feat(sync): adopt an existing CLAUDE.md instead of skipping it#17
Merged
CodeWithJuber merged 1 commit intoJul 6, 2026
Merged
Conversation
A repo with its own CLAUDE.md was previously left untouched by `forge sync`, which meant Forge's shared rules never reached Claude Code there. Sync now ADOPTS it: prepends the one-line `@AGENTS.md` import (idempotent — every original line preserved) and reports `adopted`. Re-running is a no-op once the import is present. AGENTS.md keeps its back-up-then-write behaviour; a user's skills and other tool files remain untouched. 204 tests pass; typecheck + Biome clean; zero new deps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HGZUYFdUb4EViXV5tRid19
CodeWithJuber
marked this pull request as ready for review
July 6, 2026 07:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Answers a real question about how Forge treats a project that already has its own config. Before
this,
forge syncskipped an existing unmanagedCLAUDE.md— which meant Forge's sharedrules never reached Claude Code in that repo (the activation
@AGENTS.mdimport was never wiredin). Now sync adopts it:
@AGENTS.mdimport to the top of the existingCLAUDE.md.unchangedand does nothing.adoptedin the sync report so the user sees exactly what happened.Unchanged by design:
AGENTS.mdkeeps its back-up-then-write behaviour (AGENTS.md.forge-bak+warning); Gemini/MCP configs still merge; a user's own skills and other tool files stay untouched.
src/emit/claude.js.Checklist
npm testpasses (Node 18/20/22) — 204 testsnpm run checkpasses (Biome lint + format)test/sync.test.jsfeat:)CHANGELOG.mdupdated under## [Unreleased]Risk & rollback
a pre-existing unmanaged
CLAUDE.md. Fresh repos are unaffected.Extra checks
npm run typecheckpassesVerification
Unit test asserts: after sync, the file starts with
@AGENTS.md, the original content is intact,and a second sync is a no-op with the import appearing exactly once. Manual drive on a temp repo
with a hand-written
CLAUDE.mdproducedaction: adoptedand the preserved-plus-wired file.🤖 Generated with Claude Code
https://claude.ai/code/session_01HGZUYFdUb4EViXV5tRid19
Generated by Claude Code