Authority order (highest wins) — a manifest is a map, not the territory:
- live verified repository state
- explicit current user instruction
- handoff or checkpoint manifest
- chronicle
- inferred conversation history
Load /kernel:quality, /kernel:testing, /kernel:git immediately.
After classify: load task-specific skills above. Do NOT proceed without loading them.
After scope: if tier 2+, load /kernel:orchestration.
If any domain detected (API, auth, frontend, backend): load domain skills.
Search before asking: Glob, Grep, common paths.
After classify: load matching workflow from workflows/{type}.md if it exists.
Workflow steps guide the phase sequence. Human confirms at each step (ingest mode).
Discover: explicit path if the user gave one, else:
"$KM" latest # newest across _meta/checkpoints/ + _meta/handoffs/
Legacy markdown handoffs (_meta/handoffs/*.md) remain readable this release:
parse goal/decisions/next-steps from prose, note "legacy handoff (deprecated,
no validation/divergence/budget)" and suggest regenerating as JSON. Removal
path: docs/MIGRATION-8.md.
Validate — a manifest that does not validate is not resumed:
"$KM" validate <manifest> # exit 2 (no parser) on a sealed manifest = STOP
Divergence — live state wins over manifest claims:
"$KM" divergence <manifest> --json
Typed divergence events apply workflow.invalidation_rules[].when and return
recalculated phase statuses. Never trust an inherited phase whose inputs changed.
Preflight: run "$KM" preflight <manifest>. Canonical state permits only typed
current-branch, path-exists, and allowlisted argv checks; raw shell is invalid.
Compile bounded context — read the bundle, not the raw tree:
"$KM" compile <manifest> --bundle-out /tmp/resume-bundle.md --receipt-out _meta/reports/receipt-{date}.json
The receipt (kernel.context-receipt/v1) reports estimated tokens per layer and
status: within_budget → proceed · target_exceeded → drop optional selectors,
proceed with a note · maximum_exceeded (exit 3) → STOP, report the receipt,
ask before loading anything.
Activate the policy (arms the guard-context hook for sealed/bounded):
"$KM" activate <manifest>
sealed: forbidden globs are hook-BLOCKED; do not fight the hook — amend the
manifest if access is genuinely needed. bounded: extra loads are allowed but
ledgered; justify each in the receipt's loads_beyond_manifest.
Resume at the declared position:
"$KM" resume <manifest> # entry_phase / entrypoint / next_operation
Skip inherited phases (already verified by divergence), execute required ones.
Honor execution.stop_conditions and emit checkpoints at execution.checkpoints.
Complete: when outputs.required are verified,
"$KM" deactivate --receipt _meta/reports/receipt-{date}.json
Deactivate projects the receipt into AgentDB's observational context graph (shadow
telemetry). Then outputs.completion (usually agentdb write-end), which records session
outcome on that graph row when did/blocked are present.
Optional advisory (never auto-loads):
bash agentdb graph-suggest {task_type}
Output: "Resuming {manifest}: {goal}. Entry: {entry_phase}. Receipt: {total_estimated_tokens} tokens ({status})."
tier 2+: spawn kernel:researcher
When the request itself is underspecified (any GOAL/CONSTRAINTS/INPUTS/OUTPUTS/DONE-WHEN
field unknowable), run the structured interview from skills/build/SKILL.md "The
interview" BEFORE scoping: batched AskUserQuestion rounds over intent, implementation
forks, veto-risk UX, edge behavior, and tradeoffs. Bounded choices only; open-ended
direction stays prose. Answers are quoted into the spec/commission so each decision
carries its authority.
done_when:
- observable outcome 1
- edge case handled
evals:
code_grader: PASS/FAIL command
regression: existing tests pass
Specification prompts with exact code achieve 100% success across all scopes (modelmind H002/H003,
0.95 confidence). Contract framing ("achieve X under constraint Y") leaves interpretation gaps
that agents fill incorrectly.
Before handing to surgeon (tier 2+) or starting execution (tier 1), the spec must answer:
- Exact file paths: every file that will change, by absolute path
- Exact symbols: every function/class/type to add/modify/remove, by name
- Exact code snippets for non-trivial logic (not pseudocode, not "implement X")
- Exact configs/SQL/schemas: if the change touches them, paste the literal block
- Exact verification commands: how a fresh agent confirms success without asking
Litmus test: could a fresh agent in a new session execute this spec with zero follow-up
questions? If no, the spec is incomplete. Return to step 3 (scope) or step 4 (tests) and fill
the gap before proceeding.
Anti-pattern: shipping a contract that says "the surgeon will figure out X." The surgeon will
figure out X by guessing, and the guess will be wrong.
agentdb learn pattern "{what worked}" "{evidence}"
agentdb learn failure "{what broke}" "{evidence}"
Update _meta/research/ if new findings.
Suggest /kernel:retrospective if 5+ learnings accumulated since last synthesis.
Long task still running? Emit /kernel:checkpoint at natural boundaries instead of letting context accumulate (EXP-L21).
1---2name: ingest3description: Entry point for new or resumed work. Researches and scopes new tasks; validates and resumes handoff/checkpoint manifests. Triggers: start, begin, do, implement, build, fix, create, resume, continue.4---56<skill id="ingest">78<purpose>9Unified entry for new and resumed work.10New task: READ → CLASSIFY → RESEARCH → SCOPE → TESTS → EXECUTE → LEARN (human confirms each phase).11Resume: DISCOVER → VALIDATE → DIVERGENCE → COMPILE (bounded context + receipt) → RESUME AT PHASE.12For autonomous loop: /kernel:forge1314Authority order (highest wins) — a manifest is a map, not the territory:151. live verified repository state162. explicit current user instruction173. handoff or checkpoint manifest184. chronicle195. inferred conversation history20</purpose>2122<skill_load>23always: skills/debug/SKILL.md24on_classify:25 bug: skills/debug/SKILL.md26 feature: skills/build/SKILL.md, skills/architecture/SKILL.md27 refactor: skills/architecture/SKILL.md28 review: skills/review/SKILL.md29on_domain:30 frontend: skills/frontend/SKILL.md31 app: skills/app-dev/SKILL.md32on_tier:33 2+: skills/orchestration/SKILL.md34reference: skills/build/reference/build-research.md35</skill_load>3637<on_start>38```bash39agentdb read-start40ls _meta/research/ # check prior work41```4243Load /kernel:quality, /kernel:testing, /kernel:git immediately.44After classify: load task-specific skills above. Do NOT proceed without loading them.45After scope: if tier 2+, load /kernel:orchestration.46If any domain detected (API, auth, frontend, backend): load domain skills.47</on_start>4849<step id="1_classify">50task: what user wants (one sentence)51type: bug|feature|refactor|question|verify|resume|review52familiar: yes|no5354Search before asking: Glob, Grep, common paths.5556<ask_user>57 Use AskUserQuestion when: classification is ambiguous (could be bug or feature, refactor or rewrite)58 Ask: "This looks like {type_A} but could be {type_B}. Which framing fits your intent?"59 Options: type_A, type_B, or clarify60</ask_user>6162After classify: load matching workflow from workflows/{type}.md if it exists.63Workflow steps guide the phase sequence. Human confirms at each step (ingest mode).64</step>6566<branch after="classify">67 IF type == resume (or a manifest path was supplied) → go to MANIFEST RESUME (below)68 IF familiar AND tier_likely_1 → skip to step 3 (scope), mark research="skipped (familiar)"69 IF unfamiliar OR complex → proceed to step 2 (research)70 ALWAYS: check _meta/research/ cache regardless (cache != full research)71</branch>7273<step id="1b_manifest_resume" trigger="classify.type == resume">74 Resume from a kernel.handoff/v1 or kernel.checkpoint/v1 manifest. The runtime CLI:75 `KM="${CLAUDE_PLUGIN_ROOT:-.}/orchestration/manifest/kernel-manifest"`7677 1. **Discover**: explicit path if the user gave one, else:78 ```bash79 "$KM" latest # newest across _meta/checkpoints/ + _meta/handoffs/80 ```81 Legacy markdown handoffs (_meta/handoffs/*.md) remain readable this release:82 parse goal/decisions/next-steps from prose, note "legacy handoff (deprecated,83 no validation/divergence/budget)" and suggest regenerating as JSON. Removal84 path: docs/MIGRATION-8.md.8586 2. **Validate** — a manifest that does not validate is not resumed:87 ```bash88 "$KM" validate <manifest> # exit 2 (no parser) on a sealed manifest = STOP89 ```9091 3. **Divergence** — live state wins over manifest claims:92 ```bash93 "$KM" divergence <manifest> --json94 ```95 Typed divergence events apply `workflow.invalidation_rules[].when` and return96 recalculated phase statuses. Never trust an inherited phase whose inputs changed.9798 4. **Preflight**: run `"$KM" preflight <manifest>`. Canonical state permits only typed99 current-branch, path-exists, and allowlisted argv checks; raw shell is invalid.100101 5. **Compile bounded context** — read the bundle, not the raw tree:102 ```bash103 "$KM" compile <manifest> --bundle-out /tmp/resume-bundle.md --receipt-out _meta/reports/receipt-{date}.json104 ```105 The receipt (kernel.context-receipt/v1) reports estimated tokens per layer and106 status: within_budget → proceed · target_exceeded → drop optional selectors,107 proceed with a note · maximum_exceeded (exit 3) → STOP, report the receipt,108 ask before loading anything.109110 6. **Activate** the policy (arms the guard-context hook for sealed/bounded):111 ```bash112 "$KM" activate <manifest>113 ```114 sealed: forbidden globs are hook-BLOCKED; do not fight the hook — amend the115 manifest if access is genuinely needed. bounded: extra loads are allowed but116 ledgered; justify each in the receipt's loads_beyond_manifest.117118 7. **Resume at the declared position**:119 ```bash120 "$KM" resume <manifest> # entry_phase / entrypoint / next_operation121 ```122 Skip inherited phases (already verified by divergence), execute required ones.123 Honor execution.stop_conditions and emit checkpoints at execution.checkpoints.124125 8. **Complete**: when outputs.required are verified,126 ```bash127 "$KM" deactivate --receipt _meta/reports/receipt-{date}.json128 ```129 Deactivate projects the receipt into AgentDB's observational context graph (shadow130 telemetry). Then outputs.completion (usually agentdb write-end), which records session131 outcome on that graph row when `did`/`blocked` are present.132133 Optional advisory (never auto-loads):134 ```bash135 agentdb graph-suggest {task_type}136 ```137138 Output: "Resuming {manifest}: {goal}. Entry: {entry_phase}. Receipt: {total_estimated_tokens} tokens ({status})."139</step>140141<step id="2_research" mandatory="true">142**RULE: Research without verification is theory fiction.** Every research finding must be verified143with a minimal test, prototype, or proof before it drives implementation. 8 research agents and1446 docs mean nothing if nobody built a test to prove the approach works. (LRN-F11)145146<substeps>1471. Check existing: ls _meta/research/, agentdb query1482. anti_patterns FIRST: "{tech} not working", "{tech} gotchas"1493. Solutions: official docs, GitHub issues, Stack Overflow1504. Built-in check: framework > stdlib > npm package1515. **Verify**: build minimal proof (test screen, script, unit test) before committing to approach1526. Write to: _meta/research/{topic}.md (include verification result)153</substeps>154155<format>156# {Topic} Research157## Anti-Patterns1581. {pattern}: {why} → {fix}159## Proven Solution160- package: {name}@{version}161## Sources162- {urls}163</format>164165tier 2+: spawn kernel:researcher166167<ask_user>168 Use AskUserQuestion when: research reveals multiple viable approaches or unknown risks169 Ask: "Research found {N} approaches. Proceed with {recommended}, or explore alternatives?"170 Options: proceed, explore alternatives, skip research171</ask_user>172</step>173174<step id="3_scope">175files:176 1: {path} - {what changes}177count: N178tier: 1|2|3179180<tiers>1811: reversible + loud if wrong → execute inline1822: persistent or moderately quiet → plan, execute inline; delegate a surgeon only for heavy file-disjoint work; verify1833: hard to undo, quiet if wrong, or wide blast radius → contract + surgeon + adversary184ambiguous: assume higher. File count is only a weak hint, never the trigger.185</tiers>186187<ask_user>188 Use AskUserQuestion when: tier classification is borderline (e.g., 2-3 files but complex coupling)189 Ask: "Scoped to {N} files — tier {X}. Confirm tier, or should I treat as tier {X+1}?"190 Options: confirm tier {X}, bump to tier {X+1}191192 When the request itself is underspecified (any GOAL/CONSTRAINTS/INPUTS/OUTPUTS/DONE-WHEN193 field unknowable), run the structured interview from skills/build/SKILL.md "The194 interview" BEFORE scoping: batched AskUserQuestion rounds over intent, implementation195 forks, veto-risk UX, edge behavior, and tradeoffs. Bounded choices only; open-ended196 direction stays prose. Answers are quoted into the spec/commission so each decision197 carries its authority.198</ask_user>199</step>200201<branch after="scope">202 IF scope reveals unknowns not covered by research → loop to step 2 with narrowed query203 IF scope is clear → proceed to step 4204</branch>205206<step id="4_tests" mandatory="true">207<rule>Define success before coding. Tests first.</rule>208skill_ref: skills/build/reference/testing.md209210done_when:211 - observable outcome 1212 - edge case handled213214evals:215 code_grader: PASS/FAIL command216 regression: existing tests pass217218<principles>219mock_boundaries_only: external APIs, DBs220edge_cases_first: null, empty, boundary, timeout221strong_assertions: specific values222</principles>223</step>224225<step id="4b_spec_completeness" mandatory="true">226<rule>Spec framing > contract framing. Execution-ready, not goal-shaped.</rule>227228Specification prompts with exact code achieve 100% success across all scopes (modelmind H002/H003,2290.95 confidence). Contract framing ("achieve X under constraint Y") leaves interpretation gaps230that agents fill incorrectly.231232Before handing to surgeon (tier 2+) or starting execution (tier 1), the spec must answer:233- **Exact file paths**: every file that will change, by absolute path234- **Exact symbols**: every function/class/type to add/modify/remove, by name235- **Exact code snippets** for non-trivial logic (not pseudocode, not "implement X")236- **Exact configs/SQL/schemas**: if the change touches them, paste the literal block237- **Exact verification commands**: how a fresh agent confirms success without asking238239Litmus test: **could a fresh agent in a new session execute this spec with zero follow-up240questions?** If no, the spec is incomplete. Return to step 3 (scope) or step 4 (tests) and fill241the gap before proceeding.242243Anti-pattern: shipping a contract that says "the surgeon will figure out X." The surgeon will244figure out X by guessing, and the guess will be wrong.245246<ask_user>247 Use AskUserQuestion when: the spec has a known gap and you need the user to decide which248 exact path to take (rather than letting the surgeon guess).249 Ask: "Spec gap at {location}: option A = {exact}, option B = {exact}. Which?"250 Options: option A, option B, other251</ask_user>252</step>253254<step id="5_execute">255<tier_1>2561. Reference research doc2572. Write failing tests (edge cases!)2583. Implement proven pattern2594. Check Big 5: skills/quality/SKILL.md2605. Run evals → /kernel:validate before commit2616. Commit when done_when satisfied262</tier_1>263264<tier_2_plus>265rule: you do NOT write code2661. /kernel:tearitapart — review plan before implementation2672. agentdb contract '{"goal":"X","files":["Y"],"tier":N}'2682b. If non-local profile: _gh_create_issue with contract goal + tier label2693. git checkout -b {type}/{name}2704. Spawn surgeon2715. Wait for checkpoint2726. (tier 3) spawn adversary2737. /kernel:validate → verify evals2748. /kernel:review — self-review before PR275</tier_2_plus>276</step>277278<branch after="execute">279 IF adversary rejects (tier 3) → return to execute with adversary feedback, max 3 retries280 IF tests fail → /kernel:diagnose, fix, re-execute281 IF blocked → checkpoint and STOP, ask human282</branch>283284<step id="6_learn" mandatory="true">285<rule>Every task teaches. Capture or lose.</rule>286287agentdb learn pattern "{what worked}" "{evidence}"288agentdb learn failure "{what broke}" "{evidence}"289Update _meta/research/ if new findings.290Suggest /kernel:retrospective if 5+ learnings accumulated since last synthesis.291Long task still running? Emit /kernel:checkpoint at natural boundaries instead of letting context accumulate (EXP-L21).292293<checkpoint>294agentdb write-end '{"task":"X","tier":N,"learned":["Z"]}'295MUST run before session ends.296</checkpoint>297</step>298299<output_format>300task: one sentence | type: bug|feature|refactor | tier: 1|2|3 | status: researching|scoping|testing|executing|complete301</output_format>302303<hard_stops>304ask_file_location→search | code_without_research→step2 | code_without_tests→step4 | code_tier2+→surgeon | skip_agentdb→go_back305</hard_stops>306307</skill>