Skip to content

afx cleanup reports success but leaves the worktree registered and on disk when it holds untracked files #1721

Open

Description

@waleedkadous

Observed (2026-09-22, cluesmith/codev, after PR #1710 merged)

afx cleanup -p 1709 printed:

[info] To delete: git branch -d "builder/air-1709"
[ok] Builder builder-air-1709 cleaned up!

but afterwards:

  • git worktree list still shows .builders/air-1709 (912 MB on disk, branch builder/air-1709 still checked out there)
  • git branch -d builder/air-1709 refuses: "used by worktree"
  • a second afx cleanup -p 1709 says Builder not found for project: 1709 — the roster row is gone, so the CLI can no longer reach the worktree it failed to remove

A manual git worktree remove .builders/air-1709 (non-force) fails with "contains modified or untracked files, use --force". The untracked files are only the spawn scaffolding (.builder-prompt.txt, .builder-role.md, .builder-session-id, .builder-start.sh, .claude/hooks/); tracked state was clean and every commit was on origin.

Expected

Either the worktree is actually removed (cleanup owns the scaffolding it wrote, so removing it, or using --force for a worktree whose branch is fully merged and pushed, is correct), or cleanup reports the failure and keeps the roster row so it can be retried — not "cleaned up!" with the worktree intact and the handle deleted.

Notes

Activity

  1. added
    area/tower
    on Sep 22, 2026
  2. waleedkadous commented on Sep 22, 2026

    @waleedkadous
    ContributorAuthor

    Reproduced 2026-09-22 with afx cleanup -p 1724 after PR #1725 merged: "[ok] Builder builder-air-1724 cleaned up!" but the worktree is still registered and on disk, roster row gone. Same profile as the first case: tracked tree clean, every commit on origin, only spawn scaffolding untracked (.builder-*, .claude/hooks/) plus the builder's node_modules. Two for two on AIR lanes that ran pnpm install in the worktree.

  3. waleedkadous commented on Nov 11, 2026

    @waleedkadous
    ContributorAuthor

    Field evidence from a multi-architect adopter workspace (7 architects, ~10 builders, one machine, codev 3.3.7), sent at the owner's request on 2026-11-11.

    The untracked files behind this are harness scaffolding: .builder-session-id and .claude/hooks/worktree-write-guard.cjs (also .builder-prompt.txt, .builder-role.md, .builder-start.sh) show up in git status of every builder worktree, so every cleanup needs a manual 'only those' check and afx cleanup warns about uncommitted files. Suggested fix, tried by hand there and working across worktrees: at spawn, add them to the shared .git/info/exclude. Confirmed independently in this repo on 2026-11-01, when six merged worktrees each showed five to seven such files and nothing else. This is a few-line change in spawn and would make this issue and #1363 largely moot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions