Repository navigation
Closed
Labels
area:workflowDeveloper workflow, commands, rules, skillseffort:smallLess than 1 hourfeatureNew feature or requestsemver:minorNew feature, backward-compatible
Description
Description
just worktree-clean (alias wt-clean) currently removes all worktrees unconditionally — including those with running tmux sessions where an agent may still be actively working. This is destructive and error-prone when you only want to clean up finished or broken worktrees.
Problem Statement
When running multiple parallel worktrees, some may have completed (tmux session stopped) while others are still running. Currently there is no way to selectively clean up only the finished ones — wt-clean kills everything, forcing you to manually wt-stop individual issues or risk losing in-progress agent work.
Proposed Solution
Add a mode parameter to worktree-clean with these options:
just worktree-clean(default, no argument) — clean only stopped worktrees (no running tmux session). Safe default.just worktree-clean all— clean all worktrees (current behavior), with a confirmation prompt or clear warning.
Implementation in justfile.worktree:
- The recipe already iterates over worktree dirs and checks
tmux has-session. Add a filter: whenmodeis empty/stopped, skip dirs where the tmux session is still running. - When
modeisall, retain current behavior (kill everything). - Print a summary of what was skipped vs cleaned.
Alternatives Considered
- Separate recipes (
worktree-clean-stopped,worktree-clean-all) — more discoverable but clutters the recipe list. - Interactive confirmation per worktree — too slow for many worktrees, breaks autonomous usage.
- Dry-run flag — useful addition but doesn't solve the core need of selective cleaning.
Impact
- All users of
just wt-cleanbenefit from a safer default. - Backward-incompatible change: the default behavior changes from "clean all" to "clean stopped only". Users who relied on the old default must pass
allexplicitly. - This is the safer direction — preventing accidental destruction of active work.
Changelog Category
Changed
Acceptance Criteria
-
just worktree-clean(no args) removes only stopped worktrees, skips running ones with a message -
just worktree-clean allremoves all worktrees (current behavior) - Summary output shows what was cleaned and what was skipped
-
just wt-cleanalias continues to work - TDD compliance (see
.cursor/rules/tdd.mdc)
Metadata
Metadata
Assignees
Labels
area:workflowDeveloper workflow, commands, rules, skillseffort:smallLess than 1 hourfeatureNew feature or requestsemver:minorNew feature, backward-compatible
Activity
gerchowl commentedon Feb 23, 2026
Design
Issue: #158 — worktree-clean filter mode for stopped-only vs all
Summary
Add a
modeparameter toworktree-cleanso the default cleans only stopped worktrees (no running tmux session), whilejust worktree-clean allretains current behavior (clean everything). Print a summary of cleaned vs skipped worktrees.Architecture
Recipe signature:
worktree-clean mode="":just worktree-clean(no args) →mode=""→ stopped-only (safe default)just worktree-clean all→mode="all"→ clean all (current behavior)Logic in
justfile.worktree:Stopped-only mode (
modeempty orstopped):$WT_BASE/*/:tmux has-session -t wt-${issue}→ skip, add to skipped list, continueAll mode (
mode="all"):Summary output format:
Error Handling
Testing Strategy
tests/bats/worktree.bats:just wt-cleanandjust wt-clean allworkFiles to Modify
justfile.worktree— worktree-clean recipetests/bats/worktree.bats— new tests for worktree-clean modesgerchowl commentedon Feb 23, 2026
Implementation Plan
Issue: #158
Branch: feature/158-worktree-clean-filter-mode
Tasks
Task 1: Add BATS test for worktree-clean stopped-only mode (skips running sessions) —
tests/bats/worktree.bats— verify:bats tests/bats/worktree.bats -f "worktree-clean"Task 2: Implement worktree-clean mode parameter (stopped-only default, all option) —
justfile.worktree— verify:just worktree-clean --helpshows usageTask 3: Add BATS test for worktree-clean all mode —
tests/bats/worktree.bats— verify:bats tests/bats/worktree.bats -f "worktree-clean"Task 4: Add summary output (cleaned vs skipped) and wt-clean alias verification —
justfile.worktree— verify:just testtest(worktree): add BATS test for worktree-clean stopped-only mode
feat(worktree): add mode filter to worktree-clean (stopped-only vs all)
gerchowl commentedon Feb 23, 2026
CI Diagnosis
Failing workflow: CI / Build Container Image / Build container image
Error: buildx failed — gh CLI install step exited with code 22 (curl HTTP error)
Root cause: The Containerfile step that downloads/installs gh from GitHub releases is failing. This is unrelated to PR #160 changes (justfile.worktree, tests, CHANGELOG only). Likely upstream: gh release checksum mismatch, rate limit, or transient network.
Planned fix: None — our changes do not touch the Containerfile or gh install. Recommend retrying the workflow or investigating gh release availability.
gerchowl commentedon Feb 23, 2026
Question
Context: Autonomous solve-and-pr pipeline completed. PR #160 created. CI Build Container Image failed.
Blocker: Build fails when installing gh CLI in Containerfile (exit 22). Our PR only changed justfile.worktree, tests/bats/worktree.bats, CHANGELOG — no Containerfile changes.
Options:
Please reply if you want a specific action.
gerchowl commentedon Feb 23, 2026
Autonomous Run Complete
feat(worktree): add filter mode for worktree-clean (#158) PR (#160)
chore: release 0.3.0 (#270)
fix(smoke-test): seed Unreleased entry so prepare-release can run (#598)