claude-code-dispatch
install
source · Clone the upstream repo
git clone https://github.com/win4r/claude-code-dispatch
Claude Code · Install into ~/.claude/skills/
git clone --depth=1 https://github.com/win4r/claude-code-dispatch ~/.claude/skills/win4r-claude-code-dispatch-claude-code-dispatch
manifest:
SKILL.mdsource content
Claude Code Dispatch Skill
Dispatch development tasks to Claude Code with automatic notification on completion. Zero polling, zero token waste.
Architecture
dispatch.sh → write task-meta.json → launch Claude Code via claude_code_run.py (PTY wrapper) → [Agent Teams: --agents JSON defines Testing Agent + custom subagents] → Claude Code finishes → Stop/TaskCompleted hook fires automatically → notify-agi.sh reads meta + output → writes latest.json → sends Telegram notification (group + callback) → writes pending-wake.json (heartbeat fallback)
Quick Reference
Basic dispatch
⚠️ Always use
+ background (nohup
) — dispatch runs until done.&
nohup bash scripts/dispatch.sh \ -p "Build a Python REST API with FastAPI" \ -n "my-api" \ -g "-5006066016" \ --permission-mode bypassPermissions \ --workdir /home/ubuntu/projects/my-api \ > /tmp/dispatch-my-api.log 2>&1 &
With Agent Teams
nohup bash scripts/dispatch.sh \ -p "Build a full-stack app with React + Express" \ -n "fullstack-app" \ --agent-teams \ --permission-mode bypassPermissions \ --workdir /home/ubuntu/projects/fullstack-app \ > /tmp/dispatch-fullstack.log 2>&1 &
When
--agent-teams is passed without --agents-json, a default Testing Agent
is auto-defined via the --agents CLI flag (structured JSON, not prompt injection).
With cost controls
nohup bash scripts/dispatch.sh \ -p "Refactor the database layer" \ -n "db-refactor" \ --max-budget-usd 5.00 \ --max-turns 50 \ --fallback-model sonnet \ --permission-mode bypassPermissions \ --workdir /home/ubuntu/projects/my-app \ > /tmp/dispatch-refactor.log 2>&1 &
With custom subagents
nohup bash scripts/dispatch.sh \ -p "Build CLI tool" \ -n "cli-tool" \ --agent-teams \ --agents-json '{"security-reviewer":{"description":"Security expert","prompt":"Review for vulnerabilities","tools":["Read","Grep","Glob"],"model":"opus"}}' \ --permission-mode bypassPermissions \ --workdir /home/ubuntu/projects/cli-tool \ > /tmp/dispatch-cli.log 2>&1 &
With git worktree isolation
nohup bash scripts/dispatch.sh \ -p "Implement feature X" \ -n "feature-x" \ --worktree feature-x \ --permission-mode bypassPermissions \ --workdir /home/ubuntu/projects/my-app \ > /tmp/dispatch-feature.log 2>&1 &
All Parameters
| Param | Short | Description |
|---|---|---|
| | Task description (required*) |
| Read prompt from file (required*) | |
| | Task name for tracking |
| | Telegram group ID for notifications |
| | Working directory |
| Enable Agent Teams mode | |
| Custom subagent definitions (JSON) | |
| Display: / / | |
| / / / | |
| Tool allowlist | |
| Tool denylist | |
| Model override (sonnet/opus/haiku/full name) | |
| Auto-fallback when primary is overloaded | |
| Maximum dollar spend before stopping | |
| Maximum agentic turns | |
| Git worktree name for isolation | |
| Don't save session to disk | |
| Append text to system prompt | |
| Append system prompt from file | |
| Load MCP servers from JSON file | |
| Enable verbose logging | |
| Callback to dispatching agent's group | |
| DM callback user ID | |
| DM callback bot account | |
| | Callback session key |
* One of
--prompt or --prompt-file is required.
Hook Setup
See references/hook-setup.md for full hook configuration. The skill uses Stop, TaskCompleted, and SessionEnd hooks with the
notify-agi.sh script. HTTP hooks are also supported as an alternative.
Prompt Tips
See references/prompt-guide.md for examples and best practices, including cost control, Agent Teams, worktree isolation, custom subagents, and MCP integration.
Debugging
# Watch hook log tail -f data/claude-code-results/hook.log # Check latest result cat data/claude-code-results/latest.json | jq . # Check task metadata cat data/claude-code-results/task-meta.json | jq . # Test Telegram delivery openclaw message send --channel telegram --target "-5006066016" --message "test" # Check dispatch log tail -f /tmp/dispatch-*.log
Gotchas
- Must use PTY wrapper — Direct
can hang in exec environmentsclaude -p - Hook fires twice — Stop + SessionEnd both trigger;
deduplicates (30s window).hook-lock - Hook stdin is empty in PTY — Output read from
, not stdintask-output.txt - tee pipe race — Hook sleeps 1s for pipe flush before reading output
- Meta freshness — Hook validates meta age (<2h) and session ID
- Agent Teams cost — Use
to cap spend on multi-agent tasks--max-budget-usd - Rate limits — Claude Code has daily rate limits resetting at 11:00 UTC; check hook.log for "limit" messages