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 batch file to startup folder
  • Auto-starts on next login
  • Logs to ~/.config/agent-rules-sync/
  • File: ~/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/agent-rules-sync.bat

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:

# Edit Claude Code rules
nano ~/.claude/CLAUDE.md

# Edit Cursor rules
nano ~/.cursor/rules/global.mdc

# Edit Gemini rules
nano ~/.gemini/GEMINI.md

# Edit OpenCode rules
nano ~/.config/opencode/AGENTS.md

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 agent config files every 3 seconds
  2. Detects changes in any file (master or agents)
  3. Merges rules from all sources
  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

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:

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

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!

Requirements

  • Python 3.8+
  • Claude Code, Cursor, Gemini, or OpenCode installed (at least one)

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.1.0.tar.gz (13.4 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.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_rules_sync-1.1.0.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agent_rules_sync-1.1.0.tar.gz
Algorithm Hash digest
SHA256 a29d5aaaa763b070e45dadab3d3c228b408cf9578339356f6c5f91219b083a9e
MD5 3de7d87b53391bfdb5607251f9fe88d6
BLAKE2b-256 7f78adb9f1f48862adbd1de4bea2c1368ae59986c09a3fa7851a4c7860576f29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_rules_sync-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5d4bd2d442d14810b890821d53efc0881aed9dd97800f73ecf84c41e5cb248
MD5 bc7484115d5f511eb8ceaad57da70abd
BLAKE2b-256 29b4a61a99b8bfed8039107d5183f4e795b923a8705911fcd58a1b064f61b8c2

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