Skip to content

docs: document interrupted-worktree recovery and gitignore dirty-detection#40

Open
baruch wants to merge 1 commit into
kunchenguid:mainfrom
baruch:docs/worktree-recovery
Open

docs: document interrupted-worktree recovery and gitignore dirty-detection#40
baruch wants to merge 1 commit into
kunchenguid:mainfrom
baruch:docs/worktree-recovery

Conversation

@baruch

@baruch baruch commented Jun 26, 2026

Copy link
Copy Markdown

What

Adds user- and agent-facing docs for two behaviors that were previously only
derivable by reading the code.

1. Recovering an interrupted worktree (README)

1. Recovering an interrupted worktree (README)

New "Recovering an interrupted worktree" section covering what happens when
a treehouse get subshell ends abnormally — closed terminal, crash, or OOM:

  • The normal return cleanup is skipped, the stale owner reservation is
    self-healed on the next command, and uncommitted work (tracked or
    untracked) stays protected
    from get reuse, prune, and destroy.
  • How to recover: treehouse status to find the dirty worktree by path,
    cd in to resume, treehouse return <path> when done.
  • A caveat flagging the two clean-tree cases that are not protected on a
    non-leased worktree — committed work (reclaimed by git reset --hard,
    recoverable via git reflog) and .gitignored-only changes — and pointing
    to treehouse get --lease for durable holds across crashes.

2. .gitignored files vs. dirty detection (README + AGENTS.md)

Clarifies a previously-undocumented edge case: ignored files are not counted
as dirty (so a worktree whose only leftover content is ignored can be reused),
but treehouse's reset never deletes them either — ResetWorktree runs
git clean -fd (without -x), which respects .gitignore.

Why

The dirty-detection note previously said only "untracked files count as dirty."
The crash-recovery flow and the ignored-files nuance are accurate in the code
(IsDirty, ResetWorktree, healState, Acquire) but were undocumented —
exactly the behavior a user relies on when an agent session dies.

Scope

Documentation only — no code changes. Touches README.md and AGENTS.md
(the design-decisions note; CLAUDE.md symlinks to it). 2 files, +26/−2.

…ction

Add a "Recovering an interrupted worktree" section to the README covering
what happens when a `get` subshell ends abnormally (crash, OOM, closed
terminal): the stale owner reservation is self-healed, uncommitted work
stays protected, and you recover it via `treehouse status` + `cd`. Flag the
two clean-tree cases that are NOT protected -- committed work and
gitignored-only changes -- and point to `get --lease` for durable holds.

Also clarify, in both the README "Dirty detection" highlight and the
AGENTS.md design note, that .gitignore'd files are not counted dirty (so
such a worktree can be reused) but are not deleted by the reset, since
`git clean -fd` runs without `-x` and respects `.gitignore`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant