Back to list
builtby-win

cleanup

by builtby-win

GitHub workflow automation skills for Claude Code - issue management, branching, PRs, and team coordination

0🍴 0📅 Jan 8, 2026

SKILL.md


name: cleanup description: Clean up after a PR is merged - delete branches and confirm issue closure

Done - Post-Merge Cleanup

Clean up local and remote branches after a PR is merged.

When to Use

  • After a PR is merged
  • Claude should run this AUTOMATICALLY when detecting a merged PR
  • Can also be invoked manually with /done

Workflow

Step 1: Detect Current Branch

git branch --show-current

If on an issue branch (pattern: {PROJECT_PREFIX}/issue-{N}-*), proceed with cleanup.

Note: PROJECT_PREFIX should be configured in your project's CLAUDE.md. Examples: myproject, builtby-win-web, etc.

Step 2: Check PR Status

gh pr view --json state,mergedAt

Verify the PR was merged. If not merged, warn user.

Step 3: Delete Worktree (If Present)

Check if a worktree exists for this issue and delete it:

# Extract issue number from branch name
ISSUE_NUM=$(git branch --show-current | grep -oP 'issue-\K[0-9]+')

# Try to delete worktree using the global CLI
# This will fail gracefully if no worktree exists
npx @builtby.win/worktree delete ${ISSUE_NUM} 2>/dev/null && WORKTREE_DELETED=1

Alternatively with globally installed CLI:

worktree delete ${ISSUE_NUM} 2>/dev/null && WORKTREE_DELETED=1

If worktree was deleted, it will:

  • Stop the dev server if running
  • Remove .worktrees/issue-{N}-{slug}/ directory
  • Free up the assigned port
  • Update .worktree-metadata.json

Step 4: Switch to Main

git checkout main
git pull origin main

Step 5: Delete Local Branch

git branch -d {PROJECT_PREFIX}/issue-{N}-{slug}

Use -D (force) if needed, but prefer -d to catch unmerged commits.

Step 6: Delete Remote Branch

git push origin --delete {PROJECT_PREFIX}/issue-{N}-{slug}

Step 7: Verify Issue Closed

gh issue view {N} --json state

The issue should be closed automatically by the Closes #N in the PR body.

Step 8: Announce

Output:

PR #{PR_NUM} merged!

Cleanup complete:
- Switched to main
- Deleted local branch: {PROJECT_PREFIX}/issue-{N}-{slug}
- Deleted remote branch
- Issue #{N} is now closed

Ready for next task. Run /work to see what's available.

If worktree was deleted, also include:

- Deleted worktree: .worktrees/issue-{N}-{slug}
  - Stopped dev server (port {PORT} now available)
  - Removed {N} database snapshot(s)

Auto-Detection

Claude should detect when a PR is merged by:

  1. User mentions PR was merged
  2. Checking PR state: gh pr view --json state
  3. Detecting we're on a stale issue branch

When detected, automatically run cleanup.

Edge Cases

  • PR not merged yet: "PR #{PR_NUM} is still open. Merge it first, then run /done"
  • Already on main: "Already on main. No cleanup needed."
  • Branch already deleted: "Branch already cleaned up."

Configuration

In your project's CLAUDE.md, set:

## GitHub Workflow Configuration
PROJECT_PREFIX=your-project-name

Example configurations:

  • PROJECT_PREFIX=areyougo.ing (for areyougo.ing project)
  • PROJECT_PREFIX=builtby-win-web (for builtby.win/web)
  • PROJECT_PREFIX=myapp (for any custom project)

Score

Total Score

70/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon