Problem
When a nous run is killed mid-iteration (e.g., via pkill after a nous stop that didn't fire fast enough), the experiment worktree at <target_repo>/.nous-experiments/iter-N-<id>/ and its associated branch nous-exp-iter-N-<id> are left behind. nous didn't clean them up because it didn't get to run its own teardown.
The user must manually run:
git -C <target_repo> worktree remove --force .nous-experiments/<id>
git -C <target_repo> branch -D nous-exp-<id>
Across many iterations / multiple killed runs, these orphans accumulate.
Desired behavior
A new command:
nous clean --orphaned [--target-repo <path>]
That:
- Detects worktrees under
<target_repo>/.nous-experiments/ matching the iter-* pattern.
- For each: looks up the corresponding nous run state (e.g., is the run_id still active in
~/.nous/state/?).
- If the run is dead/aborted/completed and the worktree is not actively in use, removes it (with
--force) and deletes the matching branch.
- Prints a summary of what was removed.
Variants:
nous clean --campaign <run_id> # remove worktrees specific to one campaign
nous clean --dry-run # show what would be removed without doing it
Could also be invoked automatically at the start of nous run for the same run_id, removing any orphans from prior aborted runs of that same campaign.
Suggested implementation sketch
- Add a
clean subcommand to orchestrator/cli.py.
- Walk
<target_repo>/.nous-experiments/, list git worktree list --porcelain, intersect with branches matching nous-exp-*.
- For each candidate, check whether the originating run is dead (state file missing or marked completed/aborted).
- Remove via
git worktree remove --force <path> and git branch -D <branch>.
- Add
--dry-run, --campaign <id>, and --target-repo <path> flags.
- Document in
nous --help output.
Acceptance criteria
Severity
LOW — workaround is two git commands, but accumulates over time.
Source
friction-report.md F9, paper-memorytime-mirage campaign (2026-05).
Part of friction-report tracking issue #245.
Problem
When a nous run is killed mid-iteration (e.g., via
pkillafter anous stopthat didn't fire fast enough), the experiment worktree at<target_repo>/.nous-experiments/iter-N-<id>/and its associated branchnous-exp-iter-N-<id>are left behind. nous didn't clean them up because it didn't get to run its own teardown.The user must manually run:
Across many iterations / multiple killed runs, these orphans accumulate.
Desired behavior
A new command:
That:
<target_repo>/.nous-experiments/matching theiter-*pattern.~/.nous/state/?).--force) and deletes the matching branch.Variants:
Could also be invoked automatically at the start of
nous runfor the samerun_id, removing any orphans from prior aborted runs of that same campaign.Suggested implementation sketch
cleansubcommand toorchestrator/cli.py.<target_repo>/.nous-experiments/, listgit worktree list --porcelain, intersect with branches matchingnous-exp-*.git worktree remove --force <path>andgit branch -D <branch>.--dry-run,--campaign <id>, and--target-repo <path>flags.nous --helpoutput.Acceptance criteria
nous clean --orphanedremoves worktrees and branches for completed/aborted runs.--dry-runprints what would be removed without acting.--campaign <id>scopes cleanup to a single campaign.Severity
LOW — workaround is two git commands, but accumulates over time.
Source
friction-report.mdF9, paper-memorytime-mirage campaign (2026-05).Part of friction-report tracking issue #245.