harness/plugins/work-manager/common/skills/merge-subtree/SKILL.md
DANGEROUS, human-guarded merge of an impl-subtree `<task-slug>/TODO-N` worktree branch into its parent feature branch. Delegates fixup analysis to `/impl squash`, then squash-merges the branch as ONE commit using the spec's commit message, syncs the spec to what actually shipped (`/code revise` when the Outcome diverged), and deletes the worktree/branch. Every git action that changes history or removes a tree requires explicit user confirmation first — nothing runs unattended. Invoked by impl-subtree at merge time.
npx skillsauth add popoffvg/dotfiles merge-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.
Collapse a finished <task-slug>/TODO-N branch into one clean commit on the parent feature branch.
This rewrites/destroys state: it squashes history, discards the user's fixup commit messages, deletes a branch, and removes a worktree. Treat every action as irreversible. Confirm before each one.
For each action that mutates git state (merge, commit, branch delete, worktree remove, and the CLAUDE.local.md write):
A denied or skipped action stops the flow — report state and hand back to the user. Do not work around it.
<task-slug>/TODO-N branch + its worktree (created by impl-subtree)..pi/work.settings.json branch).<notes-dir>/todos/TODO-N.md — its ## Commit block is the final message; its ## Outcome is
the acceptance anchor.Resolve the names once (used by every step below):
MAIN=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")
FEATURE=$(git -C "$MAIN" rev-parse --abbrev-ref HEAD)
BRANCH="<task-slug>/TODO-N" # the branch impl-subtree created, e.g. auth-refresh/TODO-3
WT="$MAIN/../$(basename "$MAIN")-${BRANCH//\//-}" # worktree dir: '/' → '-'
git log --oneline --format='%h %s' "$BRANCH" ^"$FEATURE"
Separate spec-driven commits from fixup! commits. Show the user a summary: total commits, fixup
count, what each fixup corrected. This is informational; the actual learning happens in Step 2.
Load and follow the impl squash skill. It:
$MAIN/CLAUDE.local.md under ## Self-improvement.chore: learn from TODO-N fixups on the main feature branch if tracked.impl squash owns the full learning workflow — do not duplicate its logic here.
Show the user the exact target, source, and the full commit message (the TODO's ## Commit
Subject + Description — never a fixup comment). On approval:
cd "$MAIN" # parent feature branch
git merge --squash "$BRANCH" # ⚠ confirm before running
git commit -m "<TODO ## Commit Subject>" -m "<TODO ## Commit Description>" # ⚠ confirm message
--squash collapses every commit (spec + fixups) into one staged change; the fixup messages are
discarded. The Step 2 CLAUDE.local.md edit is not part of this — it was written to the main tree
(uncommitted if local-only, or its own chore: commit if tracked), never into the feature commit.
If git merge --squash reports conflicts, stop — show them and hand back to the user; do not
auto-resolve.
Before cleanup, confirm the squashed commit delivers the TODO's ## Outcome (run the Autotest, or
hand to impl-verify). If it DEVIATES, stop — do not delete the branch; the work is not done.
If the achieved Outcome diverged from the planned one (impl-subtree Step 5 logged
diverged: …, or the squashed change differs from the TODO's ## Changes), the spec is now stale.
Invoke /code revise <TODO-N> — it rewrites <notes-dir>/spec.md + todos/TODO-N.md to match
what the squash commit for TODO-N actually shipped. Run it against the squash commit from Step 3.
<notes-dir>/ (never source).Only after a clean merge + Outcome check + spec sync. Show both commands, confirm, then:
git worktree remove "$WT"
git branch -D "$BRANCH"
branch -D force-deletes; the branch's pre-squash history is gone after this. Confirm the squashed
commit exists on the feature branch first.
Append to <notes-dir>/worklog.md:
- YYYY-MM-DD HH:MM: [TODO-N] merged to <feature-branch> as <squash-sha>
- fixups absorbed: <n> — lessons → CLAUDE.local.md (via impl squash)
- Outcome verified: <yes/no>
- spec synced: <no — shipped as planned | yes — /code revise on <squash-sha>>
Then send the user a final report. It MUST contain the TODO's ## Outcome, verbatim, as the
headline:
## Outcome, copied verbatim from <notes-dir>/todos/TODO-N.md.yes (matches planned) | diverged: <how>, taken from the impl-subtree Step 5
achieved-Outcome entry.<squash-sha> on <feature-branch>, commit subject (the spec ## Commit Subject).<n>) and the CLAUDE.local.md rules added (via impl squash).unchanged (shipped as planned) | /code revise rewrote spec.md + TODO-N.md
to match the squash commit.branch -D before the squashed commit is confirmed present on the feature branch./code revise <TODO-N> (Step 5)
before cleanup — never delete the branch while the spec still describes work that didn't ship.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".