McGarrah Technical Blog

Managing Context and Rules Across Multiple AI Coding Assistants

· 8 min read

As the landscape of AI coding assistants continues to explode — with tools like Amazon Q, Claude Code, GitHub Copilot, Cursor, Windsurf, and Gemini Code Assist — managing how these agents interact with your codebase is becoming a new kind of maintenance headache.

Each of these tools has its own proprietary way of defining repository rules and context. Amazon Q looks in .amazonq/rules/, Claude Code reads CLAUDE.md, GitHub Copilot wants .github/copilot-instructions.md, Cursor uses .cursor/rules/*.mdc, and so on. If you bounce between tools, or if your team members use different assistants, maintaining separate rule files for each tool is a recipe for drift and frustration.

For a detailed reference of what each agent expects, see the companion article AI Coding Agent Context Files: A Reference Guide.

The Problem: N Tools × M Rules = Drift

This is fundamentally the same configuration management problem as maintaining Terraform modules, Ansible roles, or Kubernetes manifests across environments — a single source of truth that needs to be projected into multiple vendor-specific formats. The tooling is different, but the drift pattern is identical.

Here’s what a repository looks like when you try to support every agent natively:

project-root/
├── .amazonq/rules/
│   ├── coding-standards.md
│   └── project-context.md
├── .github/
│   └── copilot-instructions.md
├── .cursor/rules/
│   └── general.mdc
├── .windsurf/rules/
│   └── general.md
├── .gemini/
│   └── styleguide.md
├── .clinerules
├── .aider.conf.yml
├── CLAUDE.md
└── ... your actual code

That’s eight places containing roughly the same information. When you update a coding convention, you need to update all eight. You won’t. Nobody will. The files will drift, and different agents will enforce different rules on the same codebase.

Why Cross-Referencing Doesn’t Work

My initial thought was to just cross-reference the files. For example, creating a CLAUDE.md that says “Please adhere to the coding standards defined in the .amazonq/rules/ directory.”

The problem with this approach is that it relies on the AI recognizing the path, deciding to crawl those specific files, and successfully fetching the text into its active context window. While agents are getting better at full-workspace awareness, relying on an AI to chase down directory references designed for a competitor’s tool is fragile. It often results in the agent hallucinating or ignoring your standards completely because the actual text of the rules never made it into the prompt’s context window.

Some agents handle this better than others — Claude Code will actually read files you reference — but it’s not reliable across all tools.

Strategy 1: Tool-Agnostic Centralization

The most robust approach is to decouple your instructions from any specific AI’s proprietary folder structure.

Step 1: Create a Root-Level Source of Truth

Move the actual content of your rules out of the proprietary folders and consolidate them into a well-structured file at the root of your repository:

project-root/
├── CONVENTIONS.md          # The single source of truth
├── .amazonq/rules/
│   └── conventions.md      # → Points to or copies from CONVENTIONS.md
├── CLAUDE.md               # → Points to or copies from CONVENTIONS.md
├── .github/
│   └── copilot-instructions.md  # → Points to or copies from CONVENTIONS.md
└── ...

CONVENTIONS.md (or RULES.md, CONTRIBUTING.md, or AI-CONTEXT.md — the name doesn’t matter) contains your actual coding standards, project context, build commands, and architectural decisions. Human developers read this file too.

Step 2: Make Agent Files Thin Wrappers

Each agent-specific file becomes a thin wrapper. For agents that can follow file references (Claude Code), point to the source:

# CLAUDE.md
Read and follow all instructions in CONVENTIONS.md in this repository root.

For agents that don’t reliably follow references (most of them), you have two options:

Option A: Duplicate with a generation note. Copy the content and add a header:

<!-- AUTO-GENERATED: Source of truth is CONVENTIONS.md. Do not edit directly. -->

# Coding Standards
...

Option B: Use a build script. Generate the agent-specific files from the source:

#!/bin/bash
# sync-ai-rules.sh — Generate agent-specific files from CONVENTIONS.md

SOURCE="CONVENTIONS.md"

# Amazon Q
mkdir -p .amazonq/rules
cp "$SOURCE" .amazonq/rules/conventions.md

# Claude Code
cp "$SOURCE" CLAUDE.md

# GitHub Copilot
mkdir -p .github
cp "$SOURCE" .github/copilot-instructions.md

# Gemini
mkdir -p .gemini
cp "$SOURCE" .gemini/styleguide.md

# Cursor (needs MDC frontmatter)
mkdir -p .cursor/rules
echo '---
description: Project conventions
alwaysApply: true
---' > .cursor/rules/conventions.mdc
cat "$SOURCE" >> .cursor/rules/conventions.mdc

echo "AI context files synced from $SOURCE"

Run this as a pre-commit hook or part of your CI pipeline.

Step 3: Explicitly Pass Context When It Matters

When starting a task where repository rules matter, pull them into the chat context using the @-mention feature available in most IDEs:

“Refactor this module, and please follow the guidelines in @CONVENTIONS.md”

This guarantees the full text is loaded into the LLM’s context window regardless of which agent you’re using.

Strategy 2: Layered Architecture

For larger projects, a single file gets unwieldy. Use a layered approach where the root file is a summary and agent-specific files add detail:

project-root/
├── CONVENTIONS.md              # High-level standards (all agents read this)
├── docs/
│   ├── ARCHITECTURE.md         # Detailed architecture (referenced as needed)
│   └── CODING-STANDARDS.md     # Detailed style guide
├── .amazonq/rules/
│   ├── conventions.md          # Symlink or copy of CONVENTIONS.md
│   └── project-context.md     # Amazon Q-specific extras (memory bank, etc.)
├── CLAUDE.md                   # Points to CONVENTIONS.md + Claude-specific notes
└── .github/
    └── copilot-instructions.md # Copy of CONVENTIONS.md

This works well when you have one primary agent (with rich rules) and want other agents to at least get the basics.

Strategy 3: Accept the Fragmentation

Sometimes the pragmatic answer is to pick your primary agent and maintain its rules properly, while giving other agents minimal context. Not every agent needs the full picture if you only use it occasionally.

For example, if Amazon Q is your daily driver:

This is honest about how most developers actually work. The risk is that when you do switch agents, the context gap shows.

Handling Exclusions

Just as you need to feed the AI the right rules, you need to keep it away from the wrong files. The exclusion landscape is fragmented:

Agent Exclusion File
Cursor .cursorignore
Windsurf .windsurfignore
Gemini .aiexclude
Cline .clineignore
Aider .aiderignore
Amazon Q / Claude Code / Copilot .gitignore (reused)

All of these use .gitignore syntax. If you need AI-specific exclusions (files tracked in git but hidden from AI), you can maintain a single source and symlink:

# Create the canonical AI exclusion list
cat > .ai-exclude <<'EOF'
*.env
*.pem
*.key
secrets/
credentials/
EOF

# Symlink for each agent that supports it
ln -s .ai-exclude .cursorignore
ln -s .ai-exclude .windsurfignore
ln -s .ai-exclude .aiexclude
ln -s .ai-exclude .clineignore
ln -s .ai-exclude .aiderignore

A Real Example: My Blog Repository

Here’s how I handle this in practice for this Jekyll blog. Amazon Q is my primary agent, so it gets the full treatment:

mcgarrah.github.io/
├── .amazonq/rules/
│   ├── git-credentials-context.md    # Git auth troubleshooting
│   └── memory-bank/
│       ├── guidelines.md             # Coding standards
│       ├── product.md                # Project overview
│       ├── structure.md              # Directory layout
│       └── tech.md                   # Technology stack
└── ... (no other agent files currently)

If I wanted to support Claude Code and Copilot without duplicating everything, I’d add:

# CLAUDE.md
This is a Jekyll 4.4.1 blog hosted on GitHub Pages at mcgarrah.org.
Read .amazonq/rules/memory-bank/ for detailed project context,
coding standards, and architecture documentation.

## Quick Reference
- `bundle exec jekyll serve` for local dev
- Posts in _posts/ with YYYY-MM-DD-title.md naming
- Custom plugins in _plugins/ must set `safe true`
- JavaScript: IIFEs, strict mode, const/let only

Claude Code will actually read those referenced files. For Copilot, I’d put a condensed version of the standards directly in .github/copilot-instructions.md since it won’t follow the reference.

What About MCP?

Model Context Protocol (MCP) standardizes how AI agents connect to external tools and data sources — databases, APIs, file systems, and more. It’s an important step toward interoperability.

However, MCP does not address project-level rules or coding conventions. It solves the “how does the agent access external resources” problem, not the “how does the agent know my coding standards” problem. These are complementary concerns, and the rules-file fragmentation remains an unsolved problem in the ecosystem.

What I’d Like to See

Until then, the build-script approach (Strategy 1, Option B) is the most maintainable solution for teams that genuinely use multiple agents.

Conclusion

Future-proofing your repository for AI isn’t about catering to one specific vendor — it’s about making your codebase’s rules and boundaries easily readable by any agent, or human, that comes along. The centralized source of truth pattern works today, even if the tooling hasn’t caught up to make it seamless.

Pick your primary agent, maintain its rules properly, and give the others enough context to be useful. When a cross-agent standard eventually emerges, you’ll be ready to adopt it because your conventions are already documented in one place.

Revision History

Categories: technical, development

About the Author: Michael McGarrah is a Cloud Architect with 25+ years in enterprise infrastructure, machine learning, and system administration. He holds an M.S. in Computer Science (AI/ML) from Georgia Tech and a B.S. in Computer Science from NC State University, and is currently pursuing an Executive MBA at UNC Wilmington. LinkedIn · Substack · GitHub · ORCID · Google Scholar · Resume