Migrate all .codex/skills from old agent API (wait/send_input/ids) to
Codex v4 API (wait_agent/assign_task/targets) across 31 files in 10
skills: spec-generator, brainstorm, clean, issue-discover,
parallel-dev-cycle, review-cycle, roadmap-with-file, workflow-plan,
workflow-tdd-plan, workflow-test-fix-cycle, and spec-setup.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Specification generator - 7 phase document chain producing product brief, PRD, architecture, epics, and issues. Agent-delegated heavy phases (2-5, 6.5) with Codex review gates. Triggers on "generate spec", "create specification", "spec generator", "workflow:spec".
doc-generator
9
Spec Generator
Structured specification document generator producing a complete specification package (Product Brief, PRD, Architecture, Epics, Issues) through 7 sequential phases with multi-CLI analysis, Codex review gates, and interactive refinement. Heavy document phases are delegated to doc-generator agents to minimize main context usage. Document generation only - execution handoff via issue export to team-planex or existing workflows.
Document Chain: Each phase builds on previous outputs, creating a traceable specification chain from idea to executable issues
Agent-Delegated: Heavy document phases (2-5, 6.5) run in doc-generator agents via spawn_agent, keeping main context lean (summaries only)
Multi-Perspective Analysis: CLI tools (Gemini/Codex/Claude) provide product, technical, and user perspectives in parallel
Codex Review Gates: Phases 3, 5, 6 include Codex CLI review for quality validation before output
Interactive by Default: Each phase offers user confirmation points; -y flag enables full auto mode
Resumable Sessions: spec-config.json tracks completed phases; -c flag resumes from last checkpoint
Template-Driven: All documents generated from standardized templates with YAML frontmatter
Pure Documentation: No code generation or execution - clean handoff via issue export to execution workflows
Spec Type Specialization: Templates adapt to spec type (service/api/library/platform) via profiles for domain-specific depth
Iterative Quality: Phase 6.5 auto-fix loop repairs issues found in readiness check (max 2 iterations)
Terminology Consistency: glossary.json generated in Phase 2, injected into all subsequent phases
Agent Registry
Agent
task_name
Role File
Responsibility
Pattern
fork_context
doc-generator (Phase 2)
doc-gen-p2
~/.codex/agents/doc-generator.toml
Product brief + glossary generation
2.1 Standard
false
doc-generator (Phase 3)
doc-gen-p3
~/.codex/agents/doc-generator.toml
Requirements / PRD generation
2.1 Standard
false
doc-generator (Phase 4)
doc-gen-p4
~/.codex/agents/doc-generator.toml
Architecture + ADR generation
2.1 Standard
false
doc-generator (Phase 5)
doc-gen-p5
~/.codex/agents/doc-generator.toml
Epics & Stories generation
2.1 Standard
false
doc-generator (Phase 6.5)
doc-gen-fix
~/.codex/agents/doc-generator.toml
Auto-fix readiness issues
2.1 Standard
false
cli-explore-agent (Phase 1)
spec-explorer
~/.codex/agents/cli-explore-agent.toml
Codebase exploration
2.1 Standard
false
COMPACT PROTECTION: Agent files are execution documents. When context compression occurs and agent instructions are reduced to summaries, you MUST immediately Read the corresponding agent file to reload before continuing execution.
Fork Context Strategy
Agent
task_name
fork_context
fork_from
Rationale
cli-explore-agent
spec-explorer
false
—
Independent utility: codebase scan, isolated task
doc-generator (P2)
doc-gen-p2
false
—
Sequential pipeline: context passed via file paths in message
doc-generator (P3)
doc-gen-p3
false
—
Sequential pipeline: reads P2 output files from disk
doc-generator (P4)
doc-gen-p4
false
—
Sequential pipeline: reads P2-P3 output files from disk
doc-generator (P5)
doc-gen-p5
false
—
Sequential pipeline: reads P2-P4 output files from disk
Why all fork_context: false: This is a Pipeline pattern (2.5) — each phase produces files on disk and the next phase reads them. No agent needs the orchestrator's conversation history; all context is explicitly passed via file paths in the spawn message.
Mandatory Prerequisites
Do NOT skip: Before performing any operations, you must completely read the following documents. Proceeding without reading the specifications will result in outputs that do not meet quality standards.
Resume mechanism: -c|--continue flag reads spec-config.json.phasesCompleted, resumes from first incomplete phase.
Core Rules
Start Immediately: First action is Phase 0 (spec study), then Phase 1
Progressive Phase Loading: Read phase docs ONLY when that phase is about to execute
Auto-Continue: All phases run autonomously; proceed to next phase after current completes
Parse Every Output: Extract required data from each phase for next phase context
DO NOT STOP: Continuous 7-phase pipeline until all phases complete or user exits
Respect -y Flag: When auto mode, skip all user interaction calls, use recommended defaults
Respect -c Flag: When continue mode, load spec-config.json and resume from checkpoint
Inject Glossary: From Phase 3 onward, inject glossary.json terms into every CLI prompt
Load Profile: Read templates/profiles/{spec_type}-profile.md and inject requirements into Phase 2-5 prompts
Iterate on Failure: When Phase 6 score < 60%, auto-trigger Phase 6.5 (max 2 iterations)
Agent Delegation: Phase 2-5 and 6.5 MUST be delegated to doc-generator agents via spawn_agent — never execute inline
Lean Context: Orchestrator only sees agent return summaries from wait_agent, never the full document content
Validate Agent Output: After each wait_agent returns, verify files exist on disk and spec-config.json was updated
Lifecycle Balance: Every spawn_agent MUST have a matching close_agent after wait_agent retrieves results
Agent Delegation Protocol
For Phase 2-5 and 6.5, the orchestrator delegates to a doc-generator agent via spawn_agent. The orchestrator builds a lean context envelope — passing only paths, never file content.
After each agent phase, the orchestrator validates output:
// 1. Wait for agent completion
const result = wait_agent({ targets: ["doc-gen-p<N>"], timeout_ms: 600000 })
// 2. Handle timeout
if (result.timed_out) {
assign_task({
target: "doc-gen-p<N>",
items: [{ type: "text", text: "Please finalize current work and output results immediately." }]
})
const retryResult = wait_agent({ targets: ["doc-gen-p<N>"], timeout_ms: 120000 })
if (retryResult.timed_out) {
close_agent({ target: "doc-gen-p<N>" })
// Fall back to inline execution for this phase
}
}
// 3. Close agent (lifecycle balance)
close_agent({ target: "doc-gen-p<N>" })
// 4. Parse agent return summary
const summary = parseJSON(result.status["doc-gen-p<N>"].completed)
// 5. Validate files exist
summary.files_created.forEach(file => {
const exists = Glob(`<work-dir>/${file}`)
if (!exists.length) → Error: agent claimed file but not found
})
// 6. Verify spec-config.json updated
const config = JSON.parse(Read(`<work-dir>/spec-config.json`))
const phaseComplete = config.phasesCompleted.some(p => p.phase === N)
if (!phaseComplete) → Error: agent did not update phasesCompleted
// 7. Store summary for downstream context (do NOT read full documents)
phasesSummaries[N] = summary
Lifecycle Management
Timeout Protocol
Phase
task_name
Default Timeout
On Timeout
Phase 1 (explore)
spec-explorer
300000ms (5min)
assign_task "finalize" → re-wait 120s → close
Phase 2
doc-gen-p2
600000ms (10min)
assign_task "finalize" → re-wait 120s → close + inline fallback
Phase 3
doc-gen-p3
600000ms (10min)
assign_task "finalize" → re-wait 120s → close + inline fallback
Phase 4
doc-gen-p4
600000ms (10min)
assign_task "finalize" → re-wait 120s → close + inline fallback
Phase 5
doc-gen-p5
600000ms (10min)
assign_task "finalize" → re-wait 120s → close + inline fallback
Phase 6.5
doc-gen-fix
600000ms (10min)
assign_task "finalize" → re-wait 120s → close + force handoff
Cleanup Protocol
At the end of each agent-delegated phase, close the agent immediately after retrieving results. Each phase spawns a fresh agent — no agent persists across phases.
// Standard per-phase cleanup (after wait_agent succeeds)
close_agent({ target: "doc-gen-p<N>" })
// On workflow abort / user cancellation
const activeAgents = ["doc-gen-p2", "doc-gen-p3", "doc-gen-p4", "doc-gen-p5", "doc-gen-fix", "spec-explorer"]
activeAgents.forEach(name => {
try { close_agent({ target: name }) } catch { /* not active */ }
})