You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bebbf52
Browse filesBrowse the repository at this point in the historyBrowse files
committed
Hold back worktrees something is using, release 0.10.0
Safe to delete was decided from git alone, so a merged worktree with a
live Claude Code or Claude Desktop session, a shell or a dev server in
it, or one inside a live session's scratchpad, could be removed from
under it.
- New In use verdict: a process whose working folder is inside the
worktree (matched by file identity, so case, symlinks and lsof's
escaped names cannot hide it), or a live Claude Code session owning
the scratchpad. The reason names it and what the verdict would be.
- A check that cannot look holds every worktree back instead of
calling them free; removal checks again after re-reading HEAD and
after keeping a copy, then compares the files and the real index
with that copy once more.
- agentyard remove PATH: the re-checked removal from the command line;
the dashboard's copyable commands use it instead of git worktree
remove.
- An MCP server older than what is installed warns and refuses to
remove until it is reconnected.
- Also: untracked files hidden by status.showUntrackedFiles=no, clean
filters other than LFS, and a git-prunable entry whose folder is
still there no longer pass as safe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.1 Sol (Codex) <noreply@openai.com>
Copy file name to clipboardExpand all lines: README.md
+43-9Lines changed: 43 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,9 +70,26 @@ fetches it, looks up each branch's pull request, and gives every worktree one ve
70
70
|---|---|
71
71
|**Safe to delete**| PR merged (or HEAD already in the default branch), and nothing local is missing from the remote: the worktree is clean, or every uncommitted file and local commit is already in the default branch by content. The only verdict that is safe to delete. |
72
72
|**Prunable**| The folder is gone; only git's registration is left, and every commit it had is on a branch, tag or remote. |
73
+
|**In use**| Otherwise Safe to delete, but a process or live Claude Code session is using it. Wait until that use ends. |
73
74
|**Not merged**| Nothing local is missing from the remote, but it was never merged into the default branch (closed PR, no PR, or its changes live on another branch). Needs a human decision. |
74
75
|**Open PR**| The branch has a PR in review. |
75
-
|**Keep**| Work that no remote has: uncommitted files or local commits whose content is on no remote branch, another checkout inside its ignored folders, a submodule holding work its origin lacks (changes, untracked files, a stash, worktrees of its own, or commits on no branch of its origin), or files git status cannot see (assume-unchanged, skip-worktree). |
76
+
|**Keep**| Work that no remote has: uncommitted files or local commits whose content is on no remote branch, another checkout inside its ignored folders, a submodule holding work its origin lacks (changes, untracked files, a stash, worktrees of its own, or commits on no branch of its origin), or files git status cannot see (assume-unchanged, skip-worktree, or a clean filter other than Git LFS's). |
77
+
78
+
In use is checked on every scan. A process whose working folder is the worktree, or any folder
79
+
inside it, uses that worktree. Folders are compared by what they are on disk, not by how their path
80
+
is spelled, so a symlink, `/tmp` against `/private/tmp`, a different letter case on a
81
+
case-insensitive disk or a name `lsof` prints escaped all still match; a process at the repository
82
+
root does not use the worktrees nested under it. Only agentyard's own work is ignored: agentyard
83
+
itself and the git, `lsof`, `ps` and `du` commands it runs, plus git's file-watching daemon. A shell
84
+
or an agent is a user even when an agentyard started it. Live Claude Code sessions
85
+
(`~/.claude/sessions`, or `-claude-dir`) name the session, and a worktree inside a live session's
86
+
scratchpad is in use even with no process in it; a session file counts as live while its process
87
+
runs, checked against its start time so a reused pid does not count. Worktrees with any other verdict
88
+
keep it and show an in-use chip. When the check itself fails (`lsof` cannot run, the sessions folder
89
+
cannot be read), no worktree is Safe to delete: each is In use, with the reason, until a scan can
90
+
check again. What it cannot see: another user's processes, and a program that works on files in a
91
+
worktree without its working folder being there (an editor opened from elsewhere, say). The verdict
92
+
is what the last scan saw; a removal checks again when it runs.
76
93
77
94
Keep is decided by content, not by commit hash. Commits often reach GitHub another way (rebased,
78
95
squash-merged, ported to another branch) and uncommitted files are often identical to what was pushed
@@ -92,10 +109,10 @@ throwaway object directory, so a scan never writes to the repository.
92
109
93
110
An interactive treemap shows measured disk usage by worktree or repository. Select a tile for its verdict and path, or jump to its row. Search, verdict, and repository filters update the chart, totals, and list together. Choose several values in the Filter menu; remove any selection individually.
94
111
95
-
Totals are grouped by repository and by folder, with ready-to-copy `git worktree remove` commands for
96
-
the safe-to-delete rows. A row with uncommitted files, or a detached HEAD holding commits nothing else
97
-
has, gets no command: a copied command would skip the checks below, so it goes only through the
98
-
dashboard's Remove or `remove_worktrees`. Rows and repositories are sorted by last activity: the newest of the last
112
+
Totals are grouped by repository and by folder, with ready-to-copy `agentyard remove <path>` commands
113
+
for the safe-to-delete rows. The command runs the same re-checked removal as the dashboard's Remove
114
+
and `remove_worktrees` (see below), so one copied an hour ago still refuses a worktree that has come
115
+
into use or gained work since; `agentyard remove -dry-run <path>` only reports. Rows and repositories are sorted by last activity: the newest of the last
99
116
commit, the worktree's index and any uncommitted file. Sizes are `du` logical sizes, refreshed every
100
117
30 minutes; APFS clones and package-manager hardlinks mean the space you actually free can be smaller.
101
118
@@ -437,6 +454,7 @@ to that name. The Sessions tab stays on this Mac unless you also pass `--session
437
454
```console
438
455
$ agentyard status # loaded? pid, root, network, URL, version, last scan, log path
439
456
$ agentyard open # open the dashboard in your browser
457
+
$ agentyard remove PATH # remove a Safe to delete worktree, re-checked first (-dry-run to only report)
440
458
$ agentyard uninstall # stop it and remove the LaunchAgent
441
459
```
442
460
@@ -479,6 +497,12 @@ anything.
479
497
|`remove_worktrees`| Removes the given worktrees if they are still reclaimable; `dry_run` reports what would go. |
480
498
|`sync_worktrees`| Asks the background agent to rescan now, refresh PRs and their local validation, and waits for it, up to a few minutes. |
481
499
500
+
An MCP server keeps running the code it started with, so after `brew upgrade` the AI may be talking
501
+
to an old version. When its executable changed on disk, the `agentyard` on your PATH now leads
502
+
elsewhere, or the background agent reports another version, every tool result carries a `warning`,
503
+
and `remove_worktrees` refuses (dry runs too): older code may lack checks the installed version has.
504
+
Reconnect it (`/mcp` in Claude Code) or start a new session.
505
+
482
506
Start a PR session with `merge_train`, then use `get_pr` to read each candidate. Both tools are
483
507
read-only. They read `/api/prs.json`, falling back to the saved `prs.json` snapshot, and report the
484
508
source and age. `agentyard mcp -demo` includes every merge train lane and synthetic PR details.
@@ -491,7 +515,16 @@ The same rules hold for the dashboard's `POST /api/remove`, which runs the same
commits, PR lookup) with the same verdict logic as the dashboard. A worktree that has gained an
493
517
uncommitted file or a local commit since the last scan is refused.
494
-
-**Only Safe to delete and Prunable.** Keep, Open PR and Not merged are always refused, with the
518
+
-**In use is re-checked just before removal.** The fresh scan checks processes and live sessions
519
+
again, then once more after re-reading HEAD and a last time after any copy is kept. Only then are
520
+
the files looked at for the last time (compared with the copy, the real index included, or
521
+
required to be clean), so a write or a `git add` by a process that started during the check is
522
+
seen. A worktree that came into use meanwhile
523
+
is refused, and a copy already kept for it is dropped. A check that fails refuses too. This narrows
524
+
the window in which someone starts working in a folder being removed; nothing on a Mac can close it.
525
+
A Prunable worktree is pruned only while its folder is still gone: one that is back is refused,
526
+
and one git calls prunable while its folder is still there is Keep.
527
+
-**Only Safe to delete and Prunable.** In use, Keep, Open PR and Not merged are always refused, with the
495
528
reason. A path must exactly match a worktree git lists right now; the main working tree never does.
496
529
A worktree whose ignored folders hold another checkout or worktree anywhere (`.worktrees/`, or deep
497
530
under `node_modules/`) is Keep, because removing it would delete that one too. So is one with a
@@ -506,8 +539,8 @@ The same rules hold for the dashboard's `POST /api/remove`, which runs the same
506
539
origin vouches (a submodule without one has nothing that does), and the removal's fresh scan fetches it first (branches only, after reading the
507
540
local refs), so a branch deleted since, or pushed only to another remote, cannot. The same goes for a gone worktree, whose registration still holds its
508
541
submodule repositories. Their ignored files are listed as the worktree's own. A clean one does not
509
-
keep it: git refuses such a worktree without `--force`, so it gets no copyable command, and the
510
-
checked removal looks once more just before forcing it (the worktree still clean, no file git status
542
+
keep it: git refuses such a worktree without `--force`, so only the checked removal takes it, and it
543
+
looks once more just before forcing it (the worktree still clean, no file git status
511
544
cannot see, its submodules unchanged, no new ignored file, even inside an ignored folder).
512
545
Paths must be given exactly as listed; one with `..`, `//` or a trailing `/` is refused.
513
546
-**What you confirmed is what goes.** A dry run returns a plan for each worktree. Passed back (the
@@ -592,7 +625,7 @@ manager.
592
625
|`-mdns NAME`| off | publish as `http://<name>.local` over mDNS (ignored on loopback) |
593
626
|`-interval D`|`5m`| rescan interval for worktrees, PRs and sessions |
594
627
|`-size-ttl D`|`30m`| how long a measured worktree size is reused |
595
-
|`-claude-dir DIR`|`~/.claude`| Claude Code config folder (holds `projects/`) |
628
+
|`-claude-dir DIR`|`~/.claude`| Claude Code config folder (holds `projects/` and live `sessions/`) |
596
629
|`-codex-dir DIR`|`~/.codex`| Codex home folder (holds `sessions/`) |
597
630
|`-sessions-lan`| off | serve the Sessions tab to other devices too |
598
631
|`-once`|| scan once, print the worktree JSON to stdout and exit |
@@ -602,6 +635,7 @@ manager.
602
635
| Flag | Default ||
603
636
|---|---|---|
604
637
|`-listen ADDR`| the installed agent's, else `127.0.0.1:4777`| where to reach the background agent |
638
+
|`-claude-dir DIR`|`~/.claude`| live Claude Code sessions for removal checks; honors `CLAUDE_CONFIG_DIR`|
605
639
|`-demo`| off | serve the demo's synthetic worktrees; nothing is read or removed |
606
640
607
641
`agentyard demo` takes `-listen` (default `127.0.0.1:4777`; if that port is busy and you did not pass
dry:=fs.Bool("dry-run", false, "re-check and report what would go; change nothing")
329
+
listen:=fs.String("listen", "", "the background agent's address (default: the installed agent's, else "+defaultListen+")")
330
+
claudeDir:=fs.String("claude-dir", "", "Claude Code config folder with live sessions/ (default: the installed agent's, else "+tilde(*flagClaudeDir)+")")
331
+
iferr:=fs.Parse(args); err!=nil {
332
+
iferrors.Is(err, flag.ErrHelp) {
333
+
returnerr
334
+
}
335
+
returnerrUsage
336
+
}
337
+
q:=removeRequest{Paths: fs.Args(), DryRun: *dry}
338
+
iflen(q.Paths) ==0 {
339
+
fs.Usage()
340
+
returnerrUsage
341
+
}
342
+
// Relative to here, but never cleaned: through a symlink, "link/../wt"
343
+
// is not "wt", and removeWorktrees refuses a path that is not canonical.
0 commit comments