Skip to content

Commit 65b811e

Browse files
authored
Merge pull request #107 from jwm4/refactor/bugfix-skill-invocation-cleanup
refactor(bugfix): remove manual skill-loading boilerplate
2 parents 2168268 + fed38ba commit 65b811e

14 files changed

Lines changed: 343 additions & 139 deletions

File tree

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# Proposal: Remove Manual Skill-Loading Boilerplate from Bugfix Workflow
2+
3+
**Date:** 2026-04-14
4+
**Status:** Implemented
5+
**Scope:** `workflows/bugfix/` (lessons may apply to other workflows later)
6+
7+
## Context
8+
9+
The bugfix workflow has 11 skills that coordinate through a controller (or
10+
speedrun) orchestrator. During development, we discovered that the Ambient Code
11+
Platform had a bug where the built-in skill invocation tool was not functioning.
12+
Skills still *appeared* to work because the `systemPrompt` told the model where
13+
skill files lived, and the model could load them with its file-reading tool and
14+
follow the instructions manually. We engineered the workflow around this
15+
workaround, adding explicit file-path references, dispatch blocks, and
16+
return-and-re-read instructions throughout every skill.
17+
18+
The platform bug has since been fixed. The skill tool now works correctly. But
19+
the workaround scaffolding remains embedded in every skill file, adding
20+
complexity, brittleness, and — critically — encouraging the agent to use the
21+
file tool to load skills instead of the platform's native skill invocation
22+
mechanism.
23+
24+
### What the workaround looks like today
25+
26+
Every phase skill (assess, reproduce, diagnose, fix, test, review, document)
27+
contains two boilerplate blocks:
28+
29+
**Dispatch block** (top of file):
30+
31+
```markdown
32+
## Dispatch
33+
34+
If you were dispatched by the controller or by speedrun, continue below.
35+
Otherwise, read `.claude/skills/controller/SKILL.md` first — it will send
36+
you back here with the proper workflow context.
37+
```
38+
39+
**Return block** (bottom of file):
40+
41+
```markdown
42+
## When This Phase Is Done
43+
44+
...
45+
46+
Then announce which file you are returning to (e.g., "Returning to
47+
`.claude/skills/controller/SKILL.md`." or "Returning to
48+
`.claude/skills/speedrun/SKILL.md` for next phase.") and **re-read that
49+
file** for next-step guidance.
50+
```
51+
52+
The controller and speedrun skills contain complementary instructions:
53+
54+
**Controller** — "How to Execute a Phase":
55+
56+
```markdown
57+
2. **Read** the skill file from the list above. You MUST call the Read tool on
58+
the skill's `SKILL.md` file before executing.
59+
```
60+
61+
**Speedrun** — "Execute a Phase":
62+
63+
```markdown
64+
2. **Read** the phase skill from the table above
65+
...
66+
4. The skill will tell you to announce which file you are returning to and
67+
re-read it. Return to **this file** (`.claude/skills/speedrun/SKILL.md`).
68+
```
69+
70+
Both orchestrators also list every phase with its full file path (e.g.,
71+
`.claude/skills/assess/SKILL.md`), which the agent uses as an argument to the
72+
Read tool.
73+
74+
### Why this is problematic
75+
76+
1. **It bypasses the skill tool.** The instructions explicitly tell the agent to
77+
use the Read tool on `SKILL.md` files. This was necessary when the skill tool
78+
was broken, but now it means the agent is not using the platform's native
79+
skill invocation, which may handle context management, scoping, and lifecycle
80+
differently (and better) than raw file reading.
81+
82+
2. **It's not portable.** Different runners (Claude Code, Gemini CLI, Cursor,
83+
etc.) may expose skills through different mechanisms. Hardcoding "read
84+
`.claude/skills/foo/SKILL.md`" assumes a specific file layout and a specific
85+
tool for loading it. A portable workflow should say *which* skill to run, not
86+
*how* to load it.
87+
88+
3. **The return-and-re-read pattern is fragile.** Telling the agent to "re-read
89+
this file for next-step guidance" after every phase is a workaround for the
90+
fact that the controller wasn't being invoked as a skill. When the skill tool
91+
works correctly, the orchestrator (controller or speedrun) should naturally
92+
retain context after a sub-skill completes — there's no need to re-read
93+
anything.
94+
95+
4. **It adds ~20 lines of boilerplate per skill.** Across 11 skills, that's
96+
~200 lines of dispatch/return scaffolding that obscures the actual workflow
97+
logic.
98+
99+
5. **It confuses the agent.** The instructions create an unusual execution model
100+
where the agent must track which file "dispatched" it and manually navigate
101+
back. This is error-prone and was one of the main sources of reliability
102+
issues during testing.
103+
104+
## Proposal
105+
106+
### Principle: say *what* to run, not *how* to run it
107+
108+
The orchestrator skills (controller and speedrun) should tell the agent which
109+
skill to run next by name. They should not tell the agent how to load or invoke
110+
that skill. The agent (or its runner) knows how to run skills — that's a
111+
platform capability, not a workflow concern.
112+
113+
### Changes to orchestrator skills (controller, speedrun)
114+
115+
**Current pattern:**
116+
117+
```markdown
118+
1. **Assess** (`/assess`) — `.claude/skills/assess/SKILL.md`
119+
...
120+
2. **Read** the skill file from the list above. You MUST call the Read tool on
121+
the skill's `SKILL.md` file before executing.
122+
...
123+
4. When the skill is done, it will report its findings and re-read this
124+
controller. Then use "Recommending Next Steps" below to offer options.
125+
```
126+
127+
**Proposed pattern:**
128+
129+
```markdown
130+
1. **Assess** (`/assess`) — `assess` skill
131+
...
132+
2. **Run** the skill for the current phase.
133+
...
134+
4. When the skill completes, use "Recommending Next Steps" below to offer
135+
options.
136+
```
137+
138+
Specifically:
139+
140+
- Replace file paths (`.claude/skills/assess/SKILL.md`) with skill names
141+
(`assess` skill) in phase listings
142+
- Remove instructions about using the Read tool to load skills
143+
- Remove instructions about the agent returning to or re-reading the
144+
orchestrator file
145+
- Keep phase descriptions, gating rules, and recommendation logic unchanged
146+
147+
### Changes to phase skills (assess, reproduce, diagnose, fix, test, review, document, pr, summary)
148+
149+
**Remove the dispatch block entirely.** When a skill is invoked through the
150+
skill tool, it doesn't need to know who invoked it or redirect to another skill
151+
if invoked "incorrectly." The skill should just do its job.
152+
153+
**Remove the return block's re-read instruction.** When a skill completes, it
154+
should report its results. It doesn't need to tell the agent to go back and
155+
re-read the controller. The orchestrator will naturally resume after the
156+
sub-skill completes.
157+
158+
**Keep the results reporting.** The "When This Phase Is Done" section should
159+
still list what findings to report — that's genuinely useful guidance. Just
160+
remove the "announce which file you are returning to and re-read that file"
161+
part.
162+
163+
### Changes to ambient.json systemPrompt
164+
165+
**Current:**
166+
167+
```json
168+
"systemPrompt": "You are Amber, an expert colleague for systematic bug resolution.\n\nAt the start of the session, read .claude/skills/controller/SKILL.md — it defines the workflow phases, how to execute them, and how to recommend next steps."
169+
```
170+
171+
**Proposed:**
172+
173+
```json
174+
"systemPrompt": "You are Amber, an expert colleague for systematic bug resolution.\n\nAt the start of the session, run the controller skill — it defines the workflow phases, how to execute them, and how to recommend next steps."
175+
```
176+
177+
Change "read `.claude/skills/controller/SKILL.md`" to "run the controller
178+
skill."
179+
180+
### Changes to CLAUDE.md
181+
182+
**Current:**
183+
184+
```markdown
185+
All phases are implemented as skills at `.claude/skills/{name}/SKILL.md`.
186+
The workflow controller at `.claude/skills/controller/SKILL.md` manages phase
187+
transitions and recommendations. The `/speedrun` skill at
188+
`.claude/skills/speedrun/SKILL.md` runs all remaining phases without stopping.
189+
```
190+
191+
**Proposed:**
192+
193+
```markdown
194+
All phases are implemented as skills. The controller skill manages phase
195+
transitions and recommendations. The speedrun skill runs all remaining phases
196+
without stopping.
197+
```
198+
199+
Remove file paths; refer to skills by name.
200+
201+
## Files affected
202+
203+
| File | Change |
204+
|------|--------|
205+
| `.ambient/ambient.json` | Replace file path with skill name in `systemPrompt` |
206+
| `CLAUDE.md` | Replace file paths with skill names |
207+
| `.claude/skills/controller/SKILL.md` | Replace file paths with skill names in phase list; remove Read tool instructions; remove re-read-on-return instructions |
208+
| `.claude/skills/speedrun/SKILL.md` | Same as controller |
209+
| `.claude/skills/assess/SKILL.md` | Remove dispatch block; simplify "When This Phase Is Done" |
210+
| `.claude/skills/reproduce/SKILL.md` | Same |
211+
| `.claude/skills/diagnose/SKILL.md` | Same |
212+
| `.claude/skills/fix/SKILL.md` | Same |
213+
| `.claude/skills/test/SKILL.md` | Same |
214+
| `.claude/skills/review/SKILL.md` | Same |
215+
| `.claude/skills/document/SKILL.md` | Same |
216+
| `.claude/skills/pr/SKILL.md` | Remove "return to coordinating skill and re-read" |
217+
| `.claude/skills/summary/SKILL.md` | Remove conditional return-and-re-read |
218+
219+
Total: 13 files, all within `workflows/bugfix/`.
220+
221+
## What this does NOT change
222+
223+
- **Phase logic.** The actual steps within each skill (how to diagnose, how to
224+
write tests, etc.) are untouched. Only dispatch/return boilerplate is removed.
225+
- **Gating rules.** The controller's `AskUserQuestion` gates between phases
226+
remain. Speedrun's hard gates (e.g., assess PR gate) remain.
227+
- **Artifact paths.** All `artifacts/bugfix/` references stay as-is.
228+
- **Recommendation logic.** The controller's next-step recommendations are
229+
unchanged.
230+
- **Escalation rules.** `CLAUDE.md` escalation triggers are unchanged.
231+
- **The orchestration model itself.** Controller and speedrun still orchestrate
232+
phase skills. This proposal only changes how they *invoke* those skills (by
233+
name instead of by file path + Read tool).
234+
235+
## Risks
236+
237+
### The agent might not find skills by name alone
238+
239+
If the runner doesn't properly index skills, the agent might not know how to
240+
invoke a skill called "assess." Mitigation: test in ACP before merging. If the
241+
skill tool doesn't resolve names reliably, we can add a mapping hint (e.g.,
242+
"the `assess` skill at `assess/SKILL.md`") without prescribing the invocation
243+
mechanism.
244+
245+
### The skill tool might handle context differently
246+
247+
When a skill is invoked via the skill tool (vs. read with the file tool), the
248+
context management may differ — the skill's content might be scoped differently,
249+
or the agent might not retain the orchestrator's context after the skill
250+
completes. Mitigation: test the full controller flow end-to-end. If context
251+
loss is an issue, we may need to keep a lighter version of the return guidance.
252+
253+
### Behavioral regression from removing dispatch blocks
254+
255+
The dispatch block served a secondary purpose: if a user invoked a phase skill
256+
directly (e.g., by saying "/diagnose" without going through the controller), the
257+
dispatch block redirected them to the controller first. Without it, a directly-
258+
invoked skill will just execute without workflow context. This may actually be
259+
fine — the skill still works standalone, and the controller is still available
260+
if the user wants guided flow.
261+
262+
## Testing plan
263+
264+
1. **Validate JSON**`ambient.json` parses correctly after edit
265+
2. **Skill resolution** — Verify the agent can find and invoke each skill by
266+
name in ACP
267+
3. **Full controller flow** — Run a bug fix from assess through PR using the
268+
controller, confirming phase transitions work without re-read instructions
269+
4. **Speedrun flow** — Run a full speedrun and confirm it progresses through
270+
all phases
271+
5. **Direct skill invocation** — Invoke a phase skill directly (e.g.,
272+
"/diagnose") and confirm it works standalone
273+
6. **Edge cases** — Test the review → fix → test → review loop in speedrun
274+
mode; test `/summary` mid-workflow
275+
276+
## Decisions on open questions
277+
278+
1. **Skill names vs. slash-command names:** Use skill names — "the `assess`
279+
skill." Slash-command syntax might bias the agent toward looking for a
280+
command file instead of using the skill tool.
281+
282+
2. **Speedrun's phase table:** Remove file paths entirely; use only skill names.
283+
The agent shouldn't know where the files are — knowing paths encourages it
284+
to load files directly instead of using the skill tool. Keep the completion
285+
signals (artifact existence checks) in the table.
286+
287+
3. **README.md:** Leave as-is. The README is documentation for humans and agents
288+
that need to *modify* the workflow, which is a legitimate reason to know
289+
file paths and load files directly.
290+
291+
4. **Controller's "Always read skill files" rule:** Drop entirely. The
292+
controller already tells the agent when to run each skill as part of the
293+
phase execution flow. A separate general rule restating this is redundant
294+
and was really just reinforcing the Read-tool workaround.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Fix a bug",
33
"description": "Systematic workflow for analyzing, fixing, and verifying software bugs with comprehensive testing and documentation. Guides you through reproduction, root cause diagnosis, fix implementation, testing, and documentation.",
4-
"systemPrompt": "You are Amber, an expert colleague for systematic bug resolution.\n\nAt the start of the session, read .claude/skills/controller/SKILL.md — it defines the workflow phases, how to execute them, and how to recommend next steps.",
4+
"systemPrompt": "You are Amber, an expert colleague for systematic bug resolution.\n\nAt the start of the session, run the controller skill — it defines the workflow phases, how to execute them, and how to recommend next steps.",
55
"startupPrompt": "Greet the user as Amber, their bug fix assistant. Explain that you'll guide them through systematic bug resolution: assess the report, reproduce the bug, diagnose root cause, implement the fix, test it, and document everything. Ask them to describe the bug or paste a bug report or issue URL to get started."
66
}

workflows/bugfix/.claude/skills/assess/SKILL.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ description: Understand the bug report and propose a plan before taking action.
55

66
# Assess Bug Report Skill
77

8-
## Dispatch
9-
10-
If you were dispatched by the controller or by speedrun, continue below.
11-
Otherwise, read `.claude/skills/controller/SKILL.md` first — it will send
12-
you back here with the proper workflow context.
13-
14-
---
15-
168
You are reviewing a bug report to build a shared understanding with the user
179
before any work begins. This is the first phase of the bugfix workflow. Your
1810
job is to read, think, and explain — not to start fixing anything.
@@ -215,5 +207,3 @@ Report your assessment:
215207
- Your understanding of the bug
216208
- Key gaps or risks identified
217209
- Your proposed plan
218-
219-
Then announce which file you are returning to (e.g., "Returning to `.claude/skills/controller/SKILL.md`." or "Returning to `.claude/skills/speedrun/SKILL.md` for next phase.") and **re-read that file** for next-step guidance.

0 commit comments

Comments
 (0)