Skip to main content

sync-claude-md

CI Go Report Card npm PyPI

English | 日本語 | 한국어

Keeps CLAUDE.md in sync with AGENTS.md for multi-agent development workflows.

Why

AI coding agents disagree on which instruction file to read — Claude Code wants CLAUDE.md, most others (GitHub Copilot, Cursor, etc.) want AGENTS.md. Maintaining both by hand is tedious and error-prone.

sync-claude-md keeps them in sync automatically: for every AGENTS.md it finds, it ensures a sibling CLAUDE.md containing an @AGENTS.md reference exists — creating the file, or adding the reference to an existing one while preserving its content — and removes the reference (deleting the file if it's now empty) once AGENTS.md is gone. Pass --gemini to do the same for GEMINI.md (@./AGENTS.md).

Works as a pre-commit hook or standalone CLI.

Installation

via npm

npm install --save-dev sync-claude-md
npx sync-claude-md --help

via PyPI

pip install sync-claude-md
sync-claude-md --help

via GitHub Releases

Download the binary for your platform from Releases.

via Go

go install github.com/lohn/sync-claude-md/cmd/sync-claude-md@latest

Usage

CLI

sync-claude-md sync           # sync staged AGENTS.md files (default), verified against the git index
sync-claude-md sync --all     # scan the entire repository instead
sync-claude-md sync --stage   # also stage the synced files (succeeds in one pass)
sync-claude-md check --all    # dry-run: report drift without writing
sync-claude-md sync --gemini  # also sync GEMINI.md (@./AGENTS.md)

Running sync-claude-md with no command prints help. With no file arguments, only staged AGENTS.md files are processed — the intended git-hook use. Outside a git repository, "staged" is meaningless, so the default falls back to a full scan too.

Flags:

Flag Effect
--all Scan the entire repository instead of only staged files
--stage, -S git add the synced target files (inside a git repository only)
--force, -f Overwrite targets with unstaged changes, or write at all outside a git repository
--gemini Also sync GEMINI.md (@./AGENTS.md) in each directory
--no-claude Skip CLAUDE.md (use with --gemini to sync GEMINI.md only)
--no-ignore Also process target files that are git-ignored (skipped by default)
--fail-on-change Exit 1 if any file was written, even after a successful sync/stage

You can also pass specific files instead of relying on --all/staged discovery, e.g. sync-claude-md sync path/to/AGENTS.md another/AGENTS.md.

sync enforces three safety guarantees:

  • Destroy protection — refuses to overwrite a target file that has unstaged changes, which would discard your work; exits 1 without writing unless --force is passed.
  • No writes outside a git repository — there's no git history to recover from, so it refuses to write anything, even a brand-new file; exits 1 unless --force is passed.
  • Index sync (inside a git repository only) — the @AGENTS.md reference must be staged so the sync actually lands in the next commit. If it isn't (including a freshly created but untracked CLAUDE.md), it exits 1 and asks you to git add the file. Pass --stage to stage the synced files automatically and succeed in a single pass.

Note: --stage adds the whole target file, so it does not play well with partial staging (git add -p). Omit --stage and stage manually if you rely on partially staged commits.

Exit codes: 0 when there's nothing left to do (everything up to date and, inside a git repository, staged); 1 on a guarantee violation above, on drift detected by check, or — with --fail-on-change — on any write at all.

Pre-commit / prek

Add to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/lohn/sync-claude-md
    rev: v1.0.1
    hooks:
      - id: sync-claude-md

sync-claude-md is written in Go, and the default sync-claude-md hook uses language: golang, so prek/pre-commit builds it from source on first run — which requires a Go toolchain. If you'd rather not require Go on every machine, swap in one of the other hook ids; all are defined in this repo's .pre-commit-hooks.yaml:

Hook id Installs via Requires
sync-claude-md Go toolchain (build from source) Go
sync-claude-md-pip PyPI wheel Python
sync-claude-md-npm npm package Node.js
sync-claude-md-system a sync-claude-md binary already on PATH nothing extra

The hook runs sync-claude-md sync and, by default, fails the commit when a synced file is not staged so you re-stage and commit again. To stage the synced files automatically instead, add args: ['--stage']:

repos:
  - repo: https://github.com/lohn/sync-claude-md
    rev: v1.0.1
    hooks:
      - id: sync-claude-md
        args: ["--stage"]

Or use repo: local with a pre-installed binary:

repos:
  - repo: local
    hooks:
      - id: sync-claude-md
        name: Sync CLAUDE.md
        entry: sync-claude-md sync
        language: system
        always_run: true
        pass_filenames: false

Husky

See docs/husky.md for detailed setup instructions.

Quick example for .husky/pre-commit:

sync-claude-md sync --stage

How It Works

For each AGENTS.md found, a CLAUDE.md is created in the same directory containing just:

@AGENTS.md

The @path/to/file syntax resolves relative to the CLAUDE.md file itself (not CWD), so @AGENTS.md always points to the correct file. With --gemini, a GEMINI.md is created the same way using Gemini's import syntax @./AGENTS.md.

It's idempotent and safe:

  • Adds the reference (at the top) only if it isn't already present anywhere in the file, and preserves all existing content
  • Removes the reference automatically when AGENTS.md is deleted, and deletes the file if that leaves it empty
  • Refuses to read a target file larger than 10 MiB, capping how much it will ever load into memory at once — no effect on normal-sized files

License

MIT © lohn

Metadata

Release files for sync-claude-md 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for sync-claude-md 1.0.1
File
sync_claude_md-1.0.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
sync_claude_md-1.0.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
sync_claude_md-1.0.1-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
sync_claude_md-1.0.1-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
sync_claude_md-1.0.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
sync_claude_md-1.0.1-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 5.4 MB

Release files / sync_claude_md-1.0.1-py3-none-win_arm64.whl

Download URL sync_claude_md-1.0.1-py3-none-win_arm64.whl
Size 875.9 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
7d579395759bd8fd656b7afe521bd5d7f9d3e6981a100b3bb9797caa4888f6fb
BLAKE2b-256 checksum
How to use checksums
2e28ad07b82be2977c28d0860f3632d26e3e6f47ef5bbf0bd544cbf1204c2324
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / sync_claude_md-1.0.1-py3-none-win_amd64.whl

Download URL sync_claude_md-1.0.1-py3-none-win_amd64.whl
Size 973.9 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
53aac35024690f3913bf3dcee248004adfbc0942d189fff1196e9bd5f88388e2
BLAKE2b-256 checksum
How to use checksums
c4368422269913c67d91dd94a39b60f475e05e04ec072c0bf987a7d44b2b4f94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / sync_claude_md-1.0.1-py3-none-manylinux_2_17_x86_64.whl

Download URL sync_claude_md-1.0.1-py3-none-manylinux_2_17_x86_64.whl
Size 930.7 kB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
eb3dde151bacf14f617392efb0d54707c7fc70c8df0f4bfb51d3ed68a0d013d4
BLAKE2b-256 checksum
How to use checksums
d1add4c09da45e0330b2ca6a42910f259969dae9d6d5138bdbfcf853e43ef6b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / sync_claude_md-1.0.1-py3-none-manylinux_2_17_aarch64.whl

Download URL sync_claude_md-1.0.1-py3-none-manylinux_2_17_aarch64.whl
Size 847.6 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
c71b1881105b9d099255f2cb69d3f6b5cad0cce8f723db48e4246b042030e2bd
BLAKE2b-256 checksum
How to use checksums
a142eaa24750e67d19768a2d372813d042fcd4bb1fc3277dff00820135568685
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / sync_claude_md-1.0.1-py3-none-macosx_11_0_arm64.whl

Download URL sync_claude_md-1.0.1-py3-none-macosx_11_0_arm64.whl
Size 844.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d7445626584a605dc2ddd116c16c41912e05885e058a96fd6742cf8db917c810
BLAKE2b-256 checksum
How to use checksums
6fc1ac7a7e82e458f3b96beefd0481bd74ff4ec7a749efdfadb5bcc99d0844fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release files / sync_claude_md-1.0.1-py3-none-macosx_10_9_x86_64.whl

Download URL sync_claude_md-1.0.1-py3-none-macosx_10_9_x86_64.whl
Size 909.0 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
efbafabb230badf1d4a2164db6804adcdd1c3c2d5e740ff81beaeda64770e5ee
BLAKE2b-256 checksum
How to use checksums
35ee683c8dec48baffbfc345d44b63814956d312e89005845f9805fc7e272f89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.1 This release

6 release files

1.0.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page