How the Platform Sync Script Regenerates Agent Instructions for Different AI Tools
The platform sync script regenerates agent instructions by reading the canonical AGENTS.md file, expanding @file references, and writing formatted output to tool-specific configuration paths.
The JCodesMore/ai-website-cloner-template repository maintains AI assistant consistency through a single source of truth. When you need to synchronize behavior across multiple AI coding tools, the platform sync script regenerates agent instructions automatically, eliminating manual duplication and ensuring every assistant follows the same project conventions.
The Source of Truth: AGENTS.md
The repository stores canonical agent rules in AGENTS.md at the root directory. This file contains the master definitions that govern how AI assistants should interpret code, structure responses, and handle project-specific tasks.
Locating Repository Paths
At the top of scripts/sync-agent-rules.sh, the script establishes its working context by defining two critical variables (lines 25-27):
REPO_ROOT: The absolute path to the repository rootSOURCE: The path toAGENTS.md
These variables ensure the script operates from the correct base directory regardless of where it is invoked.
Resolving @file Imports
The resolve_imports function (lines 33-50) enables modular documentation by processing AGENTS.md line by line. When the function encounters a line beginning with @, such as:
@docs/research/INSPECTION_GUIDE.md
It treats the remainder of the line as a file path and replaces the reference with the full contents of that file using cat. This allows maintainers to split complex instruction sets across multiple files while the sync script composites them into unified outputs.
Generating Platform-Specific Outputs
The script uses a write_file helper to standardize file generation. This helper creates target directories if they do not exist, prepends an auto-generation warning header (lines 55-57), and writes the resolved content. The script generates four distinct instruction files, each formatted for their specific AI tool:
- GitHub Copilot Chat: Writes to
.github/copilot-instructions.md(lines 69-71) - Cline / Roo Code: Writes to
.clinerulesat the repository root (lines 72-74) - Continue: Writes a YAML front-matter block followed by the resolved content to
.continue/rules/project.md(lines 75-82) - Amazon Q Developer: Writes to
.amazonq/rules/project.md(lines 83-84)
Each generated file includes a header comment warning that the file is auto-generated and should not be edited directly, directing developers to modify AGENTS.md instead.
Running the Sync Script
Execute the script from the repository root to regenerate all instruction files:
bash scripts/sync-agent-rules.sh
The script outputs confirmation messages for each platform file it creates and prints a final "Done" message upon completion (lines 86-89). After execution, all AI tools receive updated instructions derived from the current state of AGENTS.md.
Summary
- The
scripts/sync-agent-rules.shscript maintains consistency across AI tools by reading fromAGENTS.mdas the single source of truth. - The
resolve_importsfunction handles modular documentation by inlining files referenced with@syntax. - Generated files include warning headers indicating they are auto-generated and should not be edited manually.
- The script supports GitHub Copilot, Cline/Roo Code, Continue, and Amazon Q Developer with appropriate formatting for each platform's requirements.
Frequently Asked Questions
What is the purpose of the AGENTS.md file?
AGENTS.md serves as the central repository for agent rules and conventions. It defines how AI assistants should interpret and interact with the codebase, acting as the single source of truth that feeds all platform-specific instruction files. When you update this file, the sync script propagates changes to every supported AI tool.
How does the script handle file imports?
The resolve_imports function scans AGENTS.md for lines starting with @, treating them as file path references. It replaces each reference with the actual contents of the specified file using standard shell commands, enabling modular organization of complex agent instructions without duplicating content across multiple files.
Which AI tools are supported by the sync script?
The script generates instructions for GitHub Copilot Chat (.github/copilot-instructions.md), Cline / Roo Code (.clinerules), Continue (.continue/rules/project.md), and Amazon Q Developer (.amazonq/rules/project.md). Each output is formatted according to the specific requirements of the target platform, such as front-matter for Continue or plain markdown for Copilot.
How do I update agent instructions after editing AGENTS.md?
Simply run bash scripts/sync-agent-rules.sh from the repository root after modifying AGENTS.md. The script regenerates all platform-specific files automatically, ensuring every AI tool receives the updated instructions without requiring manual copy-pasting or risking version drift between different configuration files.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →