Skip to content

fix(renderer): make root CLAUDE.md mergeable instead of full-overwrite#105

Merged
gbrbks merged 1 commit into
mainfrom
fix/claude-md-merge-not-overwrite
Jun 25, 2026
Merged

fix(renderer): make root CLAUDE.md mergeable instead of full-overwrite#105
gbrbks merged 1 commit into
mainfrom
fix/claude-md-merge-not-overwrite

Conversation

@gbrbks

@gbrbks gbrbks commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Problem

When /archie-deep-scan (or any render via .archie/renderer.py, archie init, finalize, or the viewer regen) runs, Archie overwrites the root CLAUDE.md with a short throwaway pointer to AGENTS.md, destroying any hand-written guidance that previously lived there.

Root cause

In renderer.py, AGENTS.md was the only mergeable file (MERGEABLE_FILES = frozenset({"AGENTS.md"})). The root CLAUDE.md was written as a static, full-overwrite _CLAUDE_POINTER (a # CLAUDE.md H1 document), never routed through render_mergeable. The marker-merge machinery already existed and was used for AGENTS.md and per-folder CLAUDE.md files — just not the root CLAUDE.md.

The CLI adapter render_outputs (archie init / serve) was a second instance of the same bug: it wrote every file with a blind write_text, clobbering both CLAUDE.md and AGENTS.md.

Fix

  • MERGEABLE_FILES now includes CLAUDE.md → it routes through render_mergeable, which owns only the block between archie:generated markers and preserves all hand-authored content outside it.
  • _CLAUDE_POINTER drops its top-level # CLAUDE.md H1 (it's appended below the project's existing body now — a second H1 would be wrong) and becomes an ## Archie Architecture Context section.
  • render_outputs routes mergeable files through render_mergeable, matching what finalize.py and the standalone main() already do.
  • Refreshed stale "full-overwrite / static pointer / never mergeable" comments.
  • Synced npm-package/assets/renderer.py from canonical (verify_sync.py passes).

finalize.py (deep-scan Step 8) and the standalone main() (Step 6 / viewer regen) both key off renderer.MERGEABLE_FILES + render_mergeable, so all three production write paths are fixed by this change.

Verification

  • 1030 passed, 1 skipped. (Only test_serve_command.py fails — pre-existing, missing optional fastapi/starlette; unrelated.)
  • New regression test: a hand-authored root CLAUDE.md survives a render, the pointer lands below it inside markers, and re-render is idempotent.
  • End-to-end against the standalone main() (the python3 .archie/renderer.py <root> path): hand-authored body preserved → CLAUDE.md: appended Archie block (user content preserved); re-render → CLAUDE.md: updated Archie block; exactly one marker pair; byte-identical on the idempotent re-run.

🤖 Generated with Claude Code

The root CLAUDE.md was written as a static full-overwrite pointer
(_CLAUDE_POINTER) and excluded from MERGEABLE_FILES, so every render
(deep-scan, finalize, archie init, viewer regen) destroyed any
hand-written root CLAUDE.md guidance.

- Add CLAUDE.md to MERGEABLE_FILES so it routes through render_mergeable,
  which owns only the block between archie:generated markers and preserves
  everything outside it.
- Drop the top-level H1 from _CLAUDE_POINTER: it is now appended below the
  project's existing body, so a second H1 would be wrong. It becomes an
  "## Archie Architecture Context" section.
- Route render_outputs (archie init / serve adapter) through render_mergeable
  too — it wrote every file with a blind write_text, the same clobber bug.
- Refresh stale "full-overwrite / static pointer / never mergeable" comments.
- Sync npm-package/assets/renderer.py from canonical.
- Add regression test: a hand-authored root CLAUDE.md survives a render,
  the pointer lands below it inside markers, and re-render is idempotent.

finalize.py and the standalone main() both key off renderer.MERGEABLE_FILES
+ render_mergeable, so all three production write paths are fixed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
archie Ready Ready Preview, Comment Jun 25, 2026 11:18am
archie-viewer Ready Ready Preview, Comment Jun 25, 2026 11:18am

@gbrbks gbrbks merged commit ce8a457 into main Jun 25, 2026
4 checks passed
@gbrbks gbrbks deleted the fix/claude-md-merge-not-overwrite branch June 25, 2026 11:20
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