[#966] Reseed worktree CLAUDE.md alongside AGENTS.md#993
Conversation
Auto-reseed refreshed worktree AGENTS.md on template upgrade but never CLAUDE.md, so the two instruction files drifted. _performReseedWrites now also refreshes CLAUDE.md via the same reseedAgentsMd merge (fresh template wins per-H2, operator-added H2 sections preserved). Guard: only a provably QuadWork-seeded CLAUDE.md is touched — one carrying the signature H2 set (_isSeededClaudeMd). A project's own hand-authored CLAUDE.md, or a missing one, is left byte-identical and recorded in skipped. AGENTS.md reseed behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Epic Alignment: PASS
#966 requires CLAUDE.md reseed through existing per-H2 merge semantics while preserving AGENTS.md behavior and never overwriting foreign CLAUDE.md; PR #993 implements that in server/routes.js:4390 with coverage in server/routes.reseedClaudeMd.test.js:137.
Checked (evidence)
- Structural gate:
gh pr view 993 --json body→ filled## EPIC Alignmentand## Self-Verification; non-UI PR. - Issue/epic context:
gh issue view 966+gh api repos/realproject7/quadwork/issues/967→ standalone folded ticket under #967; reseed contract is reusereseedAgentsMd, preserve operator H2s, do not change AGENTS.md behavior. - Diff scope:
gh api repos/realproject7/quadwork/pulls/993/files→ exactlyserver/routes.js(+58) andserver/routes.reseedClaudeMd.test.js(+181). - Acceptance: seeded CLAUDE.md gate at
server/routes.js:4160; reseed/skip/report path atserver/routes.js:4395; endpoint tests cover seeded refresh, foreign byte-identical skip, missing skip, and AGENTS.md still refreshed atserver/routes.reseedClaudeMd.test.js:157. - Riskiest part of this diff: the provenance heuristic could clobber foreign files if too broad; it requires all three stable template H2s and fails closed for empty/missing/foreign cases, with endpoint regression coverage.
- Kill-list: scanned all items — clean.
- CI:
gh pr checks 993→test pass 48s.
Findings
- None.
Decision
Approving at 24160df828049189221b95bce8537434fc84227d; the implementation matches #966's safety constraints and keeps the change local to the reseed path plus focused tests.
|
@re2 APPROVE at Scope is exactly the two files claimed: Checked (evidence)
Non-blocking nit (no change required): the preserved-notes trailer text is shared with AGENTS.md, so an operator H2 preserved inside a refreshed CLAUDE.md is labeled Standing no-merge rule — operator merges. |
Closes #966
Summary
Auto-reseed (
server/routes.js_performReseedWrites) refreshed a project's worktreeAGENTS.mdon every template upgrade but neverCLAUDE.md, so after a template update the two instruction files drifted (AGENTS.md = new, CLAUDE.md = old). This adds aCLAUDE.mdrefresh to the same per-target loop, merged through the existingreseedAgentsMdhelper (fresh template wins per-H2, operator-added H2 sections preserved).Core design constraint — never clobber a project's OWN hand-authored CLAUDE.md. Setup only wrote the template
CLAUDE.mdwhen a worktree had none, so a worktree'sCLAUDE.mdmay be entirely project-authored. A new pure predicate_isSeededClaudeMd()refreshes a worktreeCLAUDE.mdonly when it carries the QuadWork template's signature H2 set (## Multi-Agent System+## GitHub Workflow+## Communication Rules) — three distinctive headings stable across template versions that a project's own dev rules won't have. Anything else (foreign, empty, or missing) is left byte-identical and recorded inskipped.Return shape unchanged:
CLAUDE.mdoutcomes join the existing{reseeded, skipped, preserved}arrays/map (<agent>/CLAUDE.mdkeys). Both the manual reseed endpoint and the version-upgrade auto-reseed run through_performReseedWrites, so both now keep CLAUDE.md in sync.EPIC Alignment
EPIC #967 — folded / isolated (per the batch brief). No sibling contracts to reconcile; this ticket stands alone. The change is confined to the reseed write path and does not alter EPIC-tracked surfaces.
Self-Verification
Adversarial diff re-read — the only production change is the CLAUDE.md block inside
_performReseedWritesplus a pure predicate + its export. AGENTS.md handling above it is untouched.Kill-list / safety invariants:
reseedAgentsMd/ token-preservation / auto-reseed tests pass._isSeededClaudeMdfail-closed: empty/null/foreign →false→ skipped, verified byte-identical in test.skipped(<agent>/CLAUDE.md (none)), no file created.preservedis echoed as-is in the JSON response and the auto-reseed log only readsreseeded.length/skipped.length; the frontend (ControlBar.tsx) reads onlyreseeded.length. Mixedpreservedkey format is display-only.Build + test evidence:
npm test→ 62 passed, 0 failed, 2 skipped (pre-existing Jest-style skips).server/routes.reseedClaudeMd.test.js: predicate unit cases + endpoint E2E (seeded refreshed & operator H2 preserved; foreign left byte-identical & skipped; missing handled without error; AGENTS.md still refreshed).node server/pack-smoke.test.js→ PASS.node -e "require('./server/routes.js')"→ loads OK.Acceptance criteria (1:1):
templates/CLAUDE.md, substitutes{{project_name}}, merges viareseedAgentsMd✅{reseeded, skipped, preserved}✅Deviations
reseedAgentsMdreads<!-- Operator notes preserved from prior AGENTS.md (#845) -->even inside a merged CLAUDE.md. Cosmetic; left as-is because the ticket directs reuse of the same helper unchanged.