self-managing-tool-patterns
Installation
SKILL.md
Self-Managing Tool Lifecycle
The Pattern
Problem: Your tool runs as a long-lived service. Users need to check if it's healthy, upgrade it without SSH'ing in, and have it start on boot. You need this to work on both Linux (systemd) and macOS (launchd).
Approach: A doctor command for diagnostics, PEP 610 introspection for install source detection, an upgrade flow that stops-reinstalls-regenerates-restarts-verifies, and cross-platform service management with PATH forwarding.
Pattern proven in production across multiple Python CLI tools and web services.
Key Design Decisions
1. Doctor — structured checklist with colored output
Implement a doctor command that checks prerequisites, versions, service status, and update availability: