Skip to main content

Synchronize rules across AI coding assistants (Claude Code, Cursor, Gemini, OpenCode)

Project description

Agent Rules Sync

Synchronize your rules across Claude Code, Cursor, Gemini, and OpenCode in real-time.

Edit rules in any AI agent โ†’ they automatically sync to all other agents.

Installation

Works on macOS, Linux, and Windows (native + WSL).

Quick Install

Using pip:

pip install agent-rules-sync

Using uv (faster):

uv pip install agent-rules-sync

From source:

pip install git+https://github.com/dhruv-anand-aintech/agent-rules-sync.git

That's it! The daemon installs and starts automatically.

What Happens During Installation

  1. Daemon is installed as a system service (auto-starts on boot)
  2. Service starts immediately and runs in the background
  3. Rules sync automatically every 3 seconds

Platform-Specific Installation

macOS:

  • Installs as launchd service (com.local.agent-rules-sync)
  • Auto-starts on login
  • Logs to ~/.config/agent-rules-sync/
  • File: ~/Library/LaunchAgents/com.local.agent-rules-sync.plist

Linux:

  • Installs as systemd user service (agent-rules-sync.service)
  • Auto-starts on login
  • Logs to ~/.config/agent-rules-sync/daemon.log
  • File: ~/.config/systemd/user/agent-rules-sync.service

Windows:

  • Installs via Windows Task Scheduler (with startup folder fallback)
  • Auto-starts on user login
  • Logs to ~/.config/agent-rules-sync/daemon.log
  • Task name: agent-rules-sync (visible in Task Scheduler)
  • View logs: type %USERPROFILE%\.config\agent-rules-sync\daemon.log

Usage

The daemon is already running!

After installation, the daemon runs automatically in the background. Just start editing.

Shared vs Agent-Specific Rules

Rules can be shared (sync to all agents) or agent-specific (stay local to one agent).

Shared Rules sync to all agents automatically:

# Shared Rules
- use pydantic for validation  <- Appears in all agents
- always test edge cases

Agent-Specific Rules stay local and don't sync to other agents:

# Shared Rules
- shared rule

## Claude Code Specific
- use claude-specific syntax  <- Only in Claude Code, doesn't sync elsewhere

Each agent file has the same structure:

# Shared Rules
- rule 1 (syncs everywhere)
- rule 2

## Claude Code Specific
- claude local rule

## Cursor Specific
- cursor local rule

Removing Rules is simple - just delete the line from any agent file or the master, and it disappears on the next sync (backups preserve deleted rules).

1. Edit Rules Anywhere

Pick any location and edit:

# Main AI Editors
vim ~/.claude/CLAUDE.md          # Claude Code
vim ~/.cursor/rules/global.mdc   # Cursor
vim ~/.gemini/GEMINI.md          # Gemini Antigravity
vim ~/.config/opencode/AGENTS.md # OpenCode

# Additional Agent Locations
vim ~/.config/agents/AGENTS.md   # Config Agents
vim ~/.codex/AGENTS.md           # Codex
vim ~/.config/AGENTS.md          # Config root
vim ~/.agent/AGENTS.md           # Local Agent
vim ~/.agent/AGENT.md            # Local Agent (alternate)

Just add or remove lines starting with -:

- rule 1
- rule 2
- rule 3

2. Changes Sync Automatically

Within 3 seconds, your changes appear in all other agents! No manual sync needed.

How It Works

  1. Daemon monitors all 9 agent config file locations every 3 seconds
    • Claude Code, Cursor, Gemini, OpenCode, Config Agents, Codex, Config root, Local Agent (2 variants)
  2. Detects changes in any file (master or agents)
  3. Merges rules from all sources (shared + agent-specific)
  4. Syncs to all agents automatically
  5. Deduplicates identical rules

No User Master File

The master rules file is stored hidden in ~/.config/agent-rules-sync/RULES.md โ€” you never need to touch it. Just edit your agent files!

Commands

The daemon runs automatically. These commands are for management:

# Check daemon status
agent-rules-sync status

# Watch mode (foreground, useful for debugging)
agent-rules-sync watch

# Stop daemon (it will auto-restart on next login)
agent-rules-sync stop

Windows Task Scheduler Management:

# View running task
schtasks /query /tn "agent-rules-sync"

# Manually delete task (if needed)
schtasks /delete /tn "agent-rules-sync" /f

# Manually create task (if needed)
# See install_daemon.py for task XML details

Backups

Every file change is automatically backed up with a timestamp.

View your backups:

ls -lah ~/.config/agent-rules-sync/backups/

Restore a previous version:

cp ~/.config/agent-rules-sync/backups/claude_20260125_014532.md ~/.claude/CLAUDE.md

For detailed backup information, see BACKUPS.md

To completely uninstall:

On macOS or Linux:

curl -fsSL https://raw.githubusercontent.com/dhruv-anand-aintech/agent-rules-sync/main/uninstall.py | python3

On Windows:

python -c "import urllib.request; exec(urllib.request.urlopen('https://raw.githubusercontent.com/dhruv-anand-aintech/agent-rules-sync/main/uninstall.py').read())"

Or manually:

python -m pip uninstall -y agent-rules-sync

When Changes Take Effect

Important: Different agents load configuration at different times. After Agent Rules Sync updates files, you may need to restart your agent for changes to take effect:

Agent What to Do
Claude Code Restart the application or start a new session
Cursor Changes apply automatically in new conversations
Gemini Antigravity Run /memory refresh command or restart
OpenCode Restart or start a new session

For detailed technical information, see AGENT_FILE_RELOAD.md

Example Workflow

Shared Rule (syncs everywhere)

Terminal 1:

$ agent-rules-sync watch
๐Ÿ”„ Watching for changes (every 3s)...

Terminal 2:

# Add shared rule to Claude
$ cat >> ~/.claude/CLAUDE.md << 'EOF'
# Shared Rules
- use pydantic for validation
EOF

[3 seconds later...]

Result: Rule appears in all agents:

  • โœ… ~/.cursor/rules/global.mdc
  • โœ… ~/.gemini/GEMINI.md
  • โœ… ~/.config/opencode/AGENTS.md

Agent-Specific Rule (stays local)

Terminal 2:

# Add Claude-specific rule
$ cat >> ~/.claude/CLAUDE.md << 'EOF'
## Claude Code Specific
- use claude-style syntax highlights
EOF

[3 seconds later...]

Result: Rule stays in Claude only

  • โœ… ~/.claude/CLAUDE.md has the rule
  • โŒ ~/.cursor/rules/global.mdc does NOT have it
  • โŒ Other agents unaffected

โœ“ Done! Shared rules sync everywhere, agent-specific rules stay local.

Features

โœ“ Shared rules โ€” sync rules to all agents automatically โœ“ Agent-specific rules โ€” keep rules local to one agent only โœ“ Rule deletion โ€” just delete the line, it disappears on next sync โœ“ Bidirectional sync โ€” rules can be added from any agent โœ“ Auto-deduplication โ€” same rule doesn't appear twice โœ“ Automatic backups โ€” timestamped backups before every change โœ“ Fire and forget โ€” daemon auto-starts and runs in background โœ“ Zero config โ€” works out of the box โœ“ Real-time โ€” syncs within 3 seconds โœ“ Safe recovery โ€” restore any previous version from backups

Merging Behavior

Rules are merged, not replaced. If you have:

Master: - rule A, - rule B Claude: - rule A, - rule B, - rule C

After sync, all agents get: - rule A, - rule B, - rule C

No rules are lost!

Architecture

Shared Rules (in # Shared Rules section)
         โ†“
    Daemon detects changes (every 3 seconds)
         โ†“
    Extract shared + agent-specific rules
         โ†“
    Merge all sources bidirectionally
         โ†“
    Rebuild master with all sections
         โ†“
    Sync: shared to all, agent-specific to their agent
         โ†“
    Done! (rules synced, agent rules stay local)

Master file structure:

~/.config/agent-rules-sync/RULES.md
โ”œโ”€ # Shared Rules (syncs to all agents)
โ”œโ”€ ## Claude Code Specific (Claude only)
โ”œโ”€ ## Cursor Specific (Cursor only)
โ”œโ”€ ## Gemini Specific (Gemini only)
โ””โ”€ ## OpenCode Specific (OpenCode only)

Monitoring

Check status anytime:

$ agent-rules-sync status

======================================================================
Agent Rules Sync Status
======================================================================

๐Ÿ“‚ Config directory: ~/.config/agent-rules-sync

๐Ÿ“„ Master Rules: ~/.config/agent-rules-sync/RULES.md
   Hash: acfa47839976...

๐Ÿค– Claude Code
   Path: ~/.claude/CLAUDE.md
   Status: โœ“ In sync

๐Ÿค– Cursor
   Path: ~/.cursor/rules/global.mdc
   Status: โœ“ In sync

๐Ÿค– Gemini Antigravity
   Path: ~/.gemini/GEMINI.md
   Status: โœ“ In sync

๐Ÿค– OpenCode
   Path: ~/.config/opencode/AGENTS.md
   Status: โœ“ In sync

======================================================================

Logs

Daemon logs are stored in:

~/.config/agent-rules-sync/daemon.log

View recent activity:

tail -f ~/.config/agent-rules-sync/daemon.log

Troubleshooting

Daemon not syncing?

# Check status
agent-rules-sync status

# Check logs
tail ~/.config/agent-rules-sync/daemon.log

# Restart
agent-rules-sync stop
agent-rules-sync  # Start again

Want to debug in foreground?

# Run in foreground instead of daemon
agent-rules-sync watch

Need to see what's backed up?

ls -la ~/.config/agent-rules-sync/backups/

How do I uninstall?

One-liner:

curl -fsSL https://raw.githubusercontent.com/dhruv-anand-aintech/agent-rules-sync/main/uninstall.sh | bash

Or manually:

agent-rules-sync stop                    # Stop daemon
pip uninstall -y agent-rules-sync        # Remove package
rm -rf ~/.config/agent-rules-sync        # Clean up config

Your agent rule files are preserved and not deleted!

Supported Agent Locations

Agent Rules Sync monitors and syncs rules across 9+ agent configuration locations:

Main Editors:

  • Claude Code (~/.claude/CLAUDE.md)
  • Cursor (~/.cursor/rules/global.mdc)
  • Gemini Antigravity (~/.gemini/GEMINI.md)
  • OpenCode (~/.config/opencode/AGENTS.md)

Additional Locations:

  • Config Agents (~/.config/agents/AGENTS.md)
  • Codex (~/.codex/AGENTS.md)
  • Config Root (~/.config/AGENTS.md)
  • Local Agent (~/.agent/AGENTS.md)
  • Local Agent Alt (~/.agent/AGENT.md)

Create any of these files and Agent Rules Sync will automatically sync rules to all other locations!

Requirements

  • Python 3.8+
  • At least one agent configuration file location (any of the above)

License

MIT License - see LICENSE file

Contributing

Contributions welcome! Feel free to submit issues and pull requests.

Support

Repository

https://github.com/dhruv-anand-aintech/agent-rules-sync


Keep your AI agent rules in sync. Edit anywhere. Sync everywhere.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_rules_sync-1.2.3.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_rules_sync-1.2.3-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file agent_rules_sync-1.2.3.tar.gz.

File metadata

  • Download URL: agent_rules_sync-1.2.3.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agent_rules_sync-1.2.3.tar.gz
Algorithm Hash digest
SHA256 24ffa9edd523066fb5a78172064ff6c228bce40995fa159a7a6f82ad813ff003
MD5 0e1dea450e5a83a9396556f789fd76ee
BLAKE2b-256 1e94ea2863d7a408213aefbc8015e3ecb9ac81dc7ffe0d0cf1cb6bd74673796d

See more details on using hashes here.

File details

Details for the file agent_rules_sync-1.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_rules_sync-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fcb340b726261fc64b64a51a26d70b7f07cca50e6763ef3f4135e886cca1677a
MD5 f718181ba33d3ba563da1516ac38c9ad
BLAKE2b-256 8a0be45fa287b04fcea089011130f71de243c88ae0fff0c1f482180d62ad5e28

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page