From spellbook-skills
Use when implementation is complete and you need to merge a worktree branch back into the original base branch with build/compile verification (no tests)
How this skill is triggered — by the user, by Claude, or both
Slash command
/spellbook-skills:finishing-a-development-branch-liteThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Finish development work by verifying a build/compile check, presenting merge options, and cleaning up the worktree.
Finish development work by verifying a build/compile check, presenting merge options, and cleaning up the worktree.
Core principle: Build/compile first → confirm base branch → present options → execute → cleanup.
Announce at start: "I'm using the finishing-a-development-branch-lite skill to complete this work."
AGENTS.md for build/compile commands. If present, follow it.# Node.js (requires build script)
if [ -f package.json ]; then npm run -s build; fi
# Rust
if [ -f Cargo.toml ]; then cargo build; fi
# Go
if [ -f go.mod ]; then go build ./...; fi
# Python
if [ -f pyproject.toml ] || [ -f requirements.txt ]; then python -m compileall .; fi
# Java (Maven)
if [ -f pom.xml ]; then mvn -q clean compile; fi
If no build command is available (e.g., no npm build script), ask the user for the correct command.
If build fails:
Build/compile failing (<N> failures). Must fix before completing.
[Show failures]
Stop. Do not proceed to Step 2.
Prefer extracting the base branch from the worktree branch name using the delimiter:
__wt__
Example:
feature/auth__wt__login -> base branch: feature/auth
If extracted, verify the local branch exists:
git show-ref --verify refs/heads/<base-branch>
If it exists, confirm with the user before merging. If it does not exist, ask the user to provide the base branch.
Present exactly these 4 options:
Implementation complete. What would you like to do?
1. Merge back to <base-branch> locally
2. Push and create a Pull Request
3. Keep the branch as-is (I'll handle it later)
4. Discard this work
Which option?
Important: Run the merge from the base-branch worktree (the directory where the base branch is checked out), not from the worktree branch directory.
# Switch to base branch
git checkout <base-branch>
# Pull latest (if appropriate)
git pull
# Merge feature branch
git merge <feature-branch>
# Verify build/compile on merged result
<build command>
# If build passes
git branch -d <feature-branch>
Then: Cleanup worktree (Step 5)
# Push branch
git push -u origin <feature-branch>
# Create PR
gh pr create --title "<title>" --body "<summary and build steps>"
Then: Cleanup worktree (Step 5)
Report: "Keeping branch . Worktree preserved at ."
Do not cleanup worktree.
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
git checkout <base-branch>
git branch -D <feature-branch>
Then: Cleanup worktree (Step 5)
For Options 1, 2, 4:
Before removing a worktree, change into a directory that will remain (e.g., the base-branch worktree). Removing the current directory will break the session.
git worktree list | grep $(git branch --show-current)
If yes:
git worktree remove <worktree-path>
For Option 3: Keep worktree.
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
Assuming main/master as base branch
Skipping build verification
Discarding without confirmation
Skipping base-branch confirmation because "it should be obvious"
| Excuse | Reality |
|---|---|
| "I'll merge this into main, it's fine" | Merge into the original base branch unless user says otherwise |
| "Build is optional" | Build/compile is the gate for completion |
| "Discard is reversible" | Discard is permanent and requires confirmation |
# Build/compile
mvn -q clean compile
# Merge to base branch
base_branch=feature/auth
feature_branch=feature/auth-impl
git checkout "$base_branch"
git pull
git merge "$feature_branch"
# Verify build/compile again
mvn -q clean compile
npx claudepluginhub yyykf/spellbook-skills --plugin spellbook-skillsGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.