lanchr
npx machina-cli add skill lu-zhengda/macos-toolkit/lanchr --openclawlanchr — Launch Agent & Daemon Manager
Diagnose launch agent and daemon health:
!lanchr doctor 2>&1 || echo "lanchr not installed — brew install lu-zhengda/tap/lanchr"
Analyze the output above. Report broken plists, orphaned agents, and missing binaries. For each issue, explain the impact and recommend a fix (restart, disable, or remove). Offer to execute fixes.
Commands
| Command | Purpose | Example |
|---|---|---|
lanchr list | List all services | lanchr list --no-apple |
lanchr list -d <domain> | Filter by domain (user/global/system) | lanchr list -d user |
lanchr list -s <status> | Filter by status (running/stopped/error) | lanchr list -s error |
lanchr info <label> | Detailed service info (all plist keys + runtime) | lanchr info com.example.myapp |
lanchr search <query> | Search by label, path, or content | lanchr search redis |
lanchr enable <label> | Enable a disabled service (persists) | lanchr enable com.example.myapp |
lanchr disable <label> | Disable a service (persists) | lanchr disable com.example.myapp |
lanchr load <path> | Bootstrap a plist file | lanchr load ~/Library/LaunchAgents/com.example.plist |
lanchr unload <label> | Bootout a service | lanchr unload com.example.myapp |
lanchr restart <label> | Force restart a running service | lanchr restart com.example.myapp |
lanchr logs <label> | View service logs | lanchr logs com.example.myapp -f |
lanchr doctor | Diagnose broken plists and orphaned agents | lanchr doctor |
lanchr create | Scaffold a new plist from template | See below |
lanchr edit <label> | Open plist in $EDITOR | lanchr edit com.example.myapp |
lanchr export <label> [file] | Export agent as portable bundle | lanchr export com.me.backup agent.json |
lanchr import <file> | Import agent bundle | lanchr import agent.json |
Creating Launch Agents
Use lanchr create with templates instead of writing plist XML manually:
# Simple agent that runs a script at login
lanchr create -l com.me.backup -p /usr/local/bin/backup.sh --template simple --run-at-load
# Interval-based agent (every 30 minutes)
lanchr create -l com.me.sync -p /usr/local/bin/sync.sh --template interval --interval 1800
# Calendar-based agent (daily at 9am)
lanchr create -l com.me.report -p /usr/local/bin/report.sh --template calendar --calendar "Hour=9 Minute=0"
# Keep-alive agent (restart on crash)
lanchr create -l com.me.server -p /usr/local/bin/server --template keepalive --keep-alive
# File watcher agent
lanchr create -l com.me.watcher -p /usr/local/bin/process.sh --template watcher
Additional flags: --stdout <path>, --stderr <path>, --env KEY=VAL, --load (bootstrap after creation).
Monitor Templates
Pre-built templates that use toolkit tools for system monitoring:
# CPU/memory threshold monitoring (uses pstop)
lanchr create -l com.me.cpu-monitor -p pstop --template monitor-cpu
# Port listener monitoring (uses whport)
lanchr create -l com.me.port-monitor -p whport --template monitor-ports
# Security score monitoring (uses macdog)
lanchr create -l com.me.sec-monitor -p macdog --template monitor-security
# Disk space monitoring (uses macbroom)
lanchr create -l com.me.disk-monitor -p macbroom --template monitor-disk
Agent Portability
Export and import agent bundles for backup or migration:
# Export agent with all config
lanchr export com.me.backup backup-agent.json
# Import on another machine
lanchr import backup-agent.json
Diagnostic Workflow
lanchr doctor— identify broken plists, orphaned agents, missing binarieslanchr list -s error— find services in error statelanchr logs <label> -f— follow logs for a specific servicelanchr restart <label>— restart a misbehaving service
TUI Mode
Launch lanchr without arguments for interactive service management.
Source
git clone https://github.com/lu-zhengda/macos-toolkit/blob/main/skills/lanchr/SKILL.mdView on GitHub Overview
lanchr diagnoses the health of launch agents and daemons on macOS. It reports broken plists, orphaned agents, and missing binaries, then suggests fixes and offers to apply them. It also provides commands to create, enable/disable, load/unload, restart services, view logs, and export or import agent bundles for portability.
How This Skill Works
lanchr uses built-in Bash commands to inspect launchd configuration and runtime state, analyzing outputs to identify issues. It supports template-based creation of plist files, and can perform fixes or export agent bundles for migration, while exposing commands to list, info, enable/disable, load/unload, restart, and view logs.
When to Use It
- Diagnose broken plists, orphaned agents, or missing binaries with lanchr doctor
- Create a new launch agent from templates using lanchr create
- Enable or disable a service to persist changes
- Load, unload, restart a service or view its logs
- Export or import an agent bundle for backup or migration
Quick Start
- Step 1: lanchr doctor to diagnose issues
- Step 2: lanchr list to see services and lanchr info <label> for details
- Step 3: Use lanchr load/unload, enable/disable, or restart, or use create to add new agents
Best Practices
- Run lanchr doctor regularly to detect broken plists and orphaned agents
- Create agents from templates to ensure valid plists and sane defaults
- Always verify service status with lanchr list/info and check logs before restart
- Use enable/disable for persistent state instead of ad-hoc loading
- Export agents after changes for backup or migration
Example Use Cases
- Diagnose a failing agent with lanchr doctor and fix by restarting or removing
- Create a new launch agent from a template for a keep-alive service
- Enable a previously disabled service to persist across reboots
- Export a working agent to a portable bundle for backup
- Import a portable agent bundle on another macOS machine