How to Sync Agent Rules Across Multiple AI Platforms Using Sync Scripts

You can sync agent rules across GitHub Copilot, Cline, Continue, and Amazon Q by maintaining a central AGENTS.md file and running bash scripts/sync-agent-rules.sh, which automatically generates platform-specific configuration files from this single source of truth.

The JCodesMore/ai-website-cloner-template repository implements a centralized agent rule management system that uses sync scripts to eliminate configuration drift across multiple AI platforms. By storing all guidelines in a single AGENTS.md file and propagating them through automated scripts, the project ensures that GitHub Copilot, Cline, Continue, and Amazon Q all receive identical, up-to-date instructions without manual duplication.

The Single Source of Truth Pattern

The repository maintains all agent conventions in AGENTS.md at the root directory. This file serves as the authoritative source for rules, guidelines, and project-specific instructions. It supports modular organization through @path/to/file.md import syntax, allowing you to reference external documentation while keeping the main file manageable. When the sync scripts run, these imports are resolved inline, ensuring every platform receives the complete rule set.

How the Bash Sync Script Works

The scripts/sync-agent-rules.sh utility performs the actual synchronization across platforms. According to the source code, the script executes a four-phase process:

  1. Validation (lines 28-31): Verifies that AGENTS.md exists before processing.
  2. Import resolution (lines 36-49): The resolve_imports function scans for lines beginning with @ and replaces them with the contents of the referenced file.
  3. Header prepending (lines 55-57): Constructs a standard HEADER variable containing an auto-generation warning comment.
  4. Multi-platform writing (lines 58-65): The write_file function writes the resolved content to each platform's specific configuration path.

Supported Platforms and Generated Files

The script generates the following files from AGENTS.md:

Each generated file contains an auto-generation header comment that prevents manual edits and directs contributors back to the source file.

Synchronizing Skills with Node.js

For the clone-website skill specifically, scripts/sync-skills.mjs handles propagation across additional platforms. This Node script parses the source skill at .claude/skills/clone-website/SKILL.md and adapts it for nine different platforms including Cursor, Gemini, and Codex. The script contains write operations spanning lines 56-98, generating files such as .cursor/commands/clone-website.md and .gemini/commands/clone-website.toml.

Step-by-Step Sync Workflow

To update agent rules across all platforms:

  1. Edit AGENTS.md with new guidelines or import external documentation using @docs/... syntax.
  2. Execute the sync command:
bash scripts/sync-agent-rules.sh
  1. Verify the output by checking that generated files contain the auto-generated header and match your source changes.
  2. Commit both AGENTS.md and the generated files to ensure version control tracks the synchronized state.

Summary

  • Centralize rules in AGENTS.md: Treat this file as the single source of truth for all agent guidelines to eliminate configuration drift across platforms.
  • Run bash scripts/sync-agent-rules.sh: This idempotent script resolves @ imports (lines 36-49) and writes standardized configurations to .github/copilot-instructions.md, .clinerules, .continue/rules/project.md, and .amazonq/rules/project.md (lines 58-65).
  • Use @file syntax for modularity: Import external documentation sections into AGENTS.md to keep the main file readable while distributing complete content to every agent.
  • Commit generated files: Although generated, platform-specific files should be version-controlled so collaborators receive consistent agent behavior without running scripts themselves.

Frequently Asked Questions

What is the purpose of AGENTS.md?

AGENTS.md serves as the centralized repository for all AI agent guidelines and project conventions. It acts as the single source of truth that the sync scripts read when generating platform-specific configuration files. By maintaining rules here, you ensure consistent instructions across GitHub Copilot, Cline, Continue, and Amazon Q without manual duplication.

How does the @ syntax work in AGENTS.md?

The @ syntax enables modular documentation by allowing you to reference external files within AGENTS.md. When scripts/sync-agent-rules.sh executes, the resolve_imports function (lines 36-49) scans for lines starting with @ and replaces them with the contents of the referenced file path. This inline expansion happens before the content is written to any platform-specific destination, keeping the source organized while distributing complete documentation.

Can I run the sync scripts multiple times safely?

Yes, the scripts are explicitly designed to be idempotent operations. Each execution of bash scripts/sync-agent-rules.sh overwrites the generated files with the latest resolved content from AGENTS.md, ensuring platforms stay synchronized without creating duplicates or conflicts. This design allows you to run the script repeatedly during development to propagate incremental changes.

How do I add support for a new AI platform?

To add a new platform, extend the write_file calls in scripts/sync-agent-rules.sh (around lines 58-65) to include the new destination path and filename. You must follow the existing pattern of prepending the standard header and writing the resolved content to ensure consistency. Once added, running the script will generate the configuration file for the new platform alongside existing ones.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →