Repository navigation
feat(claude): run quest's worktree hooks through the flake's pinned quest - #7674
Conversation
Quest-Claim: 3dfc555d6fffccc4
The hooks leave T3 Code's checkouts alone, but they run with the PATH Claude Code started with, which has no `quest` here, so every isolated subagent and `--worktree` would fail. Record the findings and what the quest waits on, and ignore the main checkout's `.worktrees/`, where quest's checkouts already land. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uest
Claude Code runs hooks with the PATH it started with, not the dev shell,
so a bare `quest worktree hook` fails here. Run the quest moq pins with
`nix run "${CLAUDE_PROJECT_DIR}#quest" -- worktree hook` instead, and
note in AGENTS.md how to keep the hooks across `quest init`, which
refuses a command other than its literal one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the maintainer's nix-or-submodule decision, the measured hook latency, and what still waits on moq-dev/quest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
moq-dev/quest#425 merged, so the bump is ready work, not a wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the PR-head and workflow-agent fixes from moq-dev/quest#425, the worktree hooks start `--worktree '#N'` at the PR head and release workflow agents' checkouts. Refresh the skill stubs with `quest init`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pin bump past moq-dev/quest#425 is done; what remains is quest init recognizing the nix-wrapped hooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Record the maintainer's pick: quest init treats any command hook whose arguments end in `worktree hook` as its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed head d41d0bca660bef5e728b34c5654e4b0a252dfe38 against base fb9a4fbb0012ea02347616ded42e4e83efc53a02. No actionable findings in the hook wiring, pin integration, or accompanying documentation. The pinned Quest source supports all four events and confirms the documented quest init limitation.
Verification: static review through the GitHub connector only. I did not run Nix builds, repository checks, or live Claude/T3 worktree lifecycle tests.
(Written by OpenAI)
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — read the full 8-file diff at d41d0bc and checked the pin and hook wiring against the upstream quest repository.
- Claude worktree hooks —
.claude/settings.jsonrunsnix run "${CLAUDE_PROJECT_DIR}#quest" -- worktree hookforWorktreeCreate,WorktreeRemove,SubagentStartandSubagentStop; the existing direnvSessionStarthook is untouched. - Quest pin —
flake.nixandflake.lockmove quest5e66075→36d0429and itsquest-pinnedinput7a191e6→2aa60a2. The lock revisions andlastModifiedvalues match the upstream commits, the nested lock at36d0429pins the samequest-pinned, and the commits for quest #425, #451 and #445 are all ancestors of the new pin. - Checkout scratch —
.gitignoreadds/.worktrees/, matching where the pinned quest creates checkouts under the main checkout. - Docs and stubs —
AGENTS.mdrecords the nix wrapper and thequest initdrop-and-restore workaround; the quest and m0 README narrow the remaining work to upstreamquest initrecognizing the wrapped command. All 15 skill stubs match the pinned quest exactly, and.agents/skillsis a symlink to them.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Works on
quest/m0/quest-worktree-hooks.md. Claude Code's worktree and subagent hooks now run thequestmoq pins, through nix, and the pin moves past moq-dev/quest#425, so PR worktrees and workflow agents behave under them. The quest is rewritten to what remains: moq-dev/quest teachingquest initto recognize the wrapped hooks.Summary
.claude/settings.json:WorktreeCreate,WorktreeRemove,SubagentStartandSubagentStoprunnix run "${CLAUDE_PROJECT_DIR}#quest" -- worktree hook. That's the flake'spackages.<system>.quest, the moq-dev/quest input inflake.lock. Hooks get thePATHClaude Code started with, not the dev shell, so a barequest worktree hookfails withquest: not foundhere.flake.nix/flake.lock: quest5e66075→36d0429(currentmain). That includes moq-dev/quest#425 (53f78b9), so--worktree '#N'starts at the PR head and workflow agents' checkouts are released. It also includes moq-dev/quest#451 (a subagent's.tmpsurvives release) and moq-dev/quest#445 (worktree submodules). Quest's ownquest-pinnedinput moved with it.quest-merge's description changed.AGENTS.md: one line. The hooks run the pinnedquestthroughnix run, and sincequest initrefuses them, a pin bump drops them for its run and restores.claude/settings.jsonafterwards..gitignore:/.worktrees/, where quest's checkouts land under the main checkout. Each carries its ownbiome.jsonc, the same reason/.claude/worktrees/is ignored.quest initrecognizing the wrapped hooks. Its## Waitingitem is on moq-dev/quest, so the quest stays open after this PR.origin/main.Decisions
Settled by the maintainer on 2026-11-03:
quest: ✅ nix (or a submodule) long-term, so the hooks run moq's pin; a host-widequestonPATHonly as a temporary bridge.questinstalled onPATH;direnv exec; adopting the barequest worktree hooknow; dropping the quest.quest initand wrapped hooks: ✅ ask moq-dev/quest to havequest inittreat any command hook whose arguments end inworktree hookas its own. Another agent is planning that in moq-dev/quest. Until it lands, the drop-and-restore step stays in AGENTS.md.Which nix shape
Measured from Claude's hook environment (its
PATH, no dev shell), printingquest --version. "Cold" uses a freshXDG_CACHE_HOME, so the eval and fetcher caches are empty. Times are noisy under host load.nix run "$CLAUDE_PROJECT_DIR#quest" -- …✅nix; resolves from a subdirectory toonix run --inputs-from "$CLAUDE_PROJECT_DIR" quest -- …nix develop "$CLAUDE_PROJECT_DIR" --command quest …direnv exec "$CLAUDE_PROJECT_DIR" quest …After a pin bump, the first call builds the new quest in about 6 s here. A submodule would need bun and
node_modulesin each checkout to run the CLI, so nix is simpler. The hook runs the checkout's own pinned quest, so a PR head chooses the code its hooks run. That's the same trust the existing direnvSessionStarthook already gives the checkout's flake.quest initand pin bumpsquest initrecognizes its hook only by the exact stringquest worktree hook(isQuestHookin moq-dev/quest'ssrc/core/init.ts, still the case at36d0429).quest initexits 1 (already has a WorktreeCreate hook, and only one can manage Claude's worktrees) and writes nothing.SubagentStart/SubagentStopit would add a second, barequest worktree hook.quest init(it then changes only.claude/settings.jsonand stale stubs), and restore.claude/settings.json.Live T3 check (on the new pin, Claude Code 2.1.316)
All of this ran against the real quest registry, which was empty before and after.
isolation: "worktree"subagent from this T3 worktree thread~/work/moq/.worktrees/agent-ac5c51df91121bd23atorigin/HEAD(fb9a4fbb00)releasedonSubagentStopquest worktree removedelegate_taskwithisolation: "worktree"fromf26e953~/worktrees/moq/t3-bd4a8297(t3/bd4a8297, 4 nix hooks, pin36d0429); never registered with quest, left cleangit worktree remove, branch deleted~/work/moq/.worktrees/agent-a789581853623b2a8atorigin/HEADreleasedquest worktree removeclaude --worktree '#7674' -p …~/work/moq/.worktrees/pr-7674atf26e953f66, exactly the PR's head then, fetched intoorigin/pr/7674active(as upstream documents)quest worktree removeAn interrupted probe also showed the crash case: its checkout was created and stayed
active, since noSubagentStopfired, andquest worktree removerecovered it. T3's own worktree create and remove are plain git operations that never reach Claude'sWorktreeCreate/WorktreeRemove, and the subagent hooks act only on a registeredagent-<agent_id>checkout, so T3 checkouts are left alone. I didn't exerciset3_worktree_handoff: it refuses a thread that already has a worktree, and it's a T3 git operation the hooks don't take part in. Workflow agents (wf_…) weren't run live here; moq-dev/quest#425 verified them upstream.Choices made without asking
nix run "${CLAUDE_PROJECT_DIR}#quest"over--inputs-from,nix developand a submodule, for the reasons above.main(36d0429) rather than exactly53f78b9, as pin bumps usually do. It also brings the.tmp-preserving release from moq-dev/quest#451.~/work/moq/.worktrees/, then removed everything it made. No settings outside the repository changed.Review
gpt-6.1-sol, medium effort, viaquest review --base origin/main(session01a1a286).ae281b59f7743aa41f3a33b66f3d064495802954: 1 finding..claude/settings.json:19: update the quest pin past fix(worktree): check out PR heads and release workflow agents' checkouts quest#425 before enablingWorktreeCreate. Fixed by the pin bump to36d0429(decision 2), verified live with--worktree '#7674'.d41d0bca660bef5e728b34c5654e4b0a252dfe38: no findings.Checks
quest check --base origin/mainwith the new pin: 583 documents ok.quest gate just check origin/mainond41d0bc: passes. The flake module was skipped because this host's Nix builder can't create user namespaces; CI runs it.nix run .#questbuilt and ran the new pin.Suggested follow-ups
agent-*worktrees under~/work/moq/.claude/worktrees. There are 419 from before these hooks. That's host state, not repository work, but a one-off removal of the clean ones would reclaim the disk.🤖 Generated with Claude Code
(Written by Claude Opus 5.5)