Skip to content

Instantly share code, notes, and snippets.

@mikehostetler
Created March 24, 2026 19:40
Show Gist options
  • Select an option

  • Save mikehostetler/940e5363283390bfa223e5ad153a8220 to your computer and use it in GitHub Desktop.

Select an option

Save mikehostetler/940e5363283390bfa223e5ad153a8220 to your computer and use it in GitHub Desktop.
Codex Worktree Cleanup Hack
  • Prefer gh pr checkout <number> --detach for review-only work so disposable local branches do not accumulate.
  • If a separate worktree is useful, give it an obviously temporary name and remove it with git worktree remove <path> when the review is done.
  • After temp worktrees are removed or deleted out-of-band, run git worktree prune -v to clear stale metadata.
  • Before starting substantial new work, prefer returning the root repo to a clean, current baseline with git status --short --branch, git fetch --prune origin, git checkout main, and git pull --ff-only origin main when that fits the repo workflow.
  • Ask before deleting unmerged branches.
  • Clean up disposable review branches like pr-<number> and *-review once they are merged or no longer needed.
developer_instructions = """
Prefer detached PR checkouts for review-only work.
Ask before deleting unmerged branches.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment