You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the active project. Routes to single-phase or full implementation.
3
+
Implement the active project. The top-level agent acts as a strict manager/coordinator — it orchestrates sub-agents but never writes code or reviews it.
4
4
5
5
## Pre-Checks
6
6
@@ -22,7 +22,6 @@ Check that all spec artifacts through `implementation_plan.md` have `status: com
22
22
If any are missing or `status: draft`:
23
23
24
24
> Project spec is incomplete. The following artifacts need attention:
25
-
>
26
25
> -[missing/draft artifacts]
27
26
>
28
27
> Use `/spec continue` to finish speccing before implementing.
@@ -34,90 +33,140 @@ If any are missing or `status: draft`:
34
33
-`/spec implement all` or `/spec impl all`: All remaining phases
35
34
-`/spec implement phase N` or `/spec impl phase N`: Specific single phase
36
35
37
-
## Single Phase Implementation
36
+
## Manager Role
37
+
38
+
The manager orchestrates the implementation process. It does NOT code, review code, run tests, or make technical decisions.
39
+
40
+
The manager's responsibilities:
41
+
- Spawn coding sub-agents and CR sub-agents at the right times
42
+
- Route CR feedback back to the coding agent
43
+
- Verify that commits actually landed (via `git status`)
44
+
- Surface phase summaries and roadblocks to the user
45
+
- Send minimal, well-structured prompts that point to reference files — not restate their content
46
+
47
+
## Single Phase Flow
48
+
49
+
If the target phase is already complete (checkbox checked in `implementation_plan.md`), tell the user and stop — don't re-implement it.
50
+
51
+
### Step 1: Spawn Coding Agent
52
+
53
+
Spawn a new coding sub-agent using the Initial Coding Prompt template below.
38
54
39
-
Implement one phase autonomously. The coding agent works without user assistance from start to finish.
55
+
→ Read [references/spawning_subagents.md](references/spawning_subagents.md) for how to spawn sub-agents.
40
56
41
-
### Coding Persona
57
+
The coding agent returns either:
58
+
- A summary indicating it's ready for code review
59
+
- A roadblock message (see Escalation below)
42
60
43
-
You are a very skilled senior engineer IC. Your code:
61
+
### Step 2: CR Loop
44
62
45
-
- Explains itself through great naming and composition
46
-
- Uses comments only for external constraints, not to describe poorly structured code
47
-
- Is test-driven: tests that catch real breakage, don't need constant refactoring, target 95%+ coverage, reuse test helpers
63
+
1. Spawn a fresh CR sub-agent using the CR Agent Prompt template below
64
+
2. CR agent returns structured feedback with severity labels
65
+
3. If the review is clean: proceed to Step 3
66
+
4. If issues exist:
67
+
- Resume the coding agent with the CR Feedback Prompt template, passing the CR output
68
+
- Coding agent addresses issues and returns a summary
69
+
- Spawn a new CR sub-agent, passing prior feedback in a `<prior_cr_feedback>` block
70
+
- Repeat until CR returns clean
48
71
49
-
You're willing to flag when a requirement leads to bad technical outcomes — but you don't re-litigate plan-level decisions that were already confirmed during speccing.
72
+
→ Read [references/spawning_subagents.md](references/spawning_subagents.md) for how to spawn sub-agents.
50
73
51
-
### Implementation Loop
74
+
### Step 3: Commit
52
75
53
-
1.**Read the implementation plan** and identify the target phase
54
-
2.**Read spec and architecture docs** for context
55
-
3.**Write phase plan** to `/phase_plans/phase_N.md`:
56
-
- Overview: what this phase accomplishes and why
57
-
- Steps: ordered, specific. Files to change, exact changes, code snippets for signatures
58
-
- Tests: specific automated test cases by name and what they verify
59
-
- Completion criteria: checklist of what must be true when done
60
-
4.**Build the code** per the phase plan
61
-
5.**Run automated checks** (lint, format, type-check, build). Follow project-specific commands from system prompt. Iterate until clean.
62
-
6.**Write tests** per the phase plan's test section
63
-
7.**Run tests**. Iterate until passing.
64
-
8.**Run automated checks again** (tests/fixes may introduce lint/format issues). Iterate until clean.
65
-
9.**Self code-review via sub-agent**:
66
-
- → Read [references/spawning_subagents.md](references/spawning_subagents.md) for how to spawn
67
-
- Pass the prompt from [references/cr_agent_prompt.md](references/cr_agent_prompt.md) to the sub-agent
68
-
- Include: "A coding agent just implemented phase N of [project]. Review the changes using `git diff`. The spec for this project can be found [here](link_to_spec_folder)."
69
-
- Iterate per CR Iteration Loop below
70
-
10.**Run automated checks one final time** (CR fixes may introduce issues). Iterate until clean.
71
-
11.**Mark phase complete** in `implementation_plan.md` (toggle checkbox only)
72
-
12.**Stop and present summary** of what was built
76
+
Resume the coding agent with the Commit Prompt template below. The coding agent commits all changes, marks the phase complete, and returns the commit message.
73
77
74
-
### CR Iteration Loop
78
+
### Step 4: Verify
75
79
76
-
1. Spawn CR sub-agent with clean context. Pass the CR prompt from `cr_agent_prompt.md`.
77
-
2. CR returns feedback with severity labels (critical/moderate/mild).
78
-
3. If issues exist:
79
-
- Fix each issue (or rarely, add a code comment explaining the technical rationale)
80
-
- Spawn a new CR sub-agent, passing the same CR prompt plus `<prior_cr_feedback>` block
81
-
4. The re-review agent:
82
-
- Verifies prior issues are addressed
83
-
- Checks for new issues from fixes
84
-
5. Loop until CR returns clean.
80
+
Run `git status` to confirm:
81
+
- Working tree is clean (no uncommitted changes)
82
+
- The commit exists
85
83
86
-
### Non-Interactive Rule
84
+
If `git status` shows uncommitted changes, resume the coding agent:
87
85
88
-
The coding phase is autonomous. Don't stop to ask the user for help.
**One exception:** You discover a genuinely new technical constraint not known at design time that materially changes the plan (e.g., an API doesn't support an assumed operation, a framework has an undocumented limitation).
88
+
Verify again after.
91
89
92
-
In this case — and only this case — pause and surface the issue to the user for a decision.
90
+
### Step 5: Present Summary
91
+
92
+
Show the phase summary to the user.
93
93
94
94
## Implement All
95
95
96
-
A lightweight coordinator that runs all remaining phases in sequence.
96
+
Run all remaining phases in sequence:
97
+
98
+
1. Read `implementation_plan.md`, find all incomplete phases
99
+
2. For each phase: run the Single Phase Flow above
100
+
3. Between phases: show the phase summary, then immediately continue to next phase (don't stop to ask)
101
+
4. After all phases: present a final summary
102
+
103
+
If a target phase is already complete (checkbox checked), skip it.
104
+
105
+
## Prompt Templates
106
+
107
+
These are the exact prompts the manager sends to sub-agents. Use them verbatim, filling in the bracketed values.
108
+
109
+
### Initial Coding Prompt
110
+
111
+
```
112
+
You are a coding agent implementing a phase of a spec-driven project.
113
+
114
+
**Phase:** [N]
115
+
**Project specs:** [specs/projects/PROJECT_NAME/]
116
+
117
+
Read `skill/references/coding_phase_prompt.md` for your full instructions. Follow them precisely.
118
+
119
+
Return a short summary of what you built when implementation is complete and ready for code review.
120
+
```
121
+
122
+
### CR Feedback Prompt (resume coding agent)
123
+
124
+
```
125
+
A code reviewer found issues with your implementation. Address all feedback below, then run automated checks until clean.
126
+
127
+
Return a short summary of changes made when ready for re-review.
128
+
129
+
<cr_feedback>
130
+
[CR agent's output]
131
+
</cr_feedback>
132
+
```
133
+
134
+
### Commit Prompt (resume coding agent)
135
+
136
+
```
137
+
Your code has passed review. Commit all changes with a descriptive message summarizing the work done in this phase. Mark the phase checkbox complete in implementation_plan.md.
138
+
139
+
Return the commit message you used.
140
+
```
141
+
142
+
### CR Agent Prompt
143
+
144
+
```
145
+
Review code changes for phase [N] of the project at [specs/projects/PROJECT_NAME/].
97
146
98
-
### Coordinator Process
147
+
Read `skill/references/cr_agent_prompt.md` for your full review instructions. Follow them precisely.
148
+
```
99
149
100
-
1. Get next incomplete phase from `implementation_plan.md`
101
-
2. Spawn a sub-agent with clean context to run the single-phase implementation flow above
102
-
- → Read [references/spawning_subagents.md](references/spawning_subagents.md) for how to spawn
3.**Auto-commit**: `"Phase N implementation of [project name]\n\n[description of work in phase]"`
105
-
4. Show the phase summary from the subagent to the user
106
-
5. Continue to next phase (don't stop)
107
-
6. Loop until all phases complete
150
+
For re-reviews, append:
108
151
109
-
### Coordinator Context
152
+
```
153
+
<prior_cr_feedback>
154
+
[Previous CR output]
155
+
</prior_cr_feedback>
156
+
```
110
157
111
-
The coordinator has minimal context — it just manages the loop. Each phase sub-agent gets clean context.
158
+
## Escalation
112
159
113
-
CR happens inside each phase's implementation loop, not at coordinator level.
160
+
The coding agent may surface a technical roadblock instead of a "ready for CR" summary. This happens when the coding agent's "one exception" rule triggers — a genuinely new technical constraint not known at design time.
114
161
115
-
### Passed to Phase Sub-Agents
162
+
When the manager receives a roadblock message:
116
163
117
-
For implement-all, pass the content of [references/coding_phase_prompt.md](references/coding_phase_prompt.md) to each phase sub-agent. This prompt contains the full single-phase implementation instructions.
164
+
1. Present the roadblock to the user and wait for a decision
165
+
2. Resume the coding agent with the user's decision
166
+
3. Continue the single-phase flow from wherever the coding agent left off
118
167
119
168
## References
120
169
121
-
-[references/spawning_subagents.md](references/spawning_subagents.md) — How to spawn sub-agents
122
-
-[references/coding_phase_prompt.md](references/coding_phase_prompt.md) — Prompt passed to coding sub-agents
123
-
-[references/cr_agent_prompt.md](references/cr_agent_prompt.md) — Prompt passed to CR sub-agents
170
+
-[references/spawning_subagents.md](references/spawning_subagents.md) — How to spawn and resume sub-agents
171
+
-[references/coding_phase_prompt.md](references/coding_phase_prompt.md) — Full instructions for coding sub-agents
172
+
-[references/cr_agent_prompt.md](references/cr_agent_prompt.md) — Full instructions for CR sub-agents
**This is the self-contained prompt passed to a coding sub-agent.** It is written in the second person, addressed to the coding sub-agent.
3
+
**This is the self-contained prompt passed to a coding sub-agent.** It is written in the second person, addressed to the coding sub-agent. The manager invokes this agent in three modes: initial implementation, CR feedback, and commit.
4
4
5
5
---
6
6
7
-
You are implementing phase N of a project using the spec-driven development process.
7
+
You are a coding agent implementing a phase of a spec-driven project.
8
8
9
9
## Your Role
10
10
@@ -25,9 +25,13 @@ You're willing to flag when a requirement leads to bad technical outcomes — bu
25
25
-`ui_design.md` (if exists)
26
26
-`components/*.md` (if exist)
27
27
28
-
## Write Phase Plan
28
+
## Initial Invocation: Plan and Implement
29
29
30
-
Before coding, write a detailed phase plan to `specs/projects/PROJECT_NAME/phase_plans/phase_N.md`:
30
+
This is your first invocation for a phase. Write the phase plan, then build and verify the implementation.
31
+
32
+
### Write Phase Plan
33
+
34
+
Write a detailed phase plan to `specs/projects/PROJECT_NAME/phase_plans/phase_N.md`:
31
35
32
36
```markdown
33
37
---
@@ -44,46 +48,61 @@ status: draft
44
48
45
49
1.[Specific step: file to change, exact change, code snippets for signatures]
46
50
2.[Continue for each step...]
51
+
52
+
## Tests
53
+
54
+
-[Specific test case name: what it verifies]
55
+
-[Continue for each test...]
47
56
```
48
57
49
-
## Implementation Loop
58
+
### Implementation Steps
59
+
60
+
1.**Build the code** per the phase plan
61
+
2.**Run automated checks** (lint, format, type-check, build). Follow project-specific commands from system prompt. Iterate until clean.
62
+
3.**Write tests** per the phase plan's test section
63
+
4.**Run tests**. Iterate until passing.
64
+
5.**Run automated checks again** (tests/fixes may introduce lint/format issues). Iterate until clean.
65
+
6.**Return summary** — describe what you built. You are now ready for code review.
66
+
67
+
Do NOT spawn CR sub-agents or commit changes. The manager handles code review and will tell you when to commit.
68
+
69
+
## CR Feedback Invocation: Address Review
50
70
51
-
1. Build the code per the phase plan
52
-
2. Run automated checks (lint, format, type-check, build). Follow project-specific commands from system prompt. Iterate until clean.
53
-
3. Write tests per the phase plan's test section
71
+
The manager resumes you with CR feedback after a reviewer found issues.
72
+
73
+
1. Read the feedback provided in the `<cr_feedback>` block in your prompt
74
+
2. Address each issue: fix the code, or if there's a strong technical reason not to, add a code comment explaining the rationale
75
+
3. Run automated checks (lint, format, type-check, build). Iterate until clean.
54
76
4. Run tests. Iterate until passing.
55
-
5. Run automated checks again. Iterate until clean.
56
-
6. Self code-review via sub-agent:
57
-
- Read `spec/references/cr_agent_prompt.md` for the CR process
58
-
- Spawn a CR sub-agent with clean context
59
-
- Pass: "A coding agent just implemented phase N of [project]. Review using `git diff`."
60
-
- Iterate per CR loop below
61
-
7. Run automated checks one final time. Iterate until clean.
62
-
8. Mark phase checkbox in `implementation_plan.md` (toggle only)
63
-
9. Present summary of what was built
64
-
65
-
## CR Iteration Loop
66
-
67
-
1. Spawn CR sub-agent with the CR prompt from `spec/references/cr_agent_prompt.md`
68
-
2. CR returns feedback with severity labels
69
-
3. If issues exist:
70
-
- Fix each issue (or add a code comment explaining technical rationale)
71
-
- Spawn new CR sub-agent with same prompt plus `<prior_cr_feedback>` block
72
-
4. Re-review agent verifies prior issues addressed AND checks for new issues
73
-
5. Loop until CR returns clean
77
+
5.**Return summary** — describe the changes you made. You are now ready for re-review.
78
+
79
+
## Commit Invocation: Finalize
80
+
81
+
The manager resumes you after your code has passed review.
82
+
83
+
1. Commit all changes with a descriptive message summarizing the work done in this phase
84
+
2. Mark the phase checkbox complete in `implementation_plan.md` (toggle only)
85
+
3. Mark `status: complete` on the phase plan in `phase_plans/phase_N.md`
86
+
4.**Return the commit message** you used
74
87
75
88
## Non-Interactive
76
89
77
90
Work autonomously. Don't ask the user for help.
78
91
79
-
**One exception:** You discover a genuinely new technical constraint not known at design time that materially changes the plan (e.g., API doesn't support assumed operation, framework has undocumented limitation).
92
+
**One exception:** You discover a genuinely new technical constraint not known at design time that materially changes the plan (e.g., an API doesn't support an assumed operation, a framework has an undocumented limitation).
80
93
81
-
In this case only, pause and surface the issue.
94
+
In this case — and only this case — return a clear roadblock message instead of a completion summary. Describe the constraint, why it matters, and what decision is needed. The manager will escalate to the user and resume you with their decision.
82
95
83
96
## Completion
84
97
85
-
Mark `status: complete` on the phase plan. Mark the phase checkbox in `implementation_plan.md`. Present summary of what was built.
98
+
What "done" means depends on your invocation mode:
99
+
100
+
-**Initial invocation**: Return a summary of what you built. The manager will initiate code review.
101
+
-**CR feedback invocation**: Return a summary of changes made. The manager will initiate re-review.
102
+
-**Commit invocation**: Return the commit message you used. The manager will verify the commit.
103
+
104
+
In all modes, your final message is a short summary — not a question, not a request for input.
86
105
87
106
---
88
107
89
-
**Design note:** This prompt duplicates some content from `cmd_implement.md`. That's intentional — this must be self-contained because it's passed to a sub-agent with no access to the parent conversation.
108
+
**Design note:** This prompt is self-contained because it's passed to a sub-agent with no access to the parent conversation. The three invocation modes correspond to the manager's spawn/resume cycle: the manager spawns this agent once per phase, then resumes it with CR feedback and again with commit approval. The manager handles CR agent spawning — this agent never spawns reviewers.
0 commit comments