Skip to content

feat(gh): surface and automate worktree hygiene #2575

Open

Description

@codeforester

Goal

Keep issue worktrees from accumulating by making hygiene visible and part of normal flow.

Background

basectl gh worktree prune and gh branch prune already exist and default to dry-run. On 2026-10-15, a dry run in the maintainer's checkout reported 116 of 121 worktrees removable (merged PRs), 1 closed-unmerged retained, 0 dirty. The capability exists; nothing invokes it, so the count only grows, and an agent loop will create worktrees faster than a human does.

Next-release planning review of 2026-10-14/15 against main at 7faf6dfb. Tracking: #2555.

Scope

  • Emit a doctor or status finding with stale-worktree count and oldest age.
  • Add a cleanup step to the post-merge workflow documentation and to the loop's cleanup phase (see the loop contract).
  • Do not add new prune logic.

Acceptance Criteria

  • basectl doctor (or workspace status) reports the count and age.
  • Documentation names when to run prune.
  • Existing prune semantics are unchanged.

Validation

bats cli/bash/commands/basectl/tests/gh.bats
shellcheck <changed shell files>
env -u BASE_HOME ./bin/base-test
git diff --check

Non-Goals

  • Do not change prune safety rules.
  • Do not auto-delete without --yes.

Project Fields

  • Status: Ready
  • Priority: P3
  • Area: CLI
  • Initiative: Agentic Coding Platform
  • Size: S
  • Milestone: v1.13.0
  • Category: enhancement

Agent Assignment

Assignee: codeforester. Implementation-ready; use an issue-backed worktree.

Plan revision (2026-10-16)

This issue is intentionally scheduled for v1.13.0 so the loop's cleanup phase can consume the contract from #2576. Add #2576 as a prerequisite and cover interruption/abandon paths from #2602. The implementation must continue to use the existing safe, explicit prune semantics; visibility and handoff are the goal, not unattended deletion.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Projects

  • Status
    Ready

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions