Skip to content

fix: a worker in the app's worktree moves to the task's worktree beside the main checkout - #74

Merged
mauricios merged 1 commit into
mainfrom
fix/worker-moves-to-sibling-worktree
Oct 15, 2026
Merged

mauricios merged 1 commit into
mainfrom
fix/worker-moves-to-sibling-worktree

Conversation

@mauricios

Copy link
Copy Markdown
Contributor

Why

In an adopting project, every task worktree ended up nested in main/.claude/worktrees/ under a generated name (silly-cannon-b424ff, …), and none sat beside the main checkout. Two things combined:

  1. The desktop app gives every chip's session a worktree of its own, at its worktree location (inside the project by default), on a claude/<name> branch. The session never opened in the main checkout, as decision 0021 assumed.
  2. The session-context hook kept it there. It told a session in Claude Code's worktree "this worktree is yours for one task… rename the generated branch", following decision 0015. The worker's prompt ("create this task's worktree with adf-worktree-new and move into it") lost to the hook.

Nested in the main checkout, the worktrees also walked up into its tool configuration: ESLint failed on the main checkout's config.

What changed

  • plugins/adf/hooks/session-context.sh, with the parallel-agents module:
    • A session in Claude Code's own worktree on a generated branch or a detached HEAD is told this is where it starts, not where it works. Its first step is adf-worktree-new <branch> --no-start, with the branch its prompt names or the one triage names, then a move to the path it prints (change_directory, which the approve-worktree-move hook approves; EnterWorktree in a terminal).
    • It edits and commits nothing there, and never renames the generated branch.
    • The worker line no longer claims the current worktree: "One task, in its own worktree".
    • A worktree already on a task branch keeps today's notes (what it lacks).
  • /adf:dispatch, docs/PARALLEL-AGENTS.md, the parallel-agents scenario: they no longer tell the developer to start the chip "in this folder, not in a new worktree". The app decides that, and the worker moves either way. A rationalization row covers "the chip already gave me a worktree".
  • Decision 0040 amends 0021 and 0015. The changelog entry carries the upgrade impact. Without the module, nothing changes.

For reviewers

  • Two worktrees per task while the session lives: the app's, which stays empty, and the task's. The app's goes when the session is archived (/wrap-up).
  • The developer could also set the app's worktree location to the main checkout's parent. 0040 records that as an alternative: it's a per-developer setting the framework can't apply, and the app's worktrees still get generated names and no setup.

Verification

  • ./evals/run-evals.sh: all suites pass.
    • Hook tests: a worker in the app's worktree on a generated branch, and on a detached HEAD, gets the create-and-move first step and no git branch -m. A worktree already on a task branch keeps its notes.
    • Static checks: two new ones (/dispatch and the hook), and one updated to the hook's current wording.
  • python3 scripts/build-committed.py --check: the round trip holds, with 65 files.
  • Not verified: a real chip session in the desktop app running the new first step.

🤖 Generated with Claude Code

…task's worktree beside the main checkout

In an adopting project, every task worktree ended up nested in
main/.claude/worktrees/ under a generated name. The desktop app gives every
chip's session a worktree of its own, at its worktree location (inside the
project by default), so the session never opened in the main checkout as
decision 0021 assumed. Then the session-context hook told the worker "this
worktree is yours for one task... rename the generated branch", and workers
did — the prompt's "create this task's worktree and move" lost. Nested in the
main checkout, the worktrees also walked up into its ESLint config.

With the parallel-agents module, a session in Claude Code's own worktree on a
generated branch or a detached HEAD now creates the task's worktree beside the
main checkout (adf-worktree-new <branch> --no-start) and moves there
(change_directory, which the approve-worktree-move hook approves). It edits
and commits nothing in the app's worktree, which goes when the session is
archived, and never renames its branch. A worktree already on a task branch
keeps working as before. /dispatch, PARALLEL-AGENTS.md, and the
parallel-agents scenario no longer tell the developer to start the chip "in
this folder"; the worker moves either way.

Decision 0040 amends 0021 and 0015.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mauricios
mauricios marked this pull request as ready for review October 15, 2026 21:58
@mauricios
mauricios merged commit fed11ea into main Oct 15, 2026
1 check passed
@mauricios
mauricios deleted the fix/worker-moves-to-sibling-worktree branch October 15, 2026 21:58
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