Autonomous Spec Writer
Overview
<!-- CANONICAL: shared/dispatch-convention.md -->
All subagent dispatches use disk-mediated dispatch. See shared/dispatch-convention.md for the full protocol.
Fully autonomous skill that takes a GitHub epic (or equivalent issue tracker artifact), processes child tickets without human interaction, and produces complete design docs + implementation plans + machine-readable contracts per ticket. Designed to run unattended while a separate agent (or human) handles implementation.
The core insight: Separate the cognitive work (design, investigation, decision-making, planning) from the execution work (implementation, testing). One agent specs autonomously, another builds. The spec agent requires no human input after the initial invocation -- it investigates the codebase, makes design decisions, documents its reasoning, and flags uncertainty via terminal alerts rather than blocking on human answers. Contracts solve the hard problem of two async agents communicating through prose -- prose is ambiguous, contracts make inter-ticket interfaces structural and verifiable.
Invocation:
/spec https://github.com/org/repo/issues/123
/spec PROJ-456 # if Jira/Atlassian MCP is available
Announce at start: "I'm using the spec skill to autonomously produce design docs, implementation plans, and contracts for this epic."
Communication Requirement (Non-Negotiable)
After each wave completes and after each ticket within a wave reports back, output a status update to the terminal. This is NOT optional -- the user cannot see agent activity without your narration.
Every status update must include:
- Current wave -- Which wave is in progress or just completed
- Tickets completed / remaining -- Counts for the current wave and overall
- Alerts emitted -- Any medium/low/block confidence decisions from that wave
- Re-queued tickets -- Any tickets moved to a later wave due to dependency discovery
After compaction: If you just experienced context compaction, follow the Compaction Recovery procedure, re-read state from the scratch directory, and output current status before continuing. Do NOT proceed silently.
Example of GOOD narration:
"Wave 2 complete. 3/3 tickets committed. 1 medium-confidence alert on #45 (chose Redis over Postgres for session store). #67 re-queued to Wave 3 (new dependency on #45 discovered). Overall: 7/12 tickets done, 5 remaining across 2 waves."
Anti-Rationalization Table — spec
| Rationalization | Rebuttal | Rule |
|---|---|---|
| "This ticket is small, I can skip the per-document quality gate." | Ticket size does not predict specification defects. Small tickets frequently hide ambiguity that only QG surfaces. | Run the quality gate on every design doc and every implementation plan, regardless of ticket size. |
| "All per-document gates passed, the integration check is unnecessary." | Per-document PASS does not imply cross-ticket consistency. Contracts drift between tickets even when each is individually clean. | Always run the end-of-run integration quality gate after the per-ticket gates pass. |
| "The ticket body looks clear, I can skip the investigation and go straight to writing." | Ticket bodies consistently under-specify. Without investigation, autonomous decisions are made without grounding and surface as block-confidence alerts downstream. | Investigate the codebase before writing any design content; cite investigation artifacts in the design doc. |
| "The decision looks obvious, I'll record it as high-confidence without alternatives." | Listing alternatives is a forcing function for honest confidence calibration. Skipping it hides the fact that no alternatives were considered. | Every decision logs ≥1 alternative or is explicitly marked no-alternatives: true with justification. |
| "I can save state in context memory instead of the scratch directory." | Context is lost on compaction. Scratch-directory state is load-bearing for recovery. | Every orchestrator state change writes to the scratch directory before narrating. |
| "The user's general 'looks good' counts as approval to skip a gate." | Only an unambiguous instruction specifically referencing the gate is skip approval. | Record Status: SKIPPED only after explicit gate-referencing skip instruction. |
Pipeline Status
Write a status file to ~/.claude/projects/<hash>/memory/pipeline-status.md at every narration point. This file is overwritten (not appended) and provides ambient awareness for the user in a second terminal.
Write Triggers
Write the status file at every point where the Communication Requirement mandates narration: before dispatch, after completion, phase transitions, health changes, escalations, and after compaction recovery.
Status File Format
The status file uses this structure (overwritten in full each time):
# Pipeline Status
**Updated:** <current timestamp>
**Started:** <timestamp from first write — persisted across compaction>
**Skill:** spec
**Phase:** <current phase, e.g. "Wave 2 (3/4 tickets in progress)">
**Health:** <GREEN|YELLOW|RED>
**Suggested Action:** <omit when GREEN; concrete one-sentence action when YELLOW/RED>
**Elapsed:** <computed from Started>
## Recent Events
- [HH:MM] <most recent event>
- [HH:MM] <previous event>
(last 5 events, newest first)
Skill-Specific Body
Append after the shared header:
## Tickets
- Wave 1: 3/3 complete
- Wave 2: 2/4 in progress (#45 writing, #67 investigating)
- Alerts: 1 medium-confidence on #45
## Compression State
Goal: [epic URL and description]
Key Decisions:
- [accumulated decisions, max 10]
Active Constraints:
- [dependency constraints, re-queued tickets]
Next Steps:
1. [immediate next action]
2. [subsequent actions]
Health State Machine
Health transitions are one-directional within a phase: GREEN -> YELLOW -> RED. Phase boundaries reset to GREEN.
- Phase boundaries (reset to GREEN): each new wave
- YELLOW: ticket re-queued more than once, teammate failure on a ticket, medium-confidence alert
- RED: 2+ tickets failed in same wave, unresolvable dependency cycle, block-confidence alert
When health is YELLOW or RED, include **Suggested Action:** with a concrete, context-specific sentence (e.g., "Ticket #45 re-queued twice — may have an unresolvable dependency. Check dependency graph.").
Inline CLI Format
Output concise inline status alongside the status file write:
- Minor transitions (dispatch, completion): one-liner, e.g.
Wave 2 [7/12] #45 spec committed | GREEN | 45m - Phase changes and escalations: expanded block with
---separators - Health transitions: always expanded with old -> new health
Compaction Recovery
After compaction, before re-writing the status file:
- Read the
## Compression Statesection frompipeline-status.md— recover Goal, Key Decisions, Active Constraints, and Next Steps. If absent, skip to step 1. - Read the rest of
pipeline-status.mdto recoverStartedtimestamp andRecent Eventsbuffer - Reconstruct phase, health, and skill-specific body from internal state files
- Emit a Compression State Block into the conversation to seed the new context window
- Write the updated status file
- Output inline status to CLI
Epic Extraction
GitHub has no first-class "epic with child tickets" API. Use a fallback chain to extract scope units from the provided issue:
Extraction Strategy (ordered fallback)
- Sub-issues via GraphQL: Query the
trackedIssuesfield on the issue. If the issue has sub-issues, use them as scope units. - Task list checkboxes: Parse the issue body for task list items (
- [ ]/- [x]) that reference issues via#NNNsyntax. Extract referenced issue numbers as scope units. - Body issue references: Parse the issue body for any GitHub issue URLs (
https://github.com/.../issues/NNN) or#NNNreferences not inside task lists. Extract as scope units. - Manual identification: If none of the above yield scope units, present the full issue body to the user and ask: "I couldn't find discrete child tickets. Can you identify the scope units for this work? You can provide issue numbers, paste URLs, or describe the work items and I'll create tickets for each."
Handling No Discrete Tickets
If the epic represents a single monolithic piece of work (no children, user confirms it's one unit), process it as a single-ticket run: one investigation, one design doc, one contract. The orchestration flow still applies, just with a single item in the queue.
Scratch Directory
All orchestrator and teammate state is persisted to ~/.claude/projects/<project-hash>/memory/spec/scratch/<run-id>/. Full file-by-file schema (shared files, per-ticket directories, JSON shapes), reconciliation rules, stale-cleanup policy, and project-hash recovery: see