implement-worktree
Skill1 starsChanged 8 months agoMITView on GitHub
Implement a plan in an isolated git worktree. Use when user says "implement in worktree", "worktree implement", or "isolated implementation". Creates a worktree from current branch, explores affected systems with subagents, then implements phase by phase.
In this repository59 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- arch-lens-c4-containerSkill
- arch-lens-concurrencySkill
- arch-lens-data-lineageSkill
- arch-lens-deploymentSkill
- arch-lens-developmentSkill
- arch-lens-error-resilienceSkill
- arch-lens-module-dependencySkill
- arch-lens-operationalSkill
- arch-lens-process-flowSkill
- arch-lens-repository-accessSkill
- arch-lens-scenariosSkill
- arch-lens-securitySkill
- arch-lens-state-lifecycleSkill
- audit-archSkill
- audit-bugsSkill
- audit-cohesionSkill
- audit-defense-standardsSkill
- audit-frictionSkill
- audit-implSkill
- audit-testsSkill
- design-guardsSkill
- dry-walkthroughSkill
- elaborate-phaseSkill
- exp-lens-benchmark-representativenessSkill
- exp-lens-causal-assumptionsSkill
- exp-lens-comparator-constructionSkill
- exp-lens-error-budgetSkill
- exp-lens-estimand-claritySkill
- exp-lens-exploratory-confirmatorySkill
- exp-lens-fair-comparisonSkill
- exp-lens-governance-riskSkill
- exp-lens-iterative-learningSkill
- exp-lens-measurement-validitySkill
- exp-lens-pipeline-integritySkill
- exp-lens-randomization-blockingSkill
- exp-lens-reproducibility-artifactsSkill
- exp-lens-sensitivity-robustnessSkill
- exp-lens-severity-testingSkill
- exp-lens-unit-interferenceSkill
- exp-lens-validity-threatsSkill
- exp-lens-variance-stabilitySkill
- id-slopSkill
- investigateSkill
- make-arch-diagSkill
- make-experiment-diagSkill
- make-groupsSkill
- make-planSkill
- make-reqSkill
- make-scenariosSkill
- mermaidSkill
- plan-arcSkill
- rectifySkill
- review-approachSkill
- update-architectureSkill
- update-reqsSkill
- update-specsSkill
- verify-diagSkill
- verify-proposed-diagSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. About 0 are common, 18 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 32
Consider implementation complete if ANY test fails
- Distinctive: line 37
Create a new worktree from the current branch
- Distinctive: line 38
Use subagents to deeply understand affected systems BEFORE implementing
- Distinctive: line 40
Run the project's test suite after implementation
- Distinctive: line 47
Verify plan exists (file path or pasted content)
- Very specific: line 48
Check for dry-walkthrough verification: Read the first line of the plan file.
- Very specific: line 50
Use AskUserQuestion to prompt: "Do you want to continue without dry-walkthrough validation?"
- Very specific: line 51
If user declines, abort and suggest running /dry-walkthrough first
- Distinctive: line 52
Check git status --porcelain — if dirty, warn user
- Distinctive: line 56
SCOPE FENCE — MANDATORY: Before any exploration or implementation begins, output the following constraint:
- Distinctive: line 58
When launching subagents in Step 2, include this fence instruction explicitly in each subagent prompt so that the subagents do not open, …
- Distinctive: line 71
Before implementing ANY code, launch parallel Explore subagents to understand affected systems:
- Distinctive: line 90
Run per-phase verification if plan specifies it
- Distinctive: line 91
Commit per phase if possible
- Distinctive: line 98
Before running the test suite, confirm the following to prevent avoidable test-fix cycles:
- Distinctive: line 115
Run linting and formatting checks, then run the project's test suite.
- Distinctive: line 117
If tests fail: grep the saved output file (if the project captures output), fix the issue, then re-run.
- Distinctive: line 118
Delete the exact test output file path when finished (no glob patterns).
- Distinctive: line 127
If conflicts occur, resolve them, git rebase --continue, then re-run tests.
- Distinctive: line 133
Always confirm the merge went through before removing work tree.
- Distinctive: line 134
Do not merge until user confirms first!
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Implement in Worktree Skill
Implement a provided plan in an isolated git worktree branched from the current branch.
When to Use
- User says "implement in worktree", "worktree implement", "isolated implementation"
- User provides a plan and wants it executed in a fresh worktree
Arguments
{plan_path} — Absolute path to the implementation plan file (required)
Critical Constraints
NEVER:
- Implement without first exploring affected systems with subagents
- Implement in the main working directory (always use the worktree)
- Force push or perform destructive git operations
- Consider implementation complete if ANY test fails
- Blame test failures on "pre-existing issues" — ALL tests must pass
- Re-run tests just to see failures — grep the saved output file instead
ALWAYS:
- Create a new worktree from the current branch
- Use subagents to deeply understand affected systems BEFORE implementing
- Implement one phase at a time
- Run the project's test suite after implementation
- Rebase onto base branch before completion (ready for squash-and-merge)
Workflow
Step 0: Validate Prerequisites
- Verify plan exists (file path or pasted content)
- Check for dry-walkthrough verification: Read the first line of the plan file. If it does not contain exactly
Dry-walkthrough verified = TRUE:- Display warning: "⚠️ WARNING: This plan has NOT been validated with a dry-walkthrough. Implementation may encounter issues that could have been caught beforehand."
- Use
AskUserQuestionto prompt: "Do you want to continue without dry-walkthrough validation?" - If user declines, abort and suggest running
/dry-walkthroughfirst
- Check
git status --porcelain— if dirty, warn user - Parse plan: phases, files per phase, verification commands
- Multi-Part Plan Detection: Examine the plan filename. If it contains
_part_(e.g.,_part_a,_part_b,_part_1):- Extract the part identifier (A, B, C… or number) from the suffix.
- SCOPE FENCE — MANDATORY: Before any exploration or implementation begins, output the following constraint:
"🚧 SCOPE FENCE ACTIVE: I am implementing PART {X} ONLY. I MUST NOT open, read, or execute any other part files, regardless of what I encounter in temp/ or any other directory. Sibling part files are out of scope for this entire session."
- When launching subagents in Step 2, include this fence instruction explicitly in each subagent prompt so that the subagents do not open, read, or reference sibling part files.
Step 1: Create Git Worktree
WORKTREE_NAME="impl-{plan_name}-$(date +%Y%m%d-%H%M%S)"
WORKTREE_PATH="../worktrees/${WORKTREE_NAME}"
git worktree add -b "${WORKTREE_NAME}" "${WORKTREE_PATH}"
WORKTREE_PATH="$(cd "${WORKTREE_PATH}" && pwd)"Step 2: Deep System Understanding (Subagents)
Before implementing ANY code, launch parallel Explore subagents to understand affected systems:
- Affected files — current implementation, dependencies, consumers
- Test coverage — existing tests, patterns, fixtures for affected code
- Integration points — entry/exit points, contracts that must be maintained
- Data flow — state management, source of truth
Step 3: Set Up Worktree Environment
Set up the project environment in the worktree following the project's standard setup procedure.
Why isolated environment matters: Running setup without proper isolation can overwrite global configuration files. When the worktree is deleted, commands may break with missing module errors.
All commands in Steps 4–6 must run from the worktree directory. Use absolute paths to avoid CWD drift across tool calls.
Step 4: Implement Phase by Phase
For each phase:
- Announce phase objective and files to modify
- Implement changes guided by understanding from Step 2
- Run per-phase verification if plan specifies it
- Commit per phase if possible
- Report phase completion
Where practical, delegate test updates to subagents to keep main conversation context lean.
Step 4.5: Pre-Implementation Checklist
Before running the test suite, confirm the following to prevent avoidable test-fix cycles:
- Architecture documentation — if new modules, sub-packages, or files were added, any architecture sections in project documentation (e.g., CLAUDE.md) reflect them
- Registration checks — if the project maintains a registry of components (e.g., a plugin manifest, a module index, a command registry), verify any newly added components are registered. Missing registrations cause cascading test failures.
- Documentation consistency — if the project maintains architecture documentation or component counts, update them to reflect new components added during implementation.
- Count-based test assertions — if component counts have changed, update any
assert len(...) ==or similar count assertions in the test suite before running tests
This checklist exists because these categories produce avoidable test-fix cycles: a single missed registration generates 5–30 cascading test failures that require a second commit to fix.
Step 5: Final Verification
Run linting and formatting checks, then run the project's test suite.
If tests fail: grep the saved output file (if the project captures output), fix the issue, then re-run. Delete the exact test output file path when finished (no glob patterns).
Step 6: Rebase for Squash-and-Merge
git fetch origin
git rebase origin/{base_branch}If conflicts occur, resolve them, git rebase --continue, then re-run tests. Report rebase status.
Step 7: Completion Report
Output to terminal: worktree path, branch name, base branch, status, summary of changes, and next steps (fast-forward merge then clean up). Change directory before removing worktree to prevent deleting the cwd. Always confirm the merge went through before removing work tree. Do not merge until user confirms first!
Error Handling
- Worktree creation fails — check
git worktree list, suggestgit worktree prune - Phase fails — report which phase and why, offer to fix/retry, skip (if optional), or abort and clean up
- Tests fail — implementation is NOT complete. Fix the issue. If truly unfixable, report to user and ask for guidance. Do NOT proceed or mark as complete.
- Rebase conflicts — resolve keeping implementation intent intact, re-run full test suite after
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

