Combines BUILDER (write code) and validation (run tests) in a tight loop.
You can find active tasks in ./apex/tasks/ or run with:
/apex:implement [identifier]
Load task file and begin implementation.
Contract rules:
- Implementation MUST satisfy all AC-* or explicitly document unmet criteria
- If scope/ACs must change, append a <amendment ...> entry inside task-contract and bump its version
Unplanned patterns can be documented as "new patterns" in the final reflection,
but NOT as "patterns used" (which updates confidence).
Run: Syntax → Formatting → Type check → Unit tests → Integration tests → Coverage
Return: Validation report comparing predictions vs reality
IF only warnings:
→ Document for review phase
→ Proceed
IF all pass:
→ Proceed to write implementation section
<implementation>
<metadata>
<timestamp>[ISO]</timestamp>
<duration>[Time spent]</duration>
<iterations>[Build-validate cycles]</iterations>
</metadata>
<files-modified>
<file path="[path]">
<changes>[Summary of what changed]</changes>
<patterns-applied>
<pattern id="PAT:X:Y">[How it was used]</pattern>
</patterns-applied>
<diff-summary>[Key additions/removals]</diff-summary>
</file>
</files-modified>
<files-created>
<file path="[path]">
<purpose>[Why created]</purpose>
<patterns-applied>[PAT:IDs]</patterns-applied>
<test-file>[Corresponding test if any]</test-file>
</file>
</files-created>
<validation-results>
<syntax status="pass|fail">[Details]</syntax>
<types status="pass|fail">[Details]</types>
<tests status="pass|fail" passed="X" failed="Y" skipped="Z">[Details]</tests>
<coverage>[Percentage if available]</coverage>
</validation-results>
<acceptance-criteria-status>
<criterion id="AC-1" status="met|not-met">[Evidence or reason]</criterion>
</acceptance-criteria-status>
<patterns-used>
<pattern id="PAT:X:Y" location="file:line" outcome="worked|tweaked|failed">
[Notes on usage]
</pattern>
</patterns-used>
<issues-encountered>
<issue resolved="true|false">
<description>[What happened]</description>
<resolution>[How fixed, or why unresolved]</resolution>
</issue>
</issues-encountered>
<deviations-from-plan>
<deviation>
<planned>[What plan said]</planned>
<actual>[What we did instead]</actual>
<reason>[Why deviation was necessary]</reason>
</deviation>
</deviations-from-plan>
<reviewer-handoff>
<summary>[What was built]</summary>
<key-changes>[Most important modifications]</key-changes>
<test-coverage>[What's tested]</test-coverage>
<known-limitations>[Edge cases, TODOs]</known-limitations>
<patterns-for-reflection>[Patterns to report in the final reflection]</patterns-for-reflection>
</reviewer-handoff>
<next-steps>
Run `/apex:ship [identifier]` to review and finalize.
</next-steps>
</implementation>
Only claim patterns that exist in <plan><patterns><applying>.
In <patterns-used>, only list patterns from the plan.
Pattern IDs claimed here will be validated during /apex:ship.
VIOLATION: Claiming "PAT:NEW:THING" that was never in the plan
CONSEQUENCE: The final reflection becomes unreliable and confidence becomes meaningless
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: implement-43description: Build and validate loop (BUILDER + validation) - implements the architecture, runs tests, iterates until passing. Writes code following the plan. Use when this capability is needed.4---56<skill name="apex:implement" phase="implement">78<overview>9Implement the architecture from the plan phase. Build code, run tests, iterate until all validations pass.1011Combines BUILDER (write code) and validation (run tests) in a tight loop.12</overview>1314<phase-model>15phase_model:16 frontmatter: [research, plan, implement, rework, complete]17 rework: enabled18 db_role: [RESEARCH, ARCHITECT, BUILDER, BUILDER_VALIDATOR, REVIEWER, DOCUMENTER]19 legacy_db_role: [VALIDATOR]20source_of_truth:21 gating: frontmatter.phase22 telemetry: db_role23</phase-model>2425<phase-gate requires="plan|rework" sets="implement">26 <reads-file>./apex/tasks/[ID].md</reads-file>27 <requires-section>plan</requires-section>28 <appends-section>implementation</appends-section>29</phase-gate>3031<principles>32- **Follow the Plan**: The architecture was approved - implement it, don't redesign33- **Pattern Discipline**: Only use patterns from the plan's pattern selection34- **Fail Fast**: Run tests frequently, fix issues immediately35- **No Guessing**: If spec is unclear, return to plan or ask user36</principles>3738<initial-response>39<if-no-arguments>40I'll implement the planned architecture. Please provide the task identifier.4142You can find active tasks in `./apex/tasks/` or run with:43`/apex:implement [identifier]`44</if-no-arguments>45<if-arguments>Load task file and begin implementation.</if-arguments>46</initial-response>4748<workflow>4950<step id="1" title="Load task and verify phase">51<instructions>521. Read `./apex/tasks/[identifier].md`532. Verify frontmatter `phase: plan` OR `phase: rework`543. Parse `<task-contract>` first and treat it as authoritative scope/ACs554. Parse `<plan>` section, especially `<builder-handoff>`565. If phase == rework, treat this as a Ship REJECT rework loop576. If phase not in [plan, rework], refuse with: "Task is in [phase] phase. Expected: plan or rework"5859Contract rules:60- Implementation MUST satisfy all AC-* or explicitly document unmet criteria61- If scope/ACs must change, append a <amendments><amendment ...> entry inside task-contract and bump its version62</instructions>6364</step>6566<step id="2" title="Extract implementation directives">67<extract-from-plan>68- `<builder-handoff><mission>` - What we're building69- `<builder-handoff><core-architecture>` - The chosen approach70- `<builder-handoff><pattern-guidance>` - Patterns to apply with locations71- `<builder-handoff><implementation-order>` - Sequence of steps72- `<builder-handoff><validation-gates>` - Checks after each step73- `<builder-handoff><warnings>` - Critical risks to avoid74- `<architecture-decision><files-to-modify>` - Existing files to change75- `<architecture-decision><files-to-create>` - New files to add76</extract-from-plan>7778<extract-from-contract>79- `<task-contract><acceptance-criteria>` - AC-* to track and validate80</extract-from-contract>8182<create-todo-list>83Create TodoWrite items for each implementation step from the plan.84</create-todo-list>85</step>8687<step id="3" title="Pre-implementation verification">88<checks>89- [ ] All files to modify exist and are readable90- [ ] No syntax errors in current codebase (`npm run lint` or equivalent)91- [ ] Tests currently passing (baseline)92- [ ] Dependencies available93</checks>94<on-failure>Document blockers and ask user how to proceed.</on-failure>95</step>9697<step id="4" title="Implementation loop">98<loop until="all steps complete AND all tests pass">99100<builder-phase>101<for-each-step>1021. **Read target files** fully before modifying1032. **Apply patterns** from plan's pattern-guidance1043. **Write code** following architecture decision1054. **Document pattern usage**: `# [PAT:ID] ★★★★☆ (X uses, Y% success)`1065. **Run syntax check** immediately after writing107</for-each-step>108109<pattern-discipline>110ONLY use patterns listed in `<plan><patterns><applying>`.111DO NOT invent new pattern names.112If you need a pattern not in the plan, document it as a gap.113</pattern-discipline>114115<failure-prevention>116Review `<plan><architecture-decision><risks>` before each step.117Apply mitigations proactively.118</failure-prevention>119</builder-phase>120121<validator-phase>122<after-each-step>1231. Run validation gate from plan1242. If passes, continue to next step1253. If fails, fix and retry (max 3 attempts per step)1264. After 3 failures, document issue and ask user127</after-each-step>128129<validation-commands>130- Syntax: `npm run lint` / `ruff check` / language-appropriate131- Types: `tsc --noEmit` / `mypy` / language-appropriate132- Unit tests: `npm test` / `pytest` / language-appropriate133- Integration: As specified in plan134</validation-commands>135</validator-phase>136137<checkpoint-after-each-step>138Record a checkpoint in the task log after each step (summary + confidence).139</checkpoint-after-each-step>140141</loop>142</step>143144<step id="4.5" title="Pattern Evidence Gate">145<critical>146Before running full validation, verify all patterns you intend to claim.147</critical>148149<verification-checklist>150For each pattern in `<patterns-used>`:1511. [ ] Pattern exists in `<plan><patterns><applying>`1522. [ ] Trust score matches what's in the plan1533. [ ] Location (file:line) is accurate and verifiable1544. [ ] Outcome is honest (worked|tweaked|failed)155</verification-checklist>156157<evidence-collection>158Record pattern usage evidence BEFORE validation:159- pattern_id160- file and line range161- outcome (worked|tweaked|failed)162- notes on usage163</evidence-collection>164165<fabrication-check>166IF any pattern in `<patterns-used>` is NOT in `<plan><patterns><applying>`:167→ REMOVE it from patterns-used168→ Document as "unplanned pattern discovered"169→ Do NOT claim it in the final reflection170171Unplanned patterns can be documented as "new patterns" in the final reflection,172but NOT as "patterns used" (which updates confidence).173</fabrication-check>174</step>175176<step id="5" title="Comprehensive validation">177<critical>178This is NOT optional. Run FULL test suite before completing.179</critical>180181<spawn-validator>182<agent type="apex:test-validator">183**Task ID**: [taskId]184**Modified Files**: [list from implementation]185**Predictions**: [from plan's risk section]186187Run: Syntax → Formatting → Type check → Unit tests → Integration tests → Coverage188189Return: Validation report comparing predictions vs reality190</agent>191</spawn-validator>192193<decision-logic>194IF any failures:195 → Return to builder-phase with issue list196 → Fix and re-run validation197 → Max 3 full cycles before escalating to user198199IF only warnings:200 → Document for review phase201 → Proceed202203IF all pass:204 → Proceed to write implementation section205</decision-logic>206</step>207208<step id="6" title="Write implementation section to task file">209<output-format>210Append to `<implementation>` section:211212```xml213<implementation>214<metadata>215 <timestamp>[ISO]</timestamp>216 <duration>[Time spent]</duration>217 <iterations>[Build-validate cycles]</iterations>218</metadata>219220<files-modified>221 <file path="[path]">222 <changes>[Summary of what changed]</changes>223 <patterns-applied>224 <pattern id="PAT:X:Y">[How it was used]</pattern>225 </patterns-applied>226 <diff-summary>[Key additions/removals]</diff-summary>227 </file>228</files-modified>229230<files-created>231 <file path="[path]">232 <purpose>[Why created]</purpose>233 <patterns-applied>[PAT:IDs]</patterns-applied>234 <test-file>[Corresponding test if any]</test-file>235 </file>236</files-created>237238<validation-results>239 <syntax status="pass|fail">[Details]</syntax>240 <types status="pass|fail">[Details]</types>241 <tests status="pass|fail" passed="X" failed="Y" skipped="Z">[Details]</tests>242 <coverage>[Percentage if available]</coverage>243</validation-results>244245<acceptance-criteria-status>246 <criterion id="AC-1" status="met|not-met">[Evidence or reason]</criterion>247</acceptance-criteria-status>248249<patterns-used>250 <pattern id="PAT:X:Y" location="file:line" outcome="worked|tweaked|failed">251 [Notes on usage]252 </pattern>253</patterns-used>254255<issues-encountered>256 <issue resolved="true|false">257 <description>[What happened]</description>258 <resolution>[How fixed, or why unresolved]</resolution>259 </issue>260</issues-encountered>261262<deviations-from-plan>263 <deviation>264 <planned>[What plan said]</planned>265 <actual>[What we did instead]</actual>266 <reason>[Why deviation was necessary]</reason>267 </deviation>268</deviations-from-plan>269270<reviewer-handoff>271 <summary>[What was built]</summary>272 <key-changes>[Most important modifications]</key-changes>273 <test-coverage>[What's tested]</test-coverage>274 <known-limitations>[Edge cases, TODOs]</known-limitations>275 <patterns-for-reflection>[Patterns to report in the final reflection]</patterns-for-reflection>276</reviewer-handoff>277278<next-steps>279Run `/apex:ship [identifier]` to review and finalize.280</next-steps>281</implementation>282```283</output-format>284285<update-frontmatter>286Set `phase: implement` and `updated: [ISO timestamp]`287</update-frontmatter>288289</step>290291</workflow>292293<critical-requirements>294295<pattern-fabrication-prevention>296YOU CANNOT FABRICATE PATTERNS.297298Only claim patterns that exist in `<plan><patterns><applying>`.299In `<patterns-used>`, only list patterns from the plan.300Pattern IDs claimed here will be validated during `/apex:ship`.301302VIOLATION: Claiming "PAT:NEW:THING" that was never in the plan303CONSEQUENCE: The final reflection becomes unreliable and confidence becomes meaningless304</pattern-fabrication-prevention>305306<syntax-gate>307Before completing implementation:308- Run linting309- Check for common errors (double async, missing brackets)310- Fix ALL syntax errors before proceeding311- DO NOT transition to ship with syntax errors312</syntax-gate>313314<contract-gate>315Before finishing:316- Confirm all AC-* are met, or explicitly mark any unmet criteria with reasons317- If contract scope/ACs changed, record an amendment with rationale and bump contract version318</contract-gate>319320<spec-unclear-protocol>321If implementation reveals spec ambiguity:3221. Document the ambiguity3232. Ask user for clarification3243. If architectural change needed, note it for plan revision3254. Do NOT guess and implement wrong thing326</spec-unclear-protocol>327328</critical-requirements>329330<success-criteria>331- All implementation steps from plan completed332- All validation gates passed333- Full test suite passing334- No syntax errors335- Acceptance criteria status reported for all AC-*336- Patterns used are from plan only (Pattern Evidence Gate passed)337- Deviations documented with reasons338- Task file updated at ./apex/tasks/[ID].md339- Checkpoints recorded at start, per-step, and end340- Pattern evidence recorded for usage341- Task metadata updated for build/validate completion342</success-criteria>343344<next-phase>345`/apex:ship [identifier]` - Review, document, and reflect346</next-phase>347348</skill>349350---351> Converted and distributed by [TomeVault](https://tomevault.io/claim/benredmond) — claim your Tome and manage your conversions.352<!-- tomevault:4.0:skill_md:2026-04-13 -->