Worktree
Complete development workflow — from TDD-driven implementation plans to execution, debugging, code review, git worktree management, branch lifecycle, and parallel agent dispatch.
npx -y skills add tercel/code-forge --skill worktreeAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 5 stars5 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when starting feature work that needs workspace isolation — creates git worktree with automatic project setup and baseline test verification. Ensures worktree directory is git-ignored and safe. Integrates with code-forge:impl and code-forge:finish.
SKILL.md
4.6 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
Code Forge — Worktree
⚡ Execution Entry Point
@../shared/execution-entrypoint.md
For this skill: start at the first executable step. If you catch yourself about to say "falling back to manual worktree setup", STOP and go to the indicated step.
Create an isolated git worktree for feature development with automated project setup and safety verification.
When to Use
- Starting feature work that should not affect the main workspace
- Before running code-forge:impl to isolate implementation changes
- When you need a clean baseline for testing or experimentation
Iron Law
NEVER create a project-local worktree without verifying it is git-ignored. Worktree contents tracked by git will cause repository corruption.
Workflow
Detect Directory → Verify Safety → Create Worktree → Project Setup → Baseline Tests → Report
Step 1: Detect Worktree Directory
Check in order:
- Existing
.worktrees/orworktrees/directory in project root — use if found - Project CLAUDE.md for worktree preference — use without asking
- Ask user:
- Project-local
.worktrees/(Recommended) — keeps worktrees near the code - Global
~/.config/code-forge/worktrees/— outside project, no .gitignore needed
- Project-local
Step 2: Verify Safety (Project-Local Only)
CRITICAL: If using a project-local directory:
git check-ignore -q <worktree-dir>
- Ignored: Proceed
- NOT ignored: Add to
.gitignoreimmediately, then commit:echo "<worktree-dir>/" >> .gitignore git add .gitignore && git commit -m "chore: add worktree directory to .gitignore"
Global directory: skip this step.
Step 3: Create Worktree
# Detect project name
PROJECT_NAME=$(basename "$(git rev-parse --show-toplevel)")
# Create worktree with new branch
git worktree add <worktree-dir>/<feature-name> -b <feature-name>
Branch naming: use the feature name provided by the user, prefixed with feat/ if not already prefixed.
Step 4: Project Setup
Auto-detect and run setup in the worktree directory:
| Marker | Command |
|---|---|
package.json | npm install |
package-lock.json | npm ci |
yarn.lock | yarn install |
pnpm-lock.yaml | pnpm install |
requirements.txt | pip install -r requirements.txt |
pyproject.toml | pip install -e . or poetry install |
Cargo.toml | cargo fetch |
go.mod | go mod download |
build.gradle | ./gradlew dependencies |
pom.xml | mvn dependency:resolve |
If multiple markers exist, run the most specific one. If none match, skip setup.
Step 5: Baseline Tests
Run the project's test command to establish a clean baseline:
# Auto-detect test command from package.json, Makefile, etc.
# Run tests and report results
- All pass: Report green baseline, proceed
- Some fail: Warn user — "Baseline has N failing tests. These are pre-existing, not caused by your changes."
- No test command found: Skip, inform user
Step 6: Report
Worktree created:
Branch: feat/<feature-name>
Location: <worktree-dir>/<feature-name>
Setup: npm install (completed)
Baseline: 42/42 tests passing
Next steps (code-forge workflow):
/code-forge:impl <feature-name> Execute implementation tasks
/code-forge:finish When done, merge/PR/cleanup
Next steps (ad-hoc development):
/code-forge:tdd Enforce TDD discipline
/code-forge:finish When done, merge/PR/cleanup
Example
$ /code-forge:worktree user-auth
Worktree created:
Branch: feat/user-auth
Location: .worktrees/user-auth
Setup: npm ci (completed)
Baseline: 42/42 tests passing
Next steps:
/code-forge:impl user-auth Execute implementation tasks
/code-forge:finish When done, merge/PR/cleanup
Cleanup
To remove a stale worktree manually: git worktree remove <path>. List all worktrees with git worktree list. The /code-forge:finish skill handles cleanup automatically.
Common Mistakes
- Creating project-local worktree without checking .gitignore
- Skipping baseline tests — pre-existing failures mask new regressions
- Hardcoding setup commands instead of auto-detecting
- Proceeding when baseline tests fail without user acknowledgment
Gives 0 of the 12 instructions most agent orchestration skills give in ~1.1k tokens
Counted across 742 of the 995 authors here whose files we hold, read 2026-08-06
- run the full test suite after integrating changesin 53 of 742, across 20 files
- reference existing artifacts by path or URLin 52 of 742, across 22 files
- dispatch one agent per independent problem domainin 50 of 742, across 17 files
- verify fixes do not conflictin 45 of 742, across 13 files
- include a suggested skills section in the documentin 45 of 742, across 15 files
- redact sensitive informationin 41 of 742, across 11 files
- save to the temporary directory of the operating systemin 39 of 742, across 9 files
- tailor the document to user-provided focus argumentsin 39 of 742, across 9 files
- spot check agent changes for systematic errorsin 34 of 742, across 7 files
- write a handoff document summarising the current conversationin 31 of 742, across 6 files
- assign each agent a specific scopein 23 of 742, across 8 files
- provide specific scope and clear goalin 23 of 742, across 5 files
Said here and by no other author read
- start at the first executable step
- detect the worktree directory in order
- commit the gitignore update immediately
- prefix branch names with feat
- run the most specific setup command detected
- run the project test suite
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.