Repository navigation
feat(gh): use detached review worktrees and prune review refs #2623
Description
Goal
Keep PR-review checkouts detached and separate from ordinary issue branches, with an explicit safe cleanup command for review worktrees and their local refs.
Background
Review tooling currently fetches PR heads into local refs/heads/pr-* branches such as pr-2621 and pr-2621-check2. These are local-only scratch refs, not GitHub branches, but they accumulate in the normal branch inventory and cannot be safely classified by basectl gh branch prune.
The active GitHub branch-name ruleset and basectl gh pr create correctly protect repository implementation branches, but neither can intercept arbitrary local git fetch ...:<ref> operations.
Scope
- Add a Base-owned review checkout workflow that fetches PR heads into a namespaced local ref such as
refs/base-review/pr/<number>/<slug>. - Create detached worktrees under
<repo>-review-worktrees/pr-<number>-<slug>. - Store review metadata outside the worktree under the Git common directory.
- Add
basectl gh review fetchwith safe PR, slug, path, and refresh validation. - Add
basectl gh review prune, dry-run by default, with explicit handling for merged, open, closed-unmerged, dirty, missing, orphaned, and stale review checkouts. - Update command reference, GitHub workflow documentation, help, completions, and focused tests.
Acceptance Criteria
- The review fetch path creates no
refs/heads/pr-*branch. - Created review worktrees are detached and use the documented path convention.
- Review metadata records the repository, PR number, slug, review ref, head SHA, path, and timestamps outside the worktree.
-
basectl gh review pruneis dry-run by default and never removes dirty, open-PR, unowned, or mismatched worktrees without an explicit supported scope. - Applied pruning removes the worktree, namespaced review ref, and metadata as one reported operation.
- Tests cover path traversal, naming, detached state, dirty worktrees, PR states, stale heads, orphaned metadata/refs, and idempotent cleanup.
- Documentation explains that legacy
pr-*branches are a separate one-time cleanup and are not handled automatically by the new pruner.
Non-Goals
- Do not change the canonical issue branch naming convention.
- Do not make the normal branch or worktree pruners delete no-PR branches.
- Do not add a permanent legacy-review feature; existing legacy refs are a one-time cleanup.
Validation
bats cli/bash/commands/basectl/tests/gh-review.bats
shellcheck <changed shell files>
git diff --check
env -u BASE_HOME ./bin/base-testProject Fields
- Status: Backlog
- Priority: P2
- Area: CLI
- Initiative: Agentic Coding Platform
- Size: M
- Milestone: v1.13.0
- Category: enhancement
Agent Assignment
Assignee: codeforester. Use an issue-backed worktree. The legacy pr-* refs are not part of this implementation and should not be auto-deleted by the new command.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(gh): use detached review worktrees (#2624)