diff --git a/src/templates/case-template.md b/src/templates/case-template.md index 2996eb77..14a3575a 100644 --- a/src/templates/case-template.md +++ b/src/templates/case-template.md @@ -357,6 +357,90 @@ Instead: Fix the issue, verify, then complete. For time-aware loops: generate mo --- +## Spawn1337: Autonomous Agent Spawning + +You can spawn autonomous child agents to handle subtasks in parallel. Each agent runs in its own Claude session with full capabilities. + +### How to Spawn an Agent + +1. **Write a task spec file** (anywhere in your working directory): + +```markdown +--- +agentId: my-agent-001 +name: My Research Agent +type: explore +priority: normal +maxTokens: 150000 +maxCost: 0.50 +timeoutMinutes: 15 +canModifyParentFiles: false +contextFiles: [src/auth.ts, src/types.ts] +completionPhrase: RESEARCH_DONE +outputFormat: structured +--- + +Your task instructions here. Be specific about what you want the agent to do +and what output format you expect. +``` + +2. **Output the spawn tag** to trigger the orchestrator: + +``` +path/to/task-spec.md +``` + +The orchestrator will read the file, create the agent's workspace, and start a new Claude session. + +### Task Spec Fields + +| Field | Required | Default | Description | +|-------|----------|---------|-------------| +| `agentId` | Yes | - | Unique identifier for the agent | +| `name` | Yes | - | Human-readable name | +| `type` | No | `general` | `explore\|implement\|test\|review\|refactor\|research\|generate\|fix\|general` | +| `priority` | No | `normal` | `low\|normal\|high\|critical` | +| `maxTokens` | No | 150000 | Token budget | +| `maxCost` | No | 0.50 | Cost budget in USD | +| `timeoutMinutes` | No | 30 | Max runtime (max: 120) | +| `canModifyParentFiles` | No | `false` | Whether agent can edit parent project files | +| `contextFiles` | No | `[]` | Files to symlink into agent workspace | +| `dependsOn` | No | `[]` | Agent IDs that must complete first | +| `completionPhrase` | No | `AGENT_DONE` | Phrase agent outputs when finished | +| `outputFormat` | No | `structured` | `markdown\|json\|code\|structured\|freeform` | + +### Monitoring and Communication + +``` + +``` +Query an agent's current status and progress. + +``` + +Please also check the error handling in auth.ts + +``` +Send a message to a running agent (written to its comms directory). + +``` + +``` +Cancel a running agent (graceful shutdown). + +### Resource Limits + +- Max concurrent agents: 5 +- Max spawn depth: 3 (agents can spawn children) +- Budget warning at 80%, shutdown at 100%, force kill at 110% +- Default timeout: 30 min, max: 120 min + +### Agent Results + +When an agent completes, its result is written to `spawn-comms/result.md` in its workspace. The orchestrator notifies you via SSE events. Results include YAML frontmatter with status, summary, and files changed. + +--- + ## Code Standards ### Before Writing