harness/plugins/work-manager/common/skills/impl-subtree/SKILL.md
EXPERIMENTAL implement flow. Execute one TODO inside its own git worktree + branch, commit freely as work progresses, record the user's review corrections as `git commit --fixup`, then on merge: analyze the fixups via `/impl squash` and squash-merge the branch into the feature branch as ONE commit using the spec's commit message. Opt-in alternative to plain `impl` — isolates work in a separate tree.
npx skillsauth add popoffvg/dotfiles impl-subtreeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
One TODO → one branch in one worktree → one squashed commit on the feature branch.
This is a wrapper around impl work. It adds subtree management (worktree creation, fixup
contract, merge) on top. The actual implementation logic is in impl — this skill only covers
what's different.
| Subcommand | Does |
|---|---|
| work (default) | Steps 1–5 below: create worktree, record planned Outcome, delegate to impl work, take user-review fixups, record achieved Outcome. |
| merge | Step 6: hand to merge-subtree (which calls /impl squash for fixup analysis, then human-guarded squash-merge). |
The worktree is a sibling directory of the main repo. Always resolve paths relative to the main repo root, not the worktree:
ROOT=$(git rev-parse --show-toplevel) # current tree (worktree or main)
MAIN=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)") # always the main repo root
Use $MAIN when reading/writing <notes-dir>/, .pi/work.settings.json, and CLAUDE.local.md.
Use $ROOT for file operations inside the current working tree.
impl work commits after green Autotest; additional commits as you progress.git commit --fixup=<sha>, never a normal commit. This separates "what the spec asked for" from "what the user had to correct".## Commit block./impl squash (called by merge-subtree Step 2).The feature branch is the current branch (or the wm branch in .pi/work.settings.json).
The task slug comes from the work name in .pi/work.settings.json (.name), slugified —
lowercase, non-alphanumerics → -, trimmed. Fall back to the feature branch name.
MAIN=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")
SLUG=$(jq -r '.name // empty' "$MAIN/.pi/work.settings.json" 2>/dev/null \
| tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g')
SLUG=${SLUG:-$(git -C "$MAIN" rev-parse --abbrev-ref HEAD)}
BRANCH="$SLUG/TODO-N" # e.g. auth-refresh/TODO-3
WT="$MAIN/../$(basename "$MAIN")-$SLUG-TODO-N" # sibling dir, '/' → '-'
git -C "$MAIN" worktree add "$WT" -b "$BRANCH" HEAD
cd "$WT"
<task-slug>/TODO-N.<repo>-<task-slug>-TODO-N.Make CLAUDE.local.md readable in the worktree. A worktree's directory walk never reaches the
main repo root, so a local-only CLAUDE.local.md is invisible. If git tracks it, every worktree
gets it; do nothing. If it's untracked/gitignored (the common case) and absent in the worktree,
symlink the main copy:
if [ -e "$MAIN/CLAUDE.local.md" ] && ! git -C "$MAIN" ls-files --error-unmatch CLAUDE.local.md >/dev/null 2>&1 \
&& [ ! -e "$WT/CLAUDE.local.md" ]; then
ln -s "$MAIN/CLAUDE.local.md" "$WT/CLAUDE.local.md"
fi
Keep CLAUDE.local.md gitignored in repos that use this flow.
Before editing any code, copy the TODO's ## Outcome verbatim into <notes-dir>/worklog.md:
- YYYY-MM-DD HH:MM: [TODO-N] start — Outcome (planned): <verbatim Outcome from TODO-N.md>
This is the acceptance anchor. The achieved Outcome (Step 5) is checked against it; the merge step refuses to land work whose achieved Outcome diverges without a logged reason.
Load and follow impl work — it handles reading context, replan guard, language-routed
implementation, Autotest, and commit. All file operations stay inside the worktree.
Use the worktree's notes directory: $ROOT/.notes/ (resolved inside the worktree, not $MAIN).
When the user reviews the branch and asks for changes:
git commit --fixup=<sha-of-commit-this-corrects>
Use git log --oneline <task-slug>/TODO-N to find the right <sha>. If the correction spans
several commits, fix up the earliest one it touches.Repeat until the user signals the branch is ready to merge ("merge it", "land it", "looks good — merge").
When the branch is ready (Autotest green, fixups settled), write what the implementation actually
delivered into <notes-dir>/worklog.md, next to the planned Outcome from Step 2:
- YYYY-MM-DD HH:MM: [TODO-N] done — Outcome (achieved): <what the code now does, in Terms>
- matches planned? <yes | diverged: …> — fixups: <n>
If the achieved Outcome diverged from the planned one, state why. The merge step reads this pair.
merge subcommand)Do not squash-merge inline. Load the merge-subtree skill and follow it. It:
/impl squash to analyze fixups → CLAUDE.local.md lessons.## Commit message./code revise <TODO-N> if the achieved Outcome diverged from planned.Every destructive git action confirmed individually by the user.
--fixup, never a plain commit.merge-subtree.impl — the core implementation logic. impl-subtree wraps impl work with worktree management.impl squash — analyzes fixups and distills lessons. Called by merge-subtree Step 2.merge-subtree — the dangerous, human-guarded merge + cleanup (Step 6).spec (revise) — invoked by merge-subtree when the Outcome diverged.impl-commit — message format for in-branch commits and the final squashed message.impl-verify — run on the squashed commit after merge for an independent PASS/DEVIATES verdict.tools
Improve a whole CLAUDE.local.md — the private, per-project rules captured from user corrections. Wraps each conditional rule in a <task-relevant> block so it only surfaces for matching work, merges duplicates, generalizes one-off facts, drops stale entries, and routes raw project facts to engram. Use when the user says "improve claude.local", "clean up the local rules", "claude.local is bloated", or after the Stop hook has appended many rules.
testing
WM pipeline and conventions shared across all phases. Agents must read this before spec, impl, or verify work.
development
One entry point for spec writing, implementation, and bug fixing. Default is new (write spec → grill loop → produce notes → author TODO bodies). Other subcommands: verify (audit), revise (sync to shipped), prototype (settle a decision), code-map (diagram), impl (execute one TODO), fix (analyze cause, correct thoughts, fix behavior), help (this page). Invoke as /code <subcommand>.
development
Red-Green-Refactor cycle for bug fixes. Before fixing a bug, first write a failing test that reproduces it (Red), then make the minimal change to pass (Green), then clean up the code (Refactor). Use on any bug fix, error correction, failing test repair, or when user says "fix this bug".