/workflow-finish:workflow-finishfrom workflow-finish
Cleanup branch after PR is merged. Use when user says /workflow finish or /workflow-finish.
Ships in workflow-finish. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Cleanup git branches and worktrees after a PR is merged. Removes local branch, remote branch, worktree, and workflow context files.
/workflow-finish configure (or /workflow configure - shared config)/workflow-finish (uses saved config for worktree paths).claude/workflow-config.json (shared with workflow-setup)| Command | Purpose | When to Use |
|---|---|---|
/workflow-finish configure | Configure worktree preferences | Framework setup / wizard |
/workflow-finish | Cleanup after PR merged | After PR is merged |
/workflow-finish <branch> | Cleanup specific branch | Cleaning up specific branch |
/workflow-finish <ticket-id> | Find and cleanup by ticket | Using ticket ID |
When: Framework setup wizard (one-time, shared with workflow-setup)
What it does:
.claude/workflow-config.json1. CHECK EXISTING CONFIG
└─ If .claude/workflow-config.json exists, validate and confirm
2. DETECT PROJECT NAME
├─ package.json → name
├─ pyproject.toml → [project].name
├─ go.mod → module name
└─ Fallback: directory name
3. SUGGEST WORKTREE PATH
└─ Default: ../worktrees/<project-name>
4. PROPOSE TO USER
└─ Show config, wait for approval
Skill config path depends on how the plugin was installed:
| Plugin Scope | Config File | Git |
|---|---|---|
| project | .claude/skills/workflow-finish.yaml | Committed (shared) |
| local | .claude/skills/workflow-finish.local.yaml | Ignored (personal) |
| user | .claude/skills/workflow-finish.local.yaml | Ignored (personal) |
Precedence when reading (first found wins):
.claude/skills/workflow-finish.local.yaml.claude/skills/workflow-finish.yamlNote: Runtime config is stored in .claude/workflow-config.json (shared with workflow-setup).
{
"worktreeBasePath": "../worktrees/my-project",
"ide": "Cursor",
"copyEnvFiles": true
}
Requires: .claude/workflow-config.json exists (run configure first)
/workflow-finish # Current branch
/workflow-finish feat/proj-123-some-feature # Specify branch name
/workflow-finish PROJ-123 # Specify ticket ID
1. LOAD CONFIG
└─ Read worktreeBasePath from .claude/workflow-config.json
2. RESOLVE TARGET BRANCH
├─ No argument → current branch
├─ Ticket ID → search for matching branch
└─ Branch name → use directly
3. VERIFY PR MERGED
└─ gh pr list --head <branch> --state all
4. SWITCH TO MAIN (if on target branch)
└─ git checkout main && git pull
5. CALCULATE WORKTREE PATH
└─ <basePath>/<branch-without-type-prefix>
6. CLEANUP
├─ Remove worktree
├─ Delete remote branch
├─ Delete local branch
└─ Remove workflow context
7. REPORT
└─ Show summary table
Read .claude/workflow-config.json to get worktreeBasePath.
If config doesn't exist:
Error: Configuration not found.
Run `/workflow-finish configure` or `/workflow configure` to configure.
| Input | Resolution |
|---|---|
| No argument | Use current branch (git branch --show-current) |
Ticket ID (XXX-###) | Find branch containing that ticket ID |
| Branch name | Use directly |
Finding branch from ticket ID:
# Search worktrees
git worktree list | grep -i "<ticket-id>"
# Search local branches
git branch --list "*<ticket-id-lowercase>*"
gh pr list --head <branch-name> --state all --json number,state,mergedAt
| State | Action |
|---|---|
MERGED | Proceed to cleanup |
OPEN | Warn: "PR not merged. Force finish anyway?" |
CLOSED | Warn: "PR closed without merge. Force finish anyway?" |
| Not found | Warn: "No PR found. Force finish anyway?" |
worktreeBasePath = ../worktrees/my-project (from config)
branch = feat/proj-123-add-feature
worktreePath = ../worktrees/my-project/proj-123-add-feature
# Remove worktree if exists
git worktree remove <worktree-path> --force 2>/dev/null || true
# Delete remote branch
git push origin --delete <branch-name> 2>/dev/null || echo "Remote branch already deleted"
# Delete local branch
git branch -D <branch-name> 2>/dev/null || echo "Local branch already deleted"
# Prune worktree refs
git worktree prune
# Remove workflow context directory
rm -rf .claude/workflow/<branch-name>/ 2>/dev/null || true
Workflow finished for `<branch-name>`
| Item | Status |
|------|--------|
| PR #<number> | ✓ Merged |
| Worktree | ✓ Removed |
| Remote branch | ✓ Deleted |
| Local branch | ✓ Deleted |
| Workflow context | ✓ Cleaned |
See skill.yaml for patterns.
See sharp-edges.yaml for common pitfalls.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dohernandez/claude-skills --plugin workflow-finish