Skip to content

feat(sync): adopt an existing CLAUDE.md instead of skipping it#17

Merged
CodeWithJuber merged 1 commit into
masterfrom
claude/logic-algorithm-implementation-c09485
Jul 6, 2026
Merged

feat(sync): adopt an existing CLAUDE.md instead of skipping it#17
CodeWithJuber merged 1 commit into
masterfrom
claude/logic-algorithm-implementation-c09485

Conversation

@CodeWithJuber

Copy link
Copy Markdown
Owner

What & why

Answers a real question about how Forge treats a project that already has its own config. Before
this, forge sync skipped an existing unmanaged CLAUDE.md — which meant Forge's shared
rules never reached Claude Code in that repo (the activation @AGENTS.md import was never wired
in). Now sync adopts it:

  • Prepends the one-line @AGENTS.md import to the top of the existing CLAUDE.md.
  • Preserves every original line (it's a prepend, not a rewrite).
  • Idempotent — if the import is already present, it reports unchanged and does nothing.
  • Reports adopted in the sync report so the user sees exactly what happened.

Unchanged by design: AGENTS.md keeps 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 test passes (Node 18/20/22) — 204 tests
  • npm run check passes (Biome lint + format)
  • New behaviour has a test (adopt → preserve → idempotent) in test/sync.test.js
  • Conventional commit message (feat:)
  • CHANGELOG.md updated under ## [Unreleased]
  • No new runtime dependency

Risk & rollback

  • Risk level: low — a prepend that preserves all content and is idempotent; only triggers for
    a pre-existing unmanaged CLAUDE.md. Fresh repos are unaffected.
  • Rollback plan: revert the commit; a user can delete the prepended line.

Extra checks

  • npm run typecheck passes
  • Logs contain no secrets/PII

Verification

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.md produced action: adopted and the preserved-plus-wired file.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HGZUYFdUb4EViXV5tRid19


Generated by Claude Code

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
CodeWithJuber marked this pull request as ready for review July 6, 2026 07:01
@CodeWithJuber
CodeWithJuber merged commit 0de0705 into master Jul 6, 2026
7 checks passed
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.

2 participants