Skip to content

Commit 2f40195

Browse files
authored
Merge pull request #1178 from Kiln-AI/scosman/updade_spec_skill
update specs skill for manager role
2 parents af2c37e + 3ae1c08 commit 2f40195

File tree

4 files changed

+202
-98
lines changed

4 files changed

+202
-98
lines changed
Lines changed: 112 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `/spec implement` — Implement Project
22

3-
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.
44

55
## Pre-Checks
66

@@ -22,7 +22,6 @@ Check that all spec artifacts through `implementation_plan.md` have `status: com
2222
If any are missing or `status: draft`:
2323

2424
> Project spec is incomplete. The following artifacts need attention:
25-
>
2625
> - [missing/draft artifacts]
2726
>
2827
> Use `/spec continue` to finish speccing before implementing.
@@ -34,90 +33,140 @@ If any are missing or `status: draft`:
3433
- `/spec implement all` or `/spec impl all`: All remaining phases
3534
- `/spec implement phase N` or `/spec impl phase N`: Specific single phase
3635

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.
3854

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.
4056

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)
4260

43-
You are a very skilled senior engineer IC. Your code:
61+
### Step 2: CR Loop
4462

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
4871

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.
5073

51-
### Implementation Loop
74+
### Step 3: Commit
5275

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.
7377

74-
### CR Iteration Loop
78+
### Step 4: Verify
7579

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
8583

86-
### Non-Interactive Rule
84+
If `git status` shows uncommitted changes, resume the coding agent:
8785

88-
The coding phase is autonomous. Don't stop to ask the user for help.
86+
> Commit appears incomplete — `git status` shows uncommitted changes. Please commit all changes.
8987
90-
**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.
9189

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.
9393

9494
## Implement All
9595

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/].
97146
98-
### Coordinator Process
147+
Read `skill/references/cr_agent_prompt.md` for your full review instructions. Follow them precisely.
148+
```
99149

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
103-
- Pass: phase number, project path, instruction to follow single-phase implementation
104-
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:
108151

109-
### Coordinator Context
152+
```
153+
<prior_cr_feedback>
154+
[Previous CR output]
155+
</prior_cr_feedback>
156+
```
110157

111-
The coordinator has minimal context — it just manages the loop. Each phase sub-agent gets clean context.
158+
## Escalation
112159

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.
114161

115-
### Passed to Phase Sub-Agents
162+
When the manager receives a roadblock message:
116163

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
118167

119168
## References
120169

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

.cursor/skills/specs/references/cmd_setup.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ Create `/specs/projects/` if it doesn't exist:
1919

2020
```bash
2121
mkdir -p specs/projects
22+
touch specs/projects/.gitkeep
2223
```
2324

25+
The `.gitkeep` file ensures the empty directory is tracked by git.
26+
2427
### 3. Monorepo Detection
2528

2629
Scan for root markers in subdirectories to detect potential sub-projects. Common markers:
@@ -47,7 +50,13 @@ Ask the user:
4750

4851
**If monorepo:**
4952

50-
1. Create `/specs/projects/` in each confirmed sub-project root.
53+
1. Create `/specs/projects/` in each confirmed sub-project root:
54+
55+
```bash
56+
mkdir -p specs/projects
57+
touch specs/projects/.gitkeep
58+
```
59+
5160
2. Create `/specs/monorepo.md` at repo root with:
5261
- Sub-project names and their paths
5362
- Brief description of what each sub-project does
@@ -124,8 +133,8 @@ Summarize what was done:
124133
```
125134
Setup complete:
126135
- Added .specs_skill_state/ to .gitignore
127-
- Created /specs/projects/ directory
128-
- [Created /specs/projects/ in sub-project roots if monorepo]
136+
- Created /specs/projects/ directory (with .gitkeep)
137+
- [Created /specs/projects/ in sub-project roots if monorepo (with .gitkeep)]
129138
- [Created /specs/monorepo.md if monorepo]
130139
- [Suggestions for external knowledge configuration]
131140
Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Coding Phase Prompt
22

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.
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.
44

55
---
66

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.
88

99
## Your Role
1010

@@ -25,9 +25,13 @@ You're willing to flag when a requirement leads to bad technical outcomes — bu
2525
- `ui_design.md` (if exists)
2626
- `components/*.md` (if exist)
2727

28-
## Write Phase Plan
28+
## Initial Invocation: Plan and Implement
2929

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`:
3135

3236
```markdown
3337
---
@@ -44,46 +48,61 @@ status: draft
4448

4549
1. [Specific step: file to change, exact change, code snippets for signatures]
4650
2. [Continue for each step...]
51+
52+
## Tests
53+
54+
- [Specific test case name: what it verifies]
55+
- [Continue for each test...]
4756
```
4857

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
5070

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.
5476
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
7487

7588
## Non-Interactive
7689

7790
Work autonomously. Don't ask the user for help.
7891

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).
8093

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.
8295

8396
## Completion
8497

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.
86105

87106
---
88107

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

Comments
 (0)