What Does sync-agent-rules.sh Do and When to Run It After Editing AGENTS.md

The sync-agent-rules.sh script generates AI-agent configuration files from the master AGENTS.md file and should be executed immediately after any edit to AGENTS.md to keep all supported coding assistants synchronized.

In the JCodesMore/ai-website-cloner-template repository, AI-agent conventions are managed centrally through a single source of truth. The scripts/sync-agent-rules.sh utility propagates these rules to various coding tools that cannot parse the canonical markdown file directly, ensuring consistent behavior across GitHub Copilot, Cline, Continue, and Amazon Q Developer.

What sync-agent-rules.sh Does

The script located at scripts/sync-agent-rules.sh reads the canonical rules defined in AGENTS.md, resolves any @file imports, and writes the resulting content into agent-specific configuration files. Each generated file includes a header warning that it is auto-generated and should not be edited manually.

The script generates configuration for four specific AI agents:

These generated files are committed to the repository so agents can consume the same rule set without parsing the markdown themselves.

When to Run sync-agent-rules.sh

You must run the script immediately after any modification to AGENTS.md. This includes adding new conventions, importing additional documentation via @file directives, or modifying existing rules. Since the generated files are derived copies of the single source of truth, running the script ensures every supported AI assistant works with the latest conventions without requiring manual updates to each individual configuration file.

How to Execute the Script

Run the script from the repository root to update all derived configuration files:

bash scripts/sync-agent-rules.sh

The operation is safe to run at any time; it will overwrite the generated files with fresh content while preserving the auto-generated header. To verify the refresh succeeded, check your working directory status:

git status

You should see changes in .github/copilot-instructions.md, .clinerules, .continue/rules/project.md, and .amazonq/rules/project.md.

Understanding the Generated Output

Each output file contains a standardized header that prevents manual editing. Inspect any generated file to see the warning:

cat .github/copilot-instructions.md | head -n 5

The output displays:


<!-- AUTO-GENERATED from AGENTS.md — do not edit directly.
     Run `bash scripts/sync-agent-rules.sh` to regenerate. -->

The script handles format-specific requirements—such as adding the front-matter block for Continue—while keeping the core rules identical across all agent configurations.

Summary

  • scripts/sync-agent-rules.sh propagates rules from AGENTS.md to agent-specific configuration files
  • Run it immediately after editing AGENTS.md to maintain synchronization across all tools
  • It generates files for GitHub Copilot, Cline/Roo Code, Continue, and Amazon Q Developer
  • The script overwrites existing files safely and adds auto-generated headers warning against manual edits
  • Always invoke from the repository root using bash scripts/sync-agent-rules.sh

Frequently Asked Questions

Do I need to install dependencies to run sync-agent-rules.sh?

No. The script relies on standard bash utilities available in most Unix-like environments. According to the repository source code, it uses basic shell commands to parse AGENTS.md and resolve @file imports, requiring no additional package installation beyond a standard bash interpreter.

What happens if I edit .clinerules directly instead of AGENTS.md?

Manual edits to generated files such as .clinerules or .github/copilot-instructions.md will be overwritten and lost the next time you run bash scripts/sync-agent-rules.sh. All permanent changes must be made to the AGENTS.md source file, which serves as the single source of truth for agent conventions in the repository.

Can I run sync-agent-rules.sh from a subdirectory?

No. You must execute the script from the repository root. Running bash scripts/sync-agent-rules.sh from the project root ensures correct relative path resolution when writing to .github/copilot-instructions.md, .clinerules, and other agent configuration directories located throughout the repository structure.

Does the script support custom AI agents beyond the four listed?

The current implementation specifically targets GitHub Copilot Chat, Cline/Roo Code, Continue, and Amazon Q Developer. While the script architecture could theoretically support additional agents by adding new output paths, the existing version in ai-website-cloner-template only generates configuration files for these four specific tools as defined in the source code.

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 →