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."4user-invocable: true5allowed-tools: Read, Bash, Grep, Glob, Task, WebSearch, WebFetch6kernel:7 kind: workflow8 version: 19 side_effects: writes_repo10 confirmation: none11 consumes:12 - kernel.handoff/v113 - kernel.checkpoint/v114---1516<skill id="ingest">1718<purpose>19Unified entry for new and resumed work.20New task: READ → CLASSIFY → RESEARCH → SCOPE → TESTS → EXECUTE → LEARN (human confirms each phase).21Resume: DISCOVER → VALIDATE → DIVERGENCE → COMPILE (bounded context + receipt) → RESUME AT PHASE.22For autonomous loop: /kernel:forge2324Authority order (highest wins) — a manifest is a map, not the territory:251. live verified repository state262. explicit current user instruction273. handoff or checkpoint manifest284. chronicle295. inferred conversation history30</purpose>3132<skill_load>33always: skills/debug/SKILL.md34on_classify:35 bug: skills/debug/SKILL.md36 feature: skills/build/SKILL.md, skills/architecture/SKILL.md37 refactor: skills/architecture/SKILL.md38 review: skills/review/SKILL.md39on_domain:40 frontend: skills/frontend/SKILL.md41 app: skills/app-dev/SKILL.md42on_tier:43 2+: skills/orchestration/SKILL.md44reference: skills/build/reference/build-research.md45</skill_load>4647<on_start>48```bash49agentdb read-start50ls _meta/research/ # check prior work51```5253Load /kernel:quality, /kernel:testing, /kernel:git immediately.54After classify: load task-specific skills above. Do NOT proceed without loading them.55After scope: if tier 2+, load /kernel:orchestration.56If any domain detected (API, auth, frontend, backend): load domain skills.57</on_start>5859<step id="1_classify">60task: what user wants (one sentence)61type: bug|feature|refactor|question|verify|resume|review62familiar: yes|no6364Search before asking: Glob, Grep, common paths.6566<ask_user>67 Use AskUserQuestion when: classification is ambiguous (could be bug or feature, refactor or rewrite)68 Ask: "This looks like {type_A} but could be {type_B}. Which framing fits your intent?"69 Options: type_A, type_B, or clarify70</ask_user>7172After classify: load matching workflow from workflows/{type}.md if it exists.73Workflow steps guide the phase sequence. Human confirms at each step (ingest mode).74</step>7576<branch after="classify">77 IF type == resume (or a manifest path was supplied) → go to MANIFEST RESUME (below)78 IF familiar AND tier_likely_1 → skip to step 3 (scope), mark research="skipped (familiar)"79 IF unfamiliar OR complex → proceed to step 2 (research)80 ALWAYS: check _meta/research/ cache regardless (cache != full research)81</branch>8283<step id="1b_manifest_resume" trigger="classify.type == resume">84 Resume from a kernel.handoff/v1 or kernel.checkpoint/v1 manifest. The runtime CLI:85 `KM="${CLAUDE_PLUGIN_ROOT:-.}/orchestration/manifest/kernel-manifest"`8687 1. **Discover**: explicit path if the user gave one, else:88 ```bash89 "$KM" latest # newest across _meta/checkpoints/ + _meta/handoffs/90 ```91 Legacy markdown handoffs (_meta/handoffs/*.md) remain readable this release:92 parse goal/decisions/next-steps from prose, note "legacy handoff (deprecated,93 no validation/divergence/budget)" and suggest regenerating as JSON. Removal94 path: docs/MIGRATION-8.md.9596 2. **Validate** — a manifest that does not validate is not resumed:97 ```bash98 "$KM" validate <manifest> # exit 2 (no parser) on a sealed manifest = STOP99 ```100101 3. **Divergence** — live state wins over manifest claims:102 ```bash103 "$KM" divergence <manifest> --json104 ```105 Typed divergence events apply `workflow.invalidation_rules[].when` and return106 recalculated phase statuses. Never trust an inherited phase whose inputs changed.107108 4. **Preflight**: run `"$KM" preflight <manifest>`. Canonical state permits only typed109 current-branch, path-exists, and allowlisted argv checks; raw shell is invalid.110111 5. **Compile bounded context** — read the bundle, not the raw tree:112 ```bash113 "$KM" compile <manifest> --bundle-out /tmp/resume-bundle.md --receipt-out _meta/reports/receipt-{date}.json114 ```115 The receipt (kernel.context-receipt/v1) reports estimated tokens per layer and116 status: within_budget → proceed · target_exceeded → drop optional selectors,117 proceed with a note · maximum_exceeded (exit 3) → STOP, report the receipt,118 ask before loading anything.119120 6. **Activate** the policy (arms the guard-context hook for sealed/bounded):121 ```bash122 "$KM" activate <manifest>123 ```124 sealed: forbidden globs are hook-BLOCKED; do not fight the hook — amend the125 manifest if access is genuinely needed. bounded: extra loads are allowed but126 ledgered; justify each in the receipt's loads_beyond_manifest.127128 7. **Resume at the declared position**:129 ```bash130 "$KM" resume <manifest> # entry_phase / entrypoint / next_operation131 ```132 Skip inherited phases (already verified by divergence), execute required ones.133 Honor execution.stop_conditions and emit checkpoints at execution.checkpoints.134135 8. **Complete**: when outputs.required are verified,136 ```bash137 "$KM" deactivate --receipt _meta/reports/receipt-{date}.json138 ```139 Deactivate projects the receipt into AgentDB's observational context graph (shadow140 telemetry). Then outputs.completion (usually agentdb write-end), which records session141 outcome on that graph row when `did`/`blocked` are present.142143 Optional advisory (never auto-loads):144 ```bash145 agentdb graph-suggest {task_type}146 ```147148 Output: "Resuming {manifest}: {goal}. Entry: {entry_phase}. Receipt: {total_estimated_tokens} tokens ({status})."149</step>150151<step id="2_research" mandatory="true">152**RULE: Research without verification is theory fiction.** Every research finding must be verified153with a minimal test, prototype, or proof before it drives implementation. 8 research agents and1546 docs mean nothing if nobody built a test to prove the approach works. (LRN-F11)155156<substeps>1571. Check existing: ls _meta/research/, agentdb query1582. anti_patterns FIRST: "{tech} not working", "{tech} gotchas"1593. Solutions: official docs, GitHub issues, Stack Overflow1604. Built-in check: framework > stdlib > npm package1615. **Verify**: build minimal proof (test screen, script, unit test) before committing to approach1626. Write to: _meta/research/{topic}.md (include verification result)163</substeps>164165<format>166# {Topic} Research167## Anti-Patterns1681. {pattern}: {why} → {fix}169## Proven Solution170- package: {name}@{version}171## Sources172- {urls}173</format>174175tier 2+: spawn kernel:researcher176177<ask_user>178 Use AskUserQuestion when: research reveals multiple viable approaches or unknown risks179 Ask: "Research found {N} approaches. Proceed with {recommended}, or explore alternatives?"180 Options: proceed, explore alternatives, skip research181</ask_user>182</step>183184<step id="3_scope">185files:186 1: {path} - {what changes}187count: N188tier: 1|2|3189190<tiers>1911: reversible + loud if wrong → execute inline1922: persistent or moderately quiet → plan, execute inline; delegate a surgeon only for heavy file-disjoint work; verify1933: hard to undo, quiet if wrong, or wide blast radius → contract + surgeon + adversary194ambiguous: assume higher. File count is only a weak hint, never the trigger.195</tiers>196197<ask_user>198 Use AskUserQuestion when: tier classification is borderline (e.g., 2-3 files but complex coupling)199 Ask: "Scoped to {N} files — tier {X}. Confirm tier, or should I treat as tier {X+1}?"200 Options: confirm tier {X}, bump to tier {X+1}201202 When the request itself is underspecified (any GOAL/CONSTRAINTS/INPUTS/OUTPUTS/DONE-WHEN203 field unknowable), run the structured interview from skills/build/SKILL.md "The204 interview" BEFORE scoping: batched AskUserQuestion rounds over intent, implementation205 forks, veto-risk UX, edge behavior, and tradeoffs. Bounded choices only; open-ended206 direction stays prose. Answers are quoted into the spec/commission so each decision207 carries its authority.208</ask_user>209</step>210211<branch after="scope">212 IF scope reveals unknowns not covered by research → loop to step 2 with narrowed query213 IF scope is clear → proceed to step 4214</branch>215216<step id="4_tests" mandatory="true">217<rule>Define success before coding. Tests first.</rule>218skill_ref: skills/build/reference/testing.md219220done_when:221 - observable outcome 1222 - edge case handled223224evals:225 code_grader: PASS/FAIL command226 regression: existing tests pass227228<principles>229mock_boundaries_only: external APIs, DBs230edge_cases_first: null, empty, boundary, timeout231strong_assertions: specific values232</principles>233</step>234235<step id="4b_spec_completeness" mandatory="true">236<rule>Spec framing > contract framing. Execution-ready, not goal-shaped.</rule>237238Specification prompts with exact code achieve 100% success across all scopes (modelmind H002/H003,2390.95 confidence). Contract framing ("achieve X under constraint Y") leaves interpretation gaps240that agents fill incorrectly.241242Before handing to surgeon (tier 2+) or starting execution (tier 1), the spec must answer:243- **Exact file paths**: every file that will change, by absolute path244- **Exact symbols**: every function/class/type to add/modify/remove, by name245- **Exact code snippets** for non-trivial logic (not pseudocode, not "implement X")246- **Exact configs/SQL/schemas**: if the change touches them, paste the literal block247- **Exact verification commands**: how a fresh agent confirms success without asking248249Litmus test: **could a fresh agent in a new session execute this spec with zero follow-up250questions?** If no, the spec is incomplete. Return to step 3 (scope) or step 4 (tests) and fill251the gap before proceeding.252253Anti-pattern: shipping a contract that says "the surgeon will figure out X." The surgeon will254figure out X by guessing, and the guess will be wrong.255256<ask_user>257 Use AskUserQuestion when: the spec has a known gap and you need the user to decide which258 exact path to take (rather than letting the surgeon guess).259 Ask: "Spec gap at {location}: option A = {exact}, option B = {exact}. Which?"260 Options: option A, option B, other261</ask_user>262</step>263264<step id="5_execute">265<tier_1>2661. Reference research doc2672. Write failing tests (edge cases!)2683. Implement proven pattern2694. Check Big 5: skills/quality/SKILL.md2705. Run evals → /kernel:validate before commit2716. Commit when done_when satisfied272</tier_1>273274<tier_2_plus>275rule: you do NOT write code2761. /kernel:tearitapart — review plan before implementation2772. agentdb contract '{"goal":"X","files":["Y"],"tier":N}'2782b. If non-local profile: _gh_create_issue with contract goal + tier label2793. git checkout -b {type}/{name}2804. Spawn surgeon2815. Wait for checkpoint2826. (tier 3) spawn adversary2837. /kernel:validate → verify evals2848. /kernel:review — self-review before PR285</tier_2_plus>286</step>287288<branch after="execute">289 IF adversary rejects (tier 3) → return to execute with adversary feedback, max 3 retries290 IF tests fail → /kernel:diagnose, fix, re-execute291 IF blocked → checkpoint and STOP, ask human292</branch>293294<step id="6_learn" mandatory="true">295<rule>Every task teaches. Capture or lose.</rule>296297agentdb learn pattern "{what worked}" "{evidence}"298agentdb learn failure "{what broke}" "{evidence}"299Update _meta/research/ if new findings.300Suggest /kernel:retrospective if 5+ learnings accumulated since last synthesis.301Long task still running? Emit /kernel:checkpoint at natural boundaries instead of letting context accumulate (EXP-L21).302303<checkpoint>304agentdb write-end '{"task":"X","tier":N,"learned":["Z"]}'305MUST run before session ends.306</checkpoint>307</step>308309<output_format>310task: one sentence | type: bug|feature|refactor | tier: 1|2|3 | status: researching|scoping|testing|executing|complete311</output_format>312313<hard_stops>314ask_file_location→search | code_without_research→step2 | code_without_tests→step4 | code_tier2+→surgeon | skip_agentdb→go_back315</hard_stops>316317</skill>