/implement Skill
Executes a work item's plan.md with a team of knowledge-aware agents. Agents read existing knowledge before working, report architectural findings, and the lead captures reusable insights afterward.
Resolve Paths
lore resolve
Set KNOWLEDGE_DIR to the result and WORK_DIR to $KNOWLEDGE_DIR/_work.
Agent template files live at ~/.claude/agents/ (symlinked to the lore repo). Do NOT use git rev-parse --show-toplevel for agent paths — the current repo is the target project, not the lore repo.
MANDATORY: You MUST read the actual template files from ~/.claude/agents/ when spawning agents. Do NOT skip this step. Do NOT generate inline agent prompts as a substitute. If the directory or files are missing, stop and report the error — never fall back to improvised prompts.
Step 1: Load work item and validate
- Parse arguments: extract work item name and optional
--model flag (default: sonnet, accept opus)
- Resolve work item using the same fuzzy matching algorithm as
/work:
- Exact slug match → substring match on title → substring on slug → branch match → recency → archive fallback
- If resolved item is tagged
[archived]: Warn the user: "This work item is archived. Proceed anyway?" Wait for explicit confirmation before continuing. If the user confirms, load from $WORK_DIR/_archive/<slug>/.
- Read
_meta.json, plan.md, and last entry of notes.md
- If no
plan.md: Tell user "No structured plan found. Run /spec first to create phases and tasks."
- If
plan.md has no ## Phases or no unchecked - [ ] items: Tell user "All plan tasks are already complete."
- Write branch cache — associate the current branch with this work item for downstream lookup:
lore work cache-branch --write <slug>
If the command fails, log [implement] Warning: branch cache write failed and continue — this is non-fatal.
- Present a brief summary and proceed immediately:
[implement] <Title>
Model: sonnet (override with --model opus)
Phases: N with M unchecked tasks
Step 2: Create team and generate tasks
IMPORTANT: Create the team BEFORE creating tasks. TaskCreate calls go into whichever task list is active. If you create tasks before TeamCreate, they land in the session's default list — invisible to workers who see the team's list. This produces orphaned stale tasks that persist for the rest of the session.
Create team first:
TeamCreate: team_name="impl-<slug>", description="Implementing <work item title>"
Read your team lead name from ~/.claude/teams/impl-<slug>/config.json.
Load tasks — run a single command that validates the checksum and outputs all tasks as structured text:
lore work load-tasks <slug>
- If
tasks.json exists and checksum matches: outputs a header line followed by === task-N === blocks, one per task, each with subject, activeForm, blockedBy, and description.
- If
tasks.json exists but checksum mismatches: exits with an error. Tell the user: "plan.md was edited after tasks.json was generated. Run /work regen-tasks <slug> to regenerate, or edit plan.md back." Wait for user decision.
- If
tasks.json does not exist: exits with an error. Run the fallback instead (item 4 below).
Fallback — tasks.json missing: Run the task generation script:
lore work tasks <slug>
This generates and prints the full tasks.json schema. Pipe through lore work load-tasks <slug> afterward (it will now find the file), or re-run lore work load-tasks <slug> directly.
Create tasks from the output: Read the lore work load-tasks output once. For each === task-N === block, execute one TaskCreate call using the subject, activeForm, and description fields. Track the mapping of task-N IDs to actual TaskCreate return IDs, then call TaskUpdate(addBlockedBy=[...]) for any task with a non-empty blockedBy field.
Step 3: Spawn agents
All tasks are executed by fresh worker agents. The lead does not implement tasks directly — even if the task seems small or the lead already has relevant context. Fresh agents with injected knowledge context produce cleaner results than the lead's accumulated orchestration context. If a task is too small for a worker, it should have been consolidated at spec time.
Pre-fetch knowledge for worker prompts — determine whether prefetch is needed:
If tasks lack knowledge context (manually created tasks or plans without **Knowledge context:** blocks — no ## Prior Knowledge section in task descriptions): run complementary prefetch using the task's file paths and phase objective:
# Use file paths + objective as query terms for targeted retrieval
PRIOR_KNOWLEDGE=$(lore prefetch "<phase objective> <file paths from task>" --format prompt --limit 3)
For example, if a task has **Files:** scripts/pk_search.py and **Phase objective:** Fix hyphenated-term quoting, the prefetch query would be "Fix hyphenated-term quoting pk_search.py".
If tasks have knowledge context (task descriptions contain ## Prior Knowledge): skip prefetch. This section contains either annotation-only summaries (default) or fully resolved content (when the phase specifies **Knowledge delivery:** full). In both cases, generate-tasks.py has already embedded the relevant knowledge — prefetching would duplicate or conflict with it.
Prepare advisory mixin (if advisors present) — scan all phases in plan.md for **Advisors:** blocks. If any phase declares advisors:
a. Collect advisor declarations from all phases into a single list. Each entry has the format: - advisor-name — domain scope. [must-consult|on-demand]
b. Read the advisory mixin: Read scripts/agent-protocols/advisory-consultation.md.
c. Build the {{advisors}} replacement block from the collected declarations. Format as a markdown list with name, domain, and mode clearly separated:
- **advisor-name** — domain scope. Mode: must-consult
- **advisor-name** — domain scope. Mode: on-demand
d. Resolve {{advisors}} in the mixin content by replacing the placeholder with the block from (c). Store the resolved mixin as $ADVISORY_MIXIN.
If no phases declare advisors, set $ADVISORY_MIXIN to empty.
Skill reconciliation — before spawning advisors, check if plan.md's **Related skills:** block lists skills that weren't declared as advisors in any phase:
a. Read **Related skills:** from plan.md's ## Context or ## Investigations section (if present). This is the discovery researcher's output from /spec.
b. For each matched skill, check whether any phase in plan.md declares it as an advisor (in a **Advisors:** block). A skill that appears in **Related skills:** but not in any **Advisors:** block is a candidate for late advisor declaration.
c. Declare missing advisors — for each candidate, assess whether the skill's domain overlaps with any uncompleted phase's scope. If so, add an **Advisors:** entry to that phase in plan.md:
**Advisors:**
- <skill-name>-advisor — <skill domain scope>. on-demand
Use on-demand mode for late-declared advisors (workers have already started context accumulation; must-consult would block them unnecessarily).
d. If no **Related skills:** block exists or all matched skills are already declared as advisors, skip silently — proceed to Step 3.4.
e. If new advisors were declared, re-collect all advisor declarations from plan.md phases and rebuild $ADVISORY_MIXIN (repeat Steps 3.2a–3.2d) before proceeding.
Ceremony config injection — read ceremony-level advisor overrides and merge them into the advisor pipeline:
a. Read configured advisors:
lore ceremony get implement
This returns a JSON array of skill names (e.g., ["my-custom-skill"]), or [] if no ceremony overrides are configured. If the result is [], skip to Step 3.5.
b. Declare config-injected advisors — for each skill in the returned array, check whether it is already declared as an advisor in any phase's **Advisors:** block. For each skill not already declared, add an **Advisors:** entry to the first uncompleted phase in plan.md:
**Advisors:**
- <skill-name>-advisor — <skill-name> domain (ceremony config). on-demand
Use on-demand mode for config-injected advisors. If the phase already has an **Advisors:** block, append to it rather than creating a duplicate block.
c. Rebuild advisory mixin — if any new advisors were declared in (b), re-collect all advisor declarations from all plan.md phases and rebuild $ADVISORY_MIXIN (repeat Steps 3.2a–3.2d).
d. Log config-injected advisors — for each advisor added from ceremony config, write an execution log entry:
printf 'Config-injected advisor: %s\nSource: ceremony config\nMode: on-demand\n' \
"<skill-name>-advisor" \
| bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead
Spawn advisor agents (if advisors present) — if Step 3.2, Step 3.3, or Step 3.4 found advisor declarations, spawn each unique advisor as a persistent team member before spawning workers.
For each unique advisor name collected from Step 3.2a, Step 3.3c, and Step 3.4b:
a. Build domain context — find the ## Investigations section(s) in plan.md whose topic relates to the advisor's domain scope. Extract the relevant investigation entry (findings, verified assertions, key files, implications) and format it as the advisor's domain baseline.
b. Spawn the advisor using the advisor agent definition (~/.claude/agents/advisor.md) with these template injections:
{{team_name}} → impl-<slug>
{{advisor_domain}} → the advisor's domain scope from the plan annotation
{{domain_context}} → the investigation excerpt from Step 3.5a
Task:
subagent_type: "general-purpose"
model: "<selected-model>"
team_name: "impl-<slug>"
name: "<advisor-name>"
mode: "bypassPermissions"
prompt: |
<contents of ~/.claude/agents/advisor.md with {{template}} variables resolved>
Advisors are persistent — they remain active for the entire implementation session and are shut down alongside workers in Step 4.
c. Write execution log entries — after all advisors are spawned, log each advisor's lifecycle event:
printf 'Advisor spawned: %s\nDomain: %s\nMode: %s\n' \
"<advisor-name>" "<domain scope>" "<must-consult|on-demand>" \
| bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead
Spawn worker agents — launch min(recommended_workers, 4) workers in a single message, where recommended_workers is the top-level field from tasks.json (fallback: min(task_count, 4) if the field is absent, for backward compatibility with old tasks.json files). Use the worker agent definition (~/.claude/agents/worker.md) as the base prompt, with these template injections:
{{team_name}} → impl-<slug>
{{team_lead}} → the lead name read from team config in Step 2
{{prior_knowledge}} → the $PRIOR_KNOWLEDGE block from Step 3.1 (or empty if tasks have pre-resolved knowledge)
If $ADVISORY_MIXIN is non-empty: append the resolved mixin content after the fully resolved worker.md content, separated by a blank line. The worker prompt becomes: <resolved worker.md>\n\n<resolved advisory-consultation.md>.
Task:
subagent_type: "general-purpose"
model: "<selected-model>"
team_name: "impl-<slug>"
name: "worker-N"
mode: "bypassPermissions"
prompt: |
<contents of ~/.claude/agents/worker.md with {{template}} variables resolved>
<if advisors: contents of advisory-consultation.md with {{advisors}} resolved>
Step 4: Collect progress
As worker messages arrive (delivered automatically):
Update plan.md (best-effort) — check off completed items as they arrive:
lore work check <slug> "<task-subject>"
If this fails or is missed, Step 7 reconciles from the task system.
Write execution log entry — immediately after lore work check, append to execution-log.md:
printf 'Task: %s\nChanges: %s\nSkills: %s\nObservations: %s\nInvestigation: %s\nBlockers: %s\nAdvisor input: %s\nTest result: %s\n' \
"<task-subject>" "<worker Changes field>" "<worker Skills used field>" "<worker Observations field>" \
"<worker Investigation field>" "<worker Blockers field>" "<worker Advisor input field>" "<passed|failed|skipped>" \
| bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead
Use the worker's reported Changes:, Skills used:, Observations:, Investigation:, Blockers:, and Advisor input: fields verbatim. If the worker did not report a test result, use skipped. If the worker did not report a Skills used field, use None. If the worker omitted Investigation, Blockers, or Advisor input, use None. execution-log.md is created on first write.
Log architectural findings — note interesting patterns reported by workers for Step 5
Handle blockers — if a worker reports blockers:
- Read the relevant code/context
- Send guidance via
SendMessage to the blocked worker
- If unresolvable, note in
notes.md and move on
Do NOT gate on reviewing diffs — workers proceed autonomously. The user reviews at the end.
When a batch of workers has all reported completion:
- Call
TaskList to count remaining tasks with status pending and no blockedBy dependencies (unblocked tasks).
- If unblocked tasks remain: spawn
min(unblocked_count, max_workers) fresh workers (same worker template and injections as Step 3.6, incrementing worker names as worker-N continuing from the last worker index used). Then continue collecting progress from the new batch.
max_workers is the same cap used in Step 3.6: min(recommended_workers, 4)
- Repeat this respawn cycle after each batch completes until no unblocked tasks remain.
- If no unblocked tasks remain (all tasks are complete or all remaining are blocked):
a. Send
shutdown_request to all active workers and all advisor agents (if any were spawned in Step 3.5)
b. Write advisor shutdown log entries — for each advisor that was spawned, log the shutdown:printf 'Advisor shutdown: %s\nDomain: %s\n' \
"<advisor-name>" "<domain scope>" \
| bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead
c. Run TeamDelete
Step 5: Post-implementation extraction
Invoke /remember with capture constraints scoped to the implementation:
/remember Implementation findings from <work item title> — Read all **Observations:** and **Investigation:** entries from execution-log.md and evaluate each against the capture gate. Two valid capture targets: (1) mechanism-level patterns — how the system accomplishes X broadly, evaluate for novelty against existing knowledge; (2) structural footprint — module roles, integration points, what connects to/through a file, what constrains changes — evaluate against existing architectural knowledge for what isn't yet recorded. Function-level details do not qualify. Also capture: cross-task patterns visible only from the lead's vantage. Investigation entries (debugging detours, design pivots) qualify when the root cause or resolution reveals something non-obvious about the system.
Step 6: Followup Creation Gate
Check for incomplete tasks or explicit blockers. Skip silently if everything completed cleanly.
Signal detection — check two sources:
- Incomplete tasks — call
TaskList. Flag if any tasks remain with status pending or in_progress.
- Explicit blockers — read
execution-log.md for worker report entries where Blockers: contains any text other than none (case-insensitive).
If no signals found: skip to Step 7.
If signals found: create a followup:
bash ~/.lore/scripts/create-followup.sh \
--title "Deferred work: <work item title>" \ # ≤70 chars
--source "implement" \
--attachments '[{"type":"work_item","slug":"<slug>"}]' \
--suggested-actions '[{"type":"create_work_item"}]' \
--content "<one-line summary of what didn't finish and why, followed by a checklist of remaining items>"
Step 7: Cleanup and report
- Append a session entry to
notes.md:## YYYY-MM-DDTHH:MM
**Focus:** Implementation via /implement
**Progress:** Completed N/M tasks across K phases
**Findings:** <key architectural patterns captured>
**Next:** <remaining tasks if partial, or "Implementation complete">
- Reconcile plan.md from task system — the task system is the source of truth for completion. For each completed task, ensure the corresponding plan.md checkbox is checked:
lore work check <slug> "<task-subject>"
Run this for every completed task whose checkbox is still unchecked. This catches any checkboxes missed during Step 4.
- Archival decision — based on the task system, not plan.md:
- All tasks completed: Archive the work item:
lore work archive "<slug>"
- Some tasks incomplete or blocked: Leave the work item active for later
/implement resumption
- Run
lore work heal
- Report to user:
[implement] Done.
Completed: N/M tasks
Knowledge captured: K entries to knowledge store
Remaining: <list if any, or "none — work item archived">
Followup: <"<title>" if created, omit line if not>
Consider `/retro <slug>` to evaluate knowledge system effectiveness for this work.
Handling Partial Completion
If workers hit blockers or the team can't finish all tasks:
- Capture progress to
notes.md via the session entry above
- Reconcile plan.md from the task system (Step 7.2) — completed tasks get checked, incomplete ones stay unchecked
- Report what completed and what's left
- The user can re-run
/implement later to pick up remaining tasks (Step 2 skips checked items)
Resuming Implementation
When /implement is called on a work item with partially-checked plan.md:
- Only generate tasks for unchecked
- [ ] items
- Skip phases where all items are checked
- Report: "Resuming — N remaining tasks across M phases"
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: implement-103description: Execute a spec's plan with a knowledge-aware agent team — spawns workers, tracks progress, captures architectural findings Use when this capability is needed.4---56# /implement Skill78Executes a work item's `plan.md` with a team of knowledge-aware agents. Agents read existing knowledge before working, report architectural findings, and the lead captures reusable insights afterward.910## Resolve Paths1112```bash13lore resolve14```15Set `KNOWLEDGE_DIR` to the result and `WORK_DIR` to `$KNOWLEDGE_DIR/_work`.1617Agent template files live at `~/.claude/agents/` (symlinked to the lore repo). Do NOT use `git rev-parse --show-toplevel` for agent paths — the current repo is the target project, not the lore repo.1819**MANDATORY:** You MUST read the actual template files from `~/.claude/agents/` when spawning agents. Do NOT skip this step. Do NOT generate inline agent prompts as a substitute. If the directory or files are missing, stop and report the error — never fall back to improvised prompts.2021## Step 1: Load work item and validate22231. Parse arguments: extract work item name and optional `--model` flag (default: `sonnet`, accept `opus`)242. Resolve work item using the same fuzzy matching algorithm as `/work`:25 - Exact slug match → substring match on title → substring on slug → branch match → recency → archive fallback26 - **If resolved item is tagged `[archived]`:** Warn the user: "This work item is archived. Proceed anyway?" Wait for explicit confirmation before continuing. If the user confirms, load from `$WORK_DIR/_archive/<slug>/`.273. Read `_meta.json`, `plan.md`, and last entry of `notes.md`284. **If no `plan.md`:** Tell user "No structured plan found. Run `/spec` first to create phases and tasks."295. **If `plan.md` has no `## Phases` or no unchecked `- [ ]` items:** Tell user "All plan tasks are already complete."306. **Write branch cache** — associate the current branch with this work item for downstream lookup:31 ```bash32 lore work cache-branch --write <slug>33 ```34 If the command fails, log `[implement] Warning: branch cache write failed` and continue — this is non-fatal.357. Present a brief summary and proceed immediately:36 ```37 [implement] <Title>38 Model: sonnet (override with --model opus)39 Phases: N with M unchecked tasks40 ```4142## Step 2: Create team and generate tasks4344**IMPORTANT: Create the team BEFORE creating tasks.** TaskCreate calls go into whichever task list is active. If you create tasks before TeamCreate, they land in the session's default list — invisible to workers who see the team's list. This produces orphaned stale tasks that persist for the rest of the session.45461. **Create team first:**47 ```48 TeamCreate: team_name="impl-<slug>", description="Implementing <work item title>"49 ```50512. **Read your team lead name** from `~/.claude/teams/impl-<slug>/config.json`.52533. **Load tasks** — run a single command that validates the checksum and outputs all tasks as structured text:54 ```bash55 lore work load-tasks <slug>56 ```57 - **If `tasks.json` exists and checksum matches:** outputs a header line followed by `=== task-N ===` blocks, one per task, each with `subject`, `activeForm`, `blockedBy`, and `description`.58 - **If `tasks.json` exists but checksum mismatches:** exits with an error. Tell the user: "plan.md was edited after tasks.json was generated. Run `/work regen-tasks <slug>` to regenerate, or edit plan.md back." Wait for user decision.59 - **If `tasks.json` does not exist:** exits with an error. Run the fallback instead (item 4 below).60614. **Fallback — `tasks.json` missing:** Run the task generation script:62 ```bash63 lore work tasks <slug>64 ```65 This generates and prints the full `tasks.json` schema. Pipe through `lore work load-tasks <slug>` afterward (it will now find the file), or re-run `lore work load-tasks <slug>` directly.66675. **Create tasks from the output:** Read the `lore work load-tasks` output once. For each `=== task-N ===` block, execute one `TaskCreate` call using the `subject`, `activeForm`, and `description` fields. Track the mapping of `task-N` IDs to actual TaskCreate return IDs, then call `TaskUpdate(addBlockedBy=[...])` for any task with a non-empty `blockedBy` field.6869## Step 3: Spawn agents7071**All tasks are executed by fresh worker agents.** The lead does not implement tasks directly — even if the task seems small or the lead already has relevant context. Fresh agents with injected knowledge context produce cleaner results than the lead's accumulated orchestration context. If a task is too small for a worker, it should have been consolidated at spec time.72731. **Pre-fetch knowledge for worker prompts** — determine whether prefetch is needed:7475 **If tasks lack knowledge context** (manually created tasks or plans without `**Knowledge context:**` blocks — no `## Prior Knowledge` section in task descriptions): run complementary prefetch using the task's file paths and phase objective:76 ```bash77 # Use file paths + objective as query terms for targeted retrieval78 PRIOR_KNOWLEDGE=$(lore prefetch "<phase objective> <file paths from task>" --format prompt --limit 3)79 ```80 For example, if a task has `**Files:** scripts/pk_search.py` and `**Phase objective:** Fix hyphenated-term quoting`, the prefetch query would be `"Fix hyphenated-term quoting pk_search.py"`.8182 **If tasks have knowledge context** (task descriptions contain `## Prior Knowledge`): **skip prefetch.** This section contains either annotation-only summaries (default) or fully resolved content (when the phase specifies `**Knowledge delivery:** full`). In both cases, `generate-tasks.py` has already embedded the relevant knowledge — prefetching would duplicate or conflict with it.83842. **Prepare advisory mixin (if advisors present)** — scan all phases in `plan.md` for `**Advisors:**` blocks. If any phase declares advisors:8586 a. **Collect advisor declarations** from all phases into a single list. Each entry has the format: `- advisor-name — domain scope. [must-consult|on-demand]`8788 b. **Read the advisory mixin:** Read `scripts/agent-protocols/advisory-consultation.md`.8990 c. **Build the `{{advisors}}` replacement block** from the collected declarations. Format as a markdown list with name, domain, and mode clearly separated:91 ```92 - **advisor-name** — domain scope. Mode: must-consult93 - **advisor-name** — domain scope. Mode: on-demand94 ```9596 d. **Resolve `{{advisors}}`** in the mixin content by replacing the placeholder with the block from (c). Store the resolved mixin as `$ADVISORY_MIXIN`.9798 If no phases declare advisors, set `$ADVISORY_MIXIN` to empty.991003. **Skill reconciliation** — before spawning advisors, check if plan.md's `**Related skills:**` block lists skills that weren't declared as advisors in any phase:101102 a. **Read `**Related skills:**`** from plan.md's `## Context` or `## Investigations` section (if present). This is the discovery researcher's output from `/spec`.103104 b. **For each matched skill**, check whether any phase in `plan.md` declares it as an advisor (in a `**Advisors:**` block). A skill that appears in `**Related skills:**` but not in any `**Advisors:**` block is a candidate for late advisor declaration.105106 c. **Declare missing advisors** — for each candidate, assess whether the skill's domain overlaps with any uncompleted phase's scope. If so, add an `**Advisors:**` entry to that phase in plan.md:107 ```108 **Advisors:**109 - <skill-name>-advisor — <skill domain scope>. on-demand110 ```111 Use `on-demand` mode for late-declared advisors (workers have already started context accumulation; must-consult would block them unnecessarily).112113 d. **If no `**Related skills:**` block exists** or all matched skills are already declared as advisors, skip silently — proceed to Step 3.4.114115 e. **If new advisors were declared**, re-collect all advisor declarations from plan.md phases and rebuild `$ADVISORY_MIXIN` (repeat Steps 3.2a–3.2d) before proceeding.1161174. **Ceremony config injection** — read ceremony-level advisor overrides and merge them into the advisor pipeline:118119 a. **Read configured advisors:**120 ```bash121 lore ceremony get implement122 ```123 This returns a JSON array of skill names (e.g., `["my-custom-skill"]`), or `[]` if no ceremony overrides are configured. **If the result is `[]`, skip to Step 3.5.**124125 b. **Declare config-injected advisors** — for each skill in the returned array, check whether it is already declared as an advisor in any phase's `**Advisors:**` block. For each skill not already declared, add an `**Advisors:**` entry to the first uncompleted phase in plan.md:126 ```127 **Advisors:**128 - <skill-name>-advisor — <skill-name> domain (ceremony config). on-demand129 ```130 Use `on-demand` mode for config-injected advisors. If the phase already has an `**Advisors:**` block, append to it rather than creating a duplicate block.131132 c. **Rebuild advisory mixin** — if any new advisors were declared in (b), re-collect all advisor declarations from all plan.md phases and rebuild `$ADVISORY_MIXIN` (repeat Steps 3.2a–3.2d).133134 d. **Log config-injected advisors** — for each advisor added from ceremony config, write an execution log entry:135 ```bash136 printf 'Config-injected advisor: %s\nSource: ceremony config\nMode: on-demand\n' \137 "<skill-name>-advisor" \138 | bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead139 ```1401415. **Spawn advisor agents (if advisors present)** — if Step 3.2, Step 3.3, or Step 3.4 found advisor declarations, spawn each unique advisor as a persistent team member before spawning workers.142143 For each unique advisor name collected from Step 3.2a, Step 3.3c, and Step 3.4b:144145 a. **Build domain context** — find the `## Investigations` section(s) in `plan.md` whose topic relates to the advisor's domain scope. Extract the relevant investigation entry (findings, verified assertions, key files, implications) and format it as the advisor's domain baseline.146147 b. **Spawn the advisor** using the **advisor** agent definition (`~/.claude/agents/advisor.md`) with these template injections:148 - `{{team_name}}` → `impl-<slug>`149 - `{{advisor_domain}}` → the advisor's domain scope from the plan annotation150 - `{{domain_context}}` → the investigation excerpt from Step 3.5a151152 ```153 Task:154 subagent_type: "general-purpose"155 model: "<selected-model>"156 team_name: "impl-<slug>"157 name: "<advisor-name>"158 mode: "bypassPermissions"159 prompt: |160 <contents of ~/.claude/agents/advisor.md with {{template}} variables resolved>161 ```162163 Advisors are persistent — they remain active for the entire implementation session and are shut down alongside workers in Step 4.164165 c. **Write execution log entries** — after all advisors are spawned, log each advisor's lifecycle event:166 ```bash167 printf 'Advisor spawned: %s\nDomain: %s\nMode: %s\n' \168 "<advisor-name>" "<domain scope>" "<must-consult|on-demand>" \169 | bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead170 ```1711726. **Spawn worker agents** — launch `min(recommended_workers, 4)` workers in a single message, where `recommended_workers` is the top-level field from `tasks.json` (fallback: `min(task_count, 4)` if the field is absent, for backward compatibility with old `tasks.json` files). Use the **worker** agent definition (`~/.claude/agents/worker.md`) as the base prompt, with these template injections:173 - `{{team_name}}` → `impl-<slug>`174 - `{{team_lead}}` → the lead name read from team config in Step 2175 - `{{prior_knowledge}}` → the `$PRIOR_KNOWLEDGE` block from Step 3.1 (or empty if tasks have pre-resolved knowledge)176177 **If `$ADVISORY_MIXIN` is non-empty:** append the resolved mixin content after the fully resolved `worker.md` content, separated by a blank line. The worker prompt becomes: `<resolved worker.md>\n\n<resolved advisory-consultation.md>`.178179 ```180 Task:181 subagent_type: "general-purpose"182 model: "<selected-model>"183 team_name: "impl-<slug>"184 name: "worker-N"185 mode: "bypassPermissions"186 prompt: |187 <contents of ~/.claude/agents/worker.md with {{template}} variables resolved>188 <if advisors: contents of advisory-consultation.md with {{advisors}} resolved>189 ```190191## Step 4: Collect progress192193As worker messages arrive (delivered automatically):1941951. **Update plan.md** (best-effort) — check off completed items as they arrive:196 ```bash197 lore work check <slug> "<task-subject>"198 ```199 If this fails or is missed, Step 7 reconciles from the task system.200201 **Write execution log entry** — immediately after `lore work check`, append to `execution-log.md`:202 ```bash203 printf 'Task: %s\nChanges: %s\nSkills: %s\nObservations: %s\nInvestigation: %s\nBlockers: %s\nAdvisor input: %s\nTest result: %s\n' \204 "<task-subject>" "<worker Changes field>" "<worker Skills used field>" "<worker Observations field>" \205 "<worker Investigation field>" "<worker Blockers field>" "<worker Advisor input field>" "<passed|failed|skipped>" \206 | bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead207 ```208 Use the worker's reported **Changes:**, **Skills used:**, **Observations:**, **Investigation:**, **Blockers:**, and **Advisor input:** fields verbatim. If the worker did not report a test result, use `skipped`. If the worker did not report a Skills used field, use `None`. If the worker omitted Investigation, Blockers, or Advisor input, use `None`. `execution-log.md` is created on first write.2092102. **Log architectural findings** — note interesting patterns reported by workers for Step 52113. **Handle blockers** — if a worker reports blockers:212 - Read the relevant code/context213 - Send guidance via `SendMessage` to the blocked worker214 - If unresolvable, note in `notes.md` and move on215216Do NOT gate on reviewing diffs — workers proceed autonomously. The user reviews at the end.217218When a batch of workers has all reported completion:2191. Call `TaskList` to count remaining tasks with status `pending` and no `blockedBy` dependencies (unblocked tasks).2202. **If unblocked tasks remain:** spawn `min(unblocked_count, max_workers)` fresh workers (same worker template and injections as Step 3.6, incrementing worker names as `worker-N` continuing from the last worker index used). Then continue collecting progress from the new batch.221 - `max_workers` is the same cap used in Step 3.6: `min(recommended_workers, 4)`222 - Repeat this respawn cycle after each batch completes until no unblocked tasks remain.2233. **If no unblocked tasks remain** (all tasks are complete or all remaining are blocked):224 a. Send `shutdown_request` to all active workers and all advisor agents (if any were spawned in Step 3.5)225 b. **Write advisor shutdown log entries** — for each advisor that was spawned, log the shutdown:226 ```bash227 printf 'Advisor shutdown: %s\nDomain: %s\n' \228 "<advisor-name>" "<domain scope>" \229 | bash ~/.lore/scripts/write-execution-log.sh --slug <slug> --source implement-lead230 ```231 c. Run `TeamDelete`232233## Step 5: Post-implementation extraction234235Invoke `/remember` with capture constraints scoped to the implementation:236237```238/remember Implementation findings from <work item title> — Read all **Observations:** and **Investigation:** entries from execution-log.md and evaluate each against the capture gate. Two valid capture targets: (1) mechanism-level patterns — how the system accomplishes X broadly, evaluate for novelty against existing knowledge; (2) structural footprint — module roles, integration points, what connects to/through a file, what constrains changes — evaluate against existing architectural knowledge for what isn't yet recorded. Function-level details do not qualify. Also capture: cross-task patterns visible only from the lead's vantage. Investigation entries (debugging detours, design pivots) qualify when the root cause or resolution reveals something non-obvious about the system.239```240241## Step 6: Followup Creation Gate242243Check for incomplete tasks or explicit blockers. Skip silently if everything completed cleanly.244245**Signal detection** — check two sources:2462471. **Incomplete tasks** — call `TaskList`. Flag if any tasks remain with status `pending` or `in_progress`.2482. **Explicit blockers** — read `execution-log.md` for worker report entries where `Blockers:` contains any text other than `none` (case-insensitive).249250**If no signals found:** skip to Step 7.251252**If signals found:** create a followup:253254```bash255bash ~/.lore/scripts/create-followup.sh \256 --title "Deferred work: <work item title>" \ # ≤70 chars257 --source "implement" \258 --attachments '[{"type":"work_item","slug":"<slug>"}]' \259 --suggested-actions '[{"type":"create_work_item"}]' \260 --content "<one-line summary of what didn't finish and why, followed by a checklist of remaining items>"261```262263## Step 7: Cleanup and report2642651. Append a session entry to `notes.md`:266 ```markdown267 ## YYYY-MM-DDTHH:MM268 **Focus:** Implementation via /implement269 **Progress:** Completed N/M tasks across K phases270 **Findings:** <key architectural patterns captured>271 **Next:** <remaining tasks if partial, or "Implementation complete">272 ```2732. **Reconcile plan.md from task system** — the task system is the source of truth for completion. For each completed task, ensure the corresponding plan.md checkbox is checked:274 ```bash275 lore work check <slug> "<task-subject>"276 ```277 Run this for every completed task whose checkbox is still unchecked. This catches any checkboxes missed during Step 4.2783. **Archival decision** — based on the task system, not plan.md:279 - **All tasks completed:** Archive the work item: `lore work archive "<slug>"`280 - **Some tasks incomplete or blocked:** Leave the work item active for later `/implement` resumption2814. Run `lore work heal`2825. Report to user:283 ```284 [implement] Done.285 Completed: N/M tasks286 Knowledge captured: K entries to knowledge store287 Remaining: <list if any, or "none — work item archived">288 Followup: <"<title>" if created, omit line if not>289 Consider `/retro <slug>` to evaluate knowledge system effectiveness for this work.290 ```291292## Handling Partial Completion293294If workers hit blockers or the team can't finish all tasks:2951. Capture progress to `notes.md` via the session entry above2962. Reconcile plan.md from the task system (Step 7.2) — completed tasks get checked, incomplete ones stay unchecked2973. Report what completed and what's left2984. The user can re-run `/implement` later to pick up remaining tasks (Step 2 skips checked items)299300## Resuming Implementation301302When `/implement` is called on a work item with partially-checked `plan.md`:303- Only generate tasks for unchecked `- [ ]` items304- Skip phases where all items are checked305- Report: "Resuming — N remaining tasks across M phases"306307---308> Converted and distributed by [TomeVault](https://tomevault.io/claim/anticorrelator) — claim your Tome and manage your conversions.309<!-- tomevault:4.0:skill_md:2026-04-13 -->