Agent skill
worktree-finish
Merge a worktree feature branch into main and clean up the worktree. Use after finishing work in a worktree created by /worktree-start.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/worktree-finish
SKILL.md
Worktree Finish
Brings changes from a feature worktree back into main, then removes the worktree and branch.
What it does
- Validates the worktree exists and has no uncommitted changes
- Runs checks in the worktree (auto-detects test/check scripts)
- Merges
work/<feature-name>directly intomain - Removes the worktree directory and deletes the branch
- Cleans up
.worktrees/dir if empty
Usage
/worktree-finish <feature-name>
How to execute
This must be run from the ORIGINAL project directory (not the worktree).
bash .claude/skills/worktree-finish/scripts/worktree-finish.sh "<feature-name>"
Where <feature-name> matches the name used with /worktree-start.
Important
- The worktree must have all changes committed (no dirty working tree)
- Tests/checks are run in the worktree before merging — if they fail, the merge is aborted
- Merges directly into
main(no intermediate review branch) - If there are merge conflicts, the script stops and provides manual resolution steps
- Use
git reset --hard ORIG_HEADto undo the merge if needed - The merge preserves full commit history from the worktree branch
- Unlike
merge-back, no temporary remotes are needed — branch is already local
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?