Skip to content

bkrisetya/agentrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

agentrc

One config file for all your AI coding agents.

Write your AI instructions once. Claude Code, Gemini, Codex, Copilot — they all get them.

The problem

You use multiple AI coding agents. Each reads instructions from a different file:

Agent Reads from
Claude Code ~/.claude/CLAUDE.md
Gemini CLI ~/.gemini/GEMINI.md
Codex CLI ~/.codex/AGENTS.md
GitHub Copilot ~/.copilot/copilot-instructions.md

When you add a rule to CLAUDE.md ("fix root causes, not symptoms"), your other agents don't know about it. You end up maintaining 4 files that drift apart.

The solution

Maintain one file. Run agentrc. All agents get the same instructions.

~/.claude/CLAUDE.md  (you edit this)
        |
        v  agentrc
        |
        +---> ~/.gemini/GEMINI.md
        +---> ~/.codex/AGENTS.md
        +---> ~/.copilot/copilot-instructions.md
        +---> ~/AGENTS.md (cross-tool fallback)

Install

# Download
curl -fsSL https://raw.githubusercontent.com/bkrisetya/agentrc/main/agentrc.sh \
  -o ~/.local/bin/agentrc
chmod +x ~/.local/bin/agentrc

# Or clone
git clone https://github.com/bkrisetya/agentrc.git
cp agentrc/agentrc.sh ~/.local/bin/agentrc

Usage

# Sync from default source (~/.claude/CLAUDE.md)
agentrc

# Sync from a custom source file
agentrc ~/my-instructions.md

# See what's current vs stale
agentrc --list

# Preview without writing
agentrc --dry-run

Output

agentrc v0.1.0 — syncing from /home/you/.claude/CLAUDE.md
  [ok] /home/you/.gemini/GEMINI.md
  [ok] /home/you/.codex/AGENTS.md
  [ok] /home/you/.copilot/copilot-instructions.md
  [ok] /home/you/AGENTS.md

Done. Wrote 4 targets.

Automate it

Claude Code hook (runs after every session)

Add to ~/.claude/settings.json:

{
  "hooks": {
    "Stop": [
      { "command": "agentrc --quiet" }
    ]
  }
}

Cron (every 15 minutes)

*/15 * * * * ~/.local/bin/agentrc --quiet

Git hook (post-commit)

echo '#!/bin/sh
agentrc --quiet' > .git/hooks/post-commit
chmod +x .git/hooks/post-commit

Custom targets

Add extra target paths to ~/.config/agentrc/targets.conf:

# One path per line
~/.cursor/rules/instructions.md
~/.aider/conventions.md
~/.continue/config.md

Custom source

Set AGENTRC_SOURCE to use a different source file:

export AGENTRC_SOURCE=~/my-ai-rules.md
agentrc

How it works

  1. Reads your source file (default: ~/.claude/CLAUDE.md)
  2. For each target agent, writes the source content with a small header comment
  3. Handles Windows (OneDrive path redirect, Git Bash compatibility)
  4. Skips targets where the directory can't be created (no errors, just [skip])

The script is 200 lines of bash with zero dependencies. It works on Linux, macOS, and Windows (Git Bash).

FAQ

Q: Does it modify my source file? No. It only reads the source and writes to target locations.

Q: What if I don't use all these agents? It only writes to directories that exist or can be created. Missing agents are silently skipped.

Q: Does it work on Windows? Yes, via Git Bash. It handles the USERPROFILE / OneDrive path redirect that Windows users encounter.

Q: Can I use something other than CLAUDE.md as the source? Yes. Pass any markdown file as an argument, or set AGENTRC_SOURCE.

Q: What about agent-specific instructions? Use your source file for shared rules. For agent-specific overrides, edit the target files directly — agentrc will overwrite them on next run, so keep agent-specific rules in a separate section of your source file.

Caveats

  • Overwrites target files. Each run replaces the target files entirely. If you've manually edited ~/.gemini/GEMINI.md, those edits are lost on the next agentrc run. Keep all instructions in your source file.
  • Not all instructions are portable. Your CLAUDE.md may reference Claude Code-specific features (tools like Read, Edit, Glob; skills; plan mode; subagents). Other agents will see these instructions but may not understand them. This is usually harmless — agents ignore what they don't support.
  • Agent path conventions may change. The target paths (~/.gemini/GEMINI.md, ~/.codex/AGENTS.md, etc.) are based on current agent CLI versions as of early 2026. If an agent changes where it reads instructions, you may need to update targets.conf.
  • Requires bash 4+ for associative arrays. macOS ships bash 3 but most users have bash 4+ via Homebrew. The script will error clearly if bash is too old.
  • No merge, just overwrite. This is a fan-out tool, not a sync tool. It does not merge agent-specific changes back into your source. The source file is the single source of truth.

License

MIT

About

One config file for all your AI coding agents. Syncs CLAUDE.md to Gemini, Codex, Copilot, and more.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages