# Cross-IDE Portability: AGENTS.md, SKILL.md & Shared MCP

> Write repo instructions, portable SKILL.md playbooks, and MCP server configs once so every developer on your team gets identical agent behavior across Cursor, Claude Code, Codex, Copilot, Windsurf, OpenCode, and Antigravity.

- **Topic:** [AI Code Editors & IDEs](https://twelve-pages.com/topics/ai-ides)
- **Web Edition:** https://twelve-pages.com/guides/ai-ides/cross-ide-agents-md-skills-and-mcp
- **Printable 12-Page PDF:** https://twelve-pages.com/guides/ai-ides/cross-ide-agents-md-skills-and-mcp/Cross_IDE_AGENTS_md_SKILL_md_and_MCP_Complete_How_To_Guide.pdf (981 KB)
- **Version:** v1.0 (Updated 2026-11)
- **Reading Time:** 12 minutes (12 pages)
- **Authorship:** AI-authored under human editorial direction & print QA (https://twelve-pages.com/editorial)
- **Tags:** AGENTS.md (AAIF Standard) · SKILL.md Progressive Disclosure · Shared .mcp.json & HTTP MCP · 7-IDE Compatibility Matrix · Zero-Drift CI Linters · Skill Supply-Chain Security

## Core Takeaways

- **One Canonical Repo Truth:** Maintain a single root AGENTS.md and nested package overrides, backed by thin shims so zero rules are ever duplicated.
- **On-Demand SKILL.md Packs:** Package repeatable workflows into AAIF-governed .agents/skills/ folders with YAML triggers, scripts, and references.
- **Secret-Free Shared MCP:** Unify local stdio and remote Streamable HTTP MCP servers via env-var expansion, OAuth 2.1, and automated client sync.

## 1. Write Once, Run Identically Across Every AI Coding Harness

Modern engineering teams rarely standardize on a single AI IDE: backend engineers run Claude Code or Codex CLI in the terminal, frontend teams use Cursor or Windsurf/Devin, enterprise squads run GitHub Copilot, and open-source or Gemini-native builders use OpenCode and Antigravity. Under the Linux Foundation’s Agentic AI Foundation (AAIF), three open standards—AGENTS.md, SKILL.md, and MCP—now eliminate vendor lock-in.

### Architecture: Single Repo Truth Fanning Out to 7 IDEs & Harnesses

#### 1 Ambient Context

**`AGENTS.md`** is always loaded into session context. Keep it lean (500–2,000 tokens): repo map, build/test commands, non-negotiable invariants.

#### 2 On-Demand Playbooks

**`SKILL.md`** (donated to AAIF Oct 2026) loads only YAML metadata at boot. Multi-step procedures, scripts, and references load only when matched.

#### 3 Live Tool Connectivity

**MCP** connects agents to live databases, issue trackers, and docs. Commit a secret-free `.mcp.json` and inject tokens via env vars or OAuth 2.1.

#### Why the 3-Layer Split Matters in Late 2026

By late 2026, all three standards live under the Linux Foundation's **Agentic AI Foundation (AAIF)**, backed by OpenAI, Anthropic, Google, Microsoft, Block, and Cloudflare. Separating *always-on rules* (`AGENTS.md`) from *lazy-loaded procedures* (`SKILL.md`) and *live APIs* (MCP) cuts baseline prompt bloat by 60–80% while guaranteeing uniform behavior across every developer's chosen IDE.

## 2. Exact File Paths, Precedence & Quirks Across 7 AI Harnesses

Every major coding agent now supports AGENTS.md and the open SKILL.md format, but each harness still has distinct precedence rules, scoped-rule syntax, and MCP config keys. Use this verified late-2026 reference matrix before designing your repo’s portability layer.

| Tool / Harness | Instructions & Precedence | SKILL.md Discovery Paths | MCP Config Path & Key Quirks |
| --- | --- | --- | --- |
| **Claude Code** Thin Shim | 1. `CLAUDE.md` (highest) 2. `AGENTS.md` (native in v2.1.277+ if no `CLAUDE.md`) 3. `.claude/rules/*.md` (`paths:`) | `.claude/skills/` `.agents/skills/` `~/.claude/skills/` (global) | Root `.mcp.json` (key: `mcpServers`, supports `${VAR}` & `${VAR:-default}`). Also reads user `~/.claude.json`. |
| **Cursor** Native | 1. `.cursor/rules/*.mdc` (glob/always) 2. `AGENTS.md` (root & nested) *Legacy `.cursorrules` deprecated* | `.agents/skills/` `.cursor/skills/` `.claude/skills/` (compat) | `.cursor/mcp.json` (key: `mcpServers`, `url` for remote HTTP). Symlink or sync directly from root `.mcp.json`. |
| **GitHub Copilot** Native | 1. `.github/copilot-instructions.md` 2. `AGENTS.md` (root & nested) 3. `.github/instructions/*.instructions.md` (`applyTo:`) | `.agents/skills/` `.github/skills/` `.claude/skills/` (compat) | Root `.mcp.json` (`mcpServers`, Nov 2026 Copilot/VS Code) or `.vscode/mcp.json` (key: `servers` + `${input:...}`). |
| **Codex CLI & Cloud** Native | 1. `AGENTS.override.md` (local) 2. `AGENTS.md` (root -> nested dir chain, deepest wins) | `.agents/skills/` `.codex/skills/` `~/.agents/skills/` | `.codex/config.toml` (TOML `[mcp_servers.<name>]` tables). Generate from canonical `.mcp.json` via sync script. |
| **Windsurf / Devin** Native | 1. `AGENTS.md` (Devin Local & Windsurf) 2. `.windsurf/rules/*.md` *Legacy `.windsurfrules` deprecated* | `.agents/skills/` `.windsurf/skills/` Devin CLI skill loader | `~/.codeium/windsurf/mcp_config.json` (`mcpServers`, uses **`serverUrl`** instead of `url` for remote HTTP). |
| **OpenCode** Native | 1. `AGENTS.md` (primary) 2. `CLAUDE.md` (automatic fallback if `AGENTS.md` absent) | `.agents/skills/` `.opencode/skills/` `~/.config/opencode/skills/` | Root `opencode.json` (key: `mcp`, uses `type: "local" \| "remote"` and `command: [...]` array). Sync from `.mcp.json`. |
| **Antigravity** Native | 1. `AGENTS.md` (workspace) 2. `.agents/rules/` (glob/always) 3. `~/.gemini/GEMINI.md` (global) | `.agents/skills/` (workspace) `~/.agent/skills/` (global) | Root `.mcp.json` / Antigravity MCP config (key: `mcpServers`, native stdio & Streamable HTTP + OAuth). |

#### ! The Universal Convergence Path

Notice the clear convergence across all seven harnesses in late 2026:

- **Instructions:** `AGENTS.md` at root + nested package dirs.
- **Skills:** `.agents/skills/<skill-name>/SKILL.md` is now read natively by all 7 tools (zero symlink needed for skills!).
- **MCP:** Root `.mcp.json` with `mcpServers` is the de facto canonical source, with thin generated targets only for TOML/schema outliers (Codex, OpenCode, Windsurf).

#### ? Precedence Gotchas to Watch

- **Claude Code shadow:** If a stale `CLAUDE.md` exists alongside `AGENTS.md`, Claude Code prioritizes `CLAUDE.md`. Fix: replace `CLAUDE.md` with a 1-line `@AGENTS.md` import or symlink.
- **Copilot double-loading:** If both `.github/copilot-instructions.md` and `AGENTS.md` contain full rules, Copilot injects both and wastes context.
- **Windsurf `serverUrl`:** Copying a remote MCP block with `"url"` into Windsurf silently fails unless mapped to `"serverUrl"`.

#### Rule of Thumb: Canonical Standards First, Adapter Shims Second

Never author business logic or coding standards inside tool-specific directories (`.cursor/rules/`, `.windsurf/rules/`, `.github/copilot-instructions.md`). Keep 100% of team knowledge in `AGENTS.md`, `.agents/skills/`, and `.mcp.json`, and treat tool-specific files strictly as thin pointers or CI-generated projections.

## 3. Inside a Multi-Agent-Ready Monorepo (7-Control HUD)

A portable repository looks boring on purpose. Every harness finds its expected entry point immediately, while human maintainers only ever edit three canonical locations. Explore the 7-pin layout below to see how symlinks and thin wrappers bridge all seven IDEs.

acme-platform/ — Multi-Agent Monorepo Layout

AAIF Compliant 7 IDEs Synced Zero Secrets

acme-platform/

├── **AGENTS.md** # Root source (<1.5k tok)

├── **CLAUDE.md** # 1-line @AGENTS.md shim

├── **.mcp.json** # Canonical MCP (env vars)

├── **.agents/**

│ └── **skills/**

│ ├── db-migration/

│ │ ├── SKILL.md

│ │ ├── scripts/verify_sql.py

│ │ └── references/schema.md

│ └── release-notes/SKILL.md

├── **.cursor/**

│ ├── mcp.json -> ../.mcp.json

│ └── rules/ui-tokens.mdc # Glob only

├── **.github/**

│ ├── CODEOWNERS

│ └── workflows/agent-lint.yml

├── **packages/**

│ ├── api/**AGENTS.md** # Go/SQL delta

│ └── web/**AGENTS.md** # React/a11y delta

└── scripts/sync-mcp-clients.mjs

SYMLINK VS. THIN-SHIM MATRIX

• **Windows-safe?** Use 1-line text shims (`@AGENTS.md`) instead of OS symlinks if any contributor develops on Windows without Developer Mode.

• **macOS / Linux?** Git symlinks (`ln -s AGENTS.md CLAUDE.md`) work cleanly across CI and containers.

GENERATED CLIENT PROJECTIONS (.gitignore or CI)

`.mcp.json` -> `.cursor/mcp.json` (symlink)

`.mcp.json` -> `.codex/config.toml` (script)

`.mcp.json` -> `opencode.json` (script)

`.mcp.json` -> `mcp_config.json` (`url→serverUrl`)

NEVER COMMIT THESE FILES

• `AGENTS.override.md` & `CLAUDE.local.md`

• `.env`, `.mcp.local.json`, OAuth token caches

• Unpinned third-party skill binaries

### Control-by-Control Breakdown (Pins 1–7)

**Root `AGENTS.md`:** Canonical architecture map, exact test/lint commands, branch naming, and repo-wide invariants. Read natively by all 7 harnesses.

**Thin `CLAUDE.md` Shim:** Contains only `@AGENTS.md` (Claude Code native file import). Guarantees older/enterprise Claude Code builds never miss root rules.

**Canonical `.mcp.json`:** Declares shared team MCP servers with `${ENV_VAR}` placeholders and remote Streamable HTTP URLs. Zero plaintext API keys.

**`.agents/skills/` Vault:** AAIF-standard directory auto-discovered by Claude Code, Cursor, Copilot, Codex, Windsurf/Devin, OpenCode, and Antigravity.

**Glob-Only IDE Extensions:** Keep `.cursor/rules/*.mdc` or `.claude/rules/*.md` strictly for file-pattern-triggered micro-rules that cannot be expressed by directory nesting.

**`CODEOWNERS` & CI Gate:** Route edits to `AGENTS.md`, `.agents/skills/`, and `.mcp.json` through Staff/Security review and run automated token + schema linters.

**Nested Package `AGENTS.md`:** Sub-directory deltas (e.g., `packages/api/AGENTS.md`) load *only* when an agent edits files inside that package, keeping root context small.

## 4. Hierarchical AGENTS.md & Thin-Shim Patterns

Think of README.md as onboarding for humans and AGENTS.md as an executable contract for machines. In a monorepo, stuffing every framework quirk into the root file degrades agent accuracy. Instead, pair a lean root contract with directory-scoped child AGENTS.md files.

*[Illustration: Isometric hierarchical architecture showing a glowing slate-blue root foundation branching via emerald and sapphire conduits into modular glass package nodes]*

**Hierarchical Inheritance:** Root `AGENTS.md` defines universal invariants; child files in `packages/api/` or `apps/web/` add local commands and overrides only when the agent enters that subtree.

#### A The 6 Mandatory Root Sections

1. **Repo Map (5–8 lines):** Top-level directories and what owns what.
2. **Exact Commands:** Copy-pasteable `install`, `typecheck`, `test`, and `lint` commands (prefer single-file test flags).
3. **Architecture Invariants:** Hard boundaries (e.g., "Never import `db/` from `ui/`").
4. **Code & Style Rules:** Only rules your linter *cannot* enforce automatically.
5. **PR & Verification Gate:** Exact checks the agent must pass before finishing.
6. **Pointer Index:** Links to `.agents/skills/` and deep docs (never inline them).

#### B Nested Monorepo Overrides

When an agent opens `packages/payments/ledger.ts`, harnesses walk upward from the file to the repo root, merging context with **nearest-file precedence**:

```
<code># packages/payments/AGENTS.md (Delta Only)
## Local Commands
- Test single file: `pnpm <span class="nowrap">--filter</span> payments test <file>`
## Non-Negotiable Rules
- Use integer cents (`bigint`); NEVER use JS `number` floats.
- All ledger mutations require an idempotency key header.</code>
```

Result: Frontend engineers editing `apps/web/` never pay the token cost of payments rules.

### Thin-Shim Blueprint (Zero Duplication Across Legacy & Enterprise Clients)

#### Claude Code (`CLAUDE.md`)

```
<code>@AGENTS.md
# Claude-specific hooks only:
# Run `/compact` after 40 turns.</code>
```

#### Copilot (`.github/copilot-instructions.md`)

```
<code>Read and strictly follow the root
`AGENTS.md` and nearest nested
`AGENTS.md` for all repo rules.</code>
```

#### Cursor (`.cursor/rules/sql.mdc`)

```
<code>---
globs: ["**/*.sql"]
---
Follow `packages/db/AGENTS.md`.</code>
```

#### Executable Specs Beat Wishlists

Replace vague prose ("Write clean, well-tested TypeScript") with deterministic commands ("Run `pnpm vitest run path/to/test.ts` and `pnpm tsc --noEmit`; zero warnings allowed"). Agents verify concrete commands 3–4&times; more reliably than stylistic adjectives.

## 5. The SKILL.md Progressive-Disclosure Formula

Donated to the Linux Foundation’s AAIF in October 2026 and supported by 70+ platforms (Claude Code, Codex, Cursor, Copilot, Windsurf/Devin, OpenCode, Antigravity), Agent Skills solve context bloat via 3-tier progressive disclosure: agents see only a 2-line YAML summary at boot, loading full instructions and helper scripts only when a task matches.

### Color-Coded 5-Part `SKILL.md` Anatomy

---

name: safe-db-migration

description: Generate and verify zero-downtime Postgres migrations. Use whenever creating, altering, or rolling back SQL schema files in packages/db/migrations/.

---

# Workflow: Zero-Downtime Migration

1. Inspect `packages/db/schema.sql` and draft an expand-and-contract migration file.

2. Generate both `up.sql` and reversible `down.sql` with timestamp prefix.

3. Execute `python3 scripts/check_locks.py <migration.sql>` to verify zero table-locking DDL.

4. Consult `references/postgres-lock-matrix.md` before adding NOT NULL or concurrent indexes.

## Guardrails: NEVER run `DROP COLUMN` in the same PR as app code removal. Stop and ask for human approval if estimated lock time > 200ms.

#### 1. YAML Trigger

Only `name` (lowercase kebab-case) and `description` are universally portable. Write **trigger-rich descriptions** naming exact file paths and intents.

#### 2. Workflow Steps

Numbered, imperative steps (<300 lines). Each step produces a verifiable artifact or state transition before moving to the next.

#### 3. scripts/

Deterministic Python/Bash/Node validators bundled inside the skill folder. Offload brittle regex/schema checks from the LLM to code.

#### 4. references/

Deep domain docs, API schemas, or checklists kept in sibling markdown files. Loaded *only* when the agent reaches that step—never bloating the core prompt.

#### 5. Guardrails & Stop Conditions

Explicit "NEVER" rules and human-in-the-loop escalation triggers. Prevents autonomous agents from executing destructive commands.

### 3-Tier Progressive Disclosure & Portability Rules

| Loading Tier | What Loads Into Context | Token Cost | Cross-IDE Portability Note |
| --- | --- | --- | --- |
| **Tier 1: Boot** | YAML `name` + `description` | ~30–60 tok / skill | Always visible in system prompt. Keep `description` under 250 chars for clean matching. |
| **Tier 2: Trigger** | Full `SKILL.md` body | ~400–1,800 tok | Triggered by intent match or explicit `/skill-name`. Avoid tool-only frontmatter like `context: fork` unless optional. |
| **Tier 3: Execution** | `scripts/`, `references/`, `assets/` | 0 tok until read/run | Use relative paths from the skill folder. Scripts must use standard runtimes (`python3`, `node`, `bash`). |

#### Portability Trap: Tool-Specific Frontmatter Extensions

Claude Code supports optional fields like `allowed-tools`, `model`, and `context: fork`, while Codex CLI ignores unknown keys and does not load legacy plugin commands. Stick to `name` and `description` for core behavior, and treat vendor extensions strictly as progressive enhancements.

## 6. Shared MCP Configs, Streamable HTTP & Secret Hygiene

The Model Context Protocol (MCP) gives every IDE identical live access to GitHub, Postgres, Linear, Sentry, and internal docs. The #1 cross-IDE friction point in 2026 is not MCP itself—it is divergent client config schemas and hardcoded API tokens accidentally pushed to git.

### Canonical Secret-Free `.mcp.json`

```
<code>{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/",
      "headers": {
        "Authorization": "Bearer ${GITHUB_MCP_TOKEN}"
      }
    },
    "postgres-ro": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres@0.6.2"],
      "env": {
        "POSTGRES_URL": "${DEV_PG_READONLY_URL}"
      }
    },
    "context-docs": {
      "type": "http",
      "url": "https://mcp.internal.acme.dev/v1"
    }
  }
}</code>
```

### Local `stdio` vs. Remote Streamable HTTP

| Dimension | Local `stdio` | Streamable HTTP |
| --- | --- | --- |
| **Auth Model** | Local env vars / CLI creds | OAuth 2.1 / SSO + Bearer |
| **Onboarding** | Needs Node/Python/Docker | Zero local install (URL only) |
| **Audit & RBAC** | Per-laptop; hard to revoke | Central gateway & logs |
| **Best For** | Local DBs, filesystem, git | Jira, GitHub, Sentry, prod docs |

#### 2026 Shift: Remote Streamable HTTP + OAuth 2.1

Prefer hosted **Streamable HTTP** MCP servers over local `stdio` wrappers for SaaS tools. Developers authenticate via browser OAuth 2.1—meaning zero static API tokens ever touch laptops or config files.

### Bridging Client Schema Differences Without Manual Duplication

| Client | Config File | Root Key | Schema Delta & Sync Strategy |
| --- | --- | --- | --- |
| **Claude Code / Antigravity** | `.mcp.json` | `mcpServers` | Canonical source! Native `${VAR}` and `${VAR:-fallback}` expansion. |
| **Cursor** | `.cursor/mcp.json` | `mcpServers` | Symlink directly to `../.mcp.json` (identical JSON schema). |
| **VS Code / Copilot** | `.mcp.json` or `.vscode/mcp.json` | `mcpServers` / `servers` | Late-2026 Copilot reads root `.mcp.json`; use `.vscode/mcp.json` only if you need interactive `${input:token}` prompts. |
| **Codex CLI** | `.codex/config.toml` | `[mcp_servers.*]` | Run `pnpm mcp:sync` to emit TOML from `.mcp.json` (auto-checked in CI). |
| **Windsurf / OpenCode** | `mcp_config.json` / `opencode.json` | `mcpServers` / `mcp` | Sync script maps `url → serverUrl` (Windsurf) and `type: "remote"` (OpenCode). |

#### ! 4 Rules of MCP Secret Hygiene

- **Zero hardcoded keys:** Commit `.env.example` with blank vars; load real values via `direnv`, 1Password CLI, or OAuth 2.1.
- **Pin versions:** Always pin `npx -y pkg@x.y.z` or Docker digests to block supply-chain hijacks.
- **Read-only by default:** Bind dev MCP DB credentials to a read-only Postgres role.
- **Pre-commit secret scan:** Run `gitleaks` on `.mcp.json` and all generated client configs.

#### i Watch the Tool-Count Ceiling

Connecting 10+ MCP servers can inject 150–300 tool schemas into every turn, degrading tool selection accuracy and hitting client caps (e.g., VS Code's 128-tool limit).

**Fix:** Cap workspace `.mcp.json` at **3–5 high-signal servers** (or use an MCP gateway/router that filters toolsets per role).

## 7. Stopping Instruction Drift & Context Bloat With CI Linters

Instruction files decay faster than code. Every time an engineer patches a bug by appending “NEVER do X” to CLAUDE.md without updating AGENTS.md, or dumps a 4,000-token style guide into the root prompt, agent compliance drops sharply. Treat agent instructions like production code: budget them, lint them, and prune them in CI.

*[Illustration: Precision optical calibration prism and metallic architectural gate refining tangled ribbons into three parallel glowing emerald, sapphire, and coral streams]*

**Continuous Calibration:** Automated CI gates filter ad-hoc developer notes into lean `AGENTS.md` contracts, modular `SKILL.md` playbooks, and schema-verified MCP configs.

### Context Token Budgets (Empirical Sweet Spots)

| Artifact | Target Budget | CI Hard Cap | Overflow Action (When Cap Is Hit) |
| --- | --- | --- | --- |
| **Root `AGENTS.md`** | 500–1,500 tok | 2,000 tok (~150 lines) | Move step-by-step workflows to `.agents/skills/`; move pkg rules to nested `AGENTS.md`. |
| **Nested `AGENTS.md`** | 150–500 tok | 800 tok (~60 lines) | Delete rules already enforced by ESLint/Ruff/Go vet; link to `docs/`. |
| **`SKILL.md` Frontmatter** | 25–50 tok | 75 tok (&le;250 chars) | Tighten `description` to crisp trigger verbs + exact target paths. |
| **`SKILL.md` Body** | 400–1,200 tok | 2,500 tok (~300 lines) | Extract reference tables into `references/` and validators into `scripts/`. |

#### &times; Top 4 Drift Anti-Patterns

- **Copy-Paste Syncing:** Duplicating prose across `AGENTS.md`, `CLAUDE.md`, and `.cursor/rules/` guarantees divergence within 2 weeks.
- **Linter Duplication:** Listing Prettier/ESLint formatting rules in Markdown wastes tokens and triggers contradictions.
- **Stale Commands:** Leaving old `npm run test:old` commands causes every agent to burn 3+ turns failing before guessing.
- **Tombstone Accumulation:** Never deleting rules for deprecated frameworks creates contradictory instructions.

#### &check; 5 Automated CI Lint Checks

1. **Token Cap Check:** Fail PR if root `AGENTS.md` exceeds 2,000 tokens or 150 lines.
2. **Shim Integrity:** Assert `CLAUDE.md` is either a symlink or &le;5 lines containing `@AGENTS.md`.
3. **SKILL.md Schema:** Validate YAML frontmatter (`name` matches folder, `description` present, no unreferenced scripts).
4. **Dead Path Check:** Verify every backticked path/script mentioned in `AGENTS.md` exists in git.
5. **MCP Sync & Secret Check:** Assert generated configs match `.mcp.json` and contain zero raw tokens.

## 8. 5 Copy-Paste Portability Recipes Ready for Production

Drop these five battle-tested templates directly into any repository to achieve immediate cross-IDE parity across Cursor, Claude Code, Codex, Copilot, Windsurf/Devin, OpenCode, and Antigravity.

| # | Recipe | File Path | Problem Solved |
| --- | --- | --- | --- |
| **1** | Lean Root Contract | `AGENTS.md` | Gives all 7 harnesses identical build, test, and boundary rules. |
| **2** | Zero-Drift Claude Shim | `CLAUDE.md` | Prevents Claude Code from shadowing or missing `AGENTS.md`. |
| **3** | Portable PR Review Skill | `.agents/skills/pr-review/SKILL.md` | On-demand security & diff review playbook with deterministic script. |
| **4** | Client MCP Sync Script | `scripts/sync-mcp.mjs` | Generates Codex TOML & Windsurf `serverUrl` from `.mcp.json`. |
| **5** | GitHub Actions Lint Gate | `.github/workflows/agent-lint.yml` | Blocks bloated rules, broken YAML, or unpinned MCP servers in PRs. |

Recipe 1: Lean Root `AGENTS.md`

```
<code># AGENTS.md — Acme Platform
## Repo Map
- `apps/web/`: Next.js 16 frontend (pnpm)
- `packages/api/`: Go 1.24 REST/gRPC services
- `packages/db/`: SQL migrations (see local AGENTS.md)

## Verification Commands (Run Before Finishing)
- Typecheck: `pnpm -r typecheck`
- Fast unit test: `pnpm <span class="nowrap">--filter</span> <pkg> test <file>`
- Go check: `cd packages/api && go test ./...`

## Hard Invariants
- Never commit secrets or edit `.env*` files.
- Never bypass ESLint/golangci-lint with ignore comments.
- Use `.agents/skills/` for migrations & release notes.</code>
```

Recipe 2: Thin `CLAUDE.md` Shim

```
<code>@AGENTS.md

<!-- Keep all shared rules in AGENTS.md.
     Only Claude-specific local hooks belong below. --></code>
```

Recipe 3: Portable `SKILL.md`

```
<code>---
name: pr-readiness-check
description: Audit staged diffs for security leaks, missing tests, and breaking API changes before opening a PR.
---
# PR Readiness Check
1. Run `git diff <span class="nowrap">--staged</span> <span class="nowrap">--stat</span>` to list touched packages.
2. Execute `python3 scripts/scan_diff.py` for secret/TODO checks.
3. Verify each modified module has a passing targeted test.
4. Summarize risks in 3 bullets; NEVER auto-push to `main`.</code>
```

Recipe 4: `scripts/sync-mcp.mjs` (Excerpt)

```
<code>import fs from "node:fs";
const cfg = JSON.parse(fs.readFileSync(".mcp.json", "utf8"));
// 1. Emit Codex .codex/config.toml
const toml = Object.entries(cfg.mcpServers).map(([k, v]) => {
  const lines = [`[mcp_servers.${k}]`];
  if (v.url) lines.push(`url = "${v.url}"`);
  if (v.command) lines.push(`command = "${v.command}"`);
  if (v.args) lines.push(`args = ${JSON.stringify(v.args)}`);
  return lines.join("\n");
}).join("\n\n");
fs.mkdirSync(".codex", { recursive: true });
fs.writeFileSync(".codex/config.toml", toml + "\n");</code>
```

Recipe 5: `.github/workflows/agent-lint.yml`

```
<code>name: Agent Portability Lint
on: [pull_request]
jobs:
  lint-agent-config:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Enforce AGENTS.md line cap (<=150)
        run: test "$(wc -l < AGENTS.md)" -le 150
      - name: Verify CLAUDE.md thin shim
        run: grep -q "@AGENTS.md" CLAUDE.md && test "$(wc -l < CLAUDE.md)" -le 8
      - name: Validate SKILL.md YAML frontmatter
        run: |
          python3 -c '
          import glob, yaml
          for f in glob.glob(".agents/skills/*/SKILL.md"):
            fm = yaml.safe_load(open(f).read().split("---")[1])
            assert fm.get("name") and len(fm.get("description","")) <= 250, f
          '
      - name: Check MCP sync & no raw secrets
        run: |
          node scripts/sync-mcp.mjs && git diff <span class="nowrap">--exit-code</span> .codex/config.toml
          ! grep -E "(sk-|ghp_|xoxb-)" .mcp.json</code>
```

## 9. Securing AGENTS.md, Third-Party Skills & MCP Tools

Because every AI coding agent treats AGENTS.md and SKILL.md as trusted system instructions—and executes bundled scripts/ with developer privileges—agent configs are now a Tier-1 supply-chain attack surface. A single poisoned community skill can exfiltrate ~/.ssh or .env secrets across all seven IDEs simultaneously.

#### 1 Indirect Prompt Injection

Hidden Unicode (zero-width chars), HTML comments, or obfuscated base64 strings inside third-party `SKILL.md` or `references/` files can instruct agents to curl secrets to attacker domains.

#### 2 Rug-Pull Skill Scripts

Installing unpinned skills via `git pull` or floating `npx -y pkg@latest` lets a compromised upstream maintainer inject malicious shell payloads overnight.

#### 3 Over-Privileged MCP

Granting write/admin tokens to MCP servers (or combining untrusted web-fetch MCP with local shell execution) creates a lethal "confused deputy" exfiltration path.

### Mandatory Team Governance Controls

| Control Layer | Implementation Standard | Verification Mechanism |
| --- | --- | --- |
| **`CODEOWNERS` Review** | Require Staff Engineer + AppSec approval on `AGENTS.md`, `.agents/skills/**`, and `.mcp.json`. | GitHub Branch Protection "Require review from Code Owners" enforced on `main`. |
| **Vendor & Pin Skills** | Copy audited third-party skills into your repo's `.agents/skills/` (or internal private registry) pinned to a commit SHA. | CI rejects dynamic runtime skill fetchers and logs SHA provenance in `SKILL_LOCK.json`. |
| **Static Injection Scan** | Reject invisible Unicode (`U+200B..U+200F`, bidi overrides), base64 blobs, and unapproved egress domains in Markdown/scripts. | Pre-commit & CI regex/AST scanner across all `*.md` and `.agents/skills/*/scripts/*`. |
| **Least-Privilege Tools** | Scope MCP credentials to read-only or staging; restrict destructive shell commands via harness allowlists/sandboxes. | Quarterly token audit + OAuth 2.1 short-lived tokens via central MCP gateway. |

#### `.github/CODEOWNERS` Rule Block

```
<code># Agent instructions & executable skills require dual review
/AGENTS.md                  @org/platform-eng @org/appsec
/**/AGENTS.md               @org/platform-eng
/CLAUDE.md                  @org/platform-eng
/.mcp.json                  @org/platform-eng @org/appsec
/.agents/skills/            @org/platform-eng @org/appsec
/.cursor/rules/             @org/platform-eng</code>
```

#### &check; 5-Minute Third-Party Skill Audit

1. Read *every line* of `SKILL.md` and `references/` in raw text (inspect for HTML comments or hidden Unicode).
2. Inspect all files in `scripts/` for network calls (`curl`, `fetch`, `requests`) and env access (`os.environ`).
3. Check whether the skill requests disabling safety hooks or auto-approving shell commands.
4. Test the skill inside a disposable sandbox container with dummy credentials before merging.

#### Security Golden Rule: Treat `SKILL.md` as Executable Code

Never merge a community skill PR the way you merge documentation. A malicious instruction in Markdown can hijack an autonomous agent just as effectively as a malicious line of Python.

## 10. One Git Commit → CI Gate → Identical Behavior in 7 IDEs

When AGENTS.md, .agents/skills/, and .mcp.json flow through a single Git + CI pipeline, onboarding a new engineer or rolling out a new architectural rule takes one pull request—and instantly upgrades every local IDE and cloud coding agent simultaneously.

### 4-Week Team Migration Playbook (From Fragmented Rules to AAIF Parity)

#### W1 Audit & Consolidate

Inventory every `.cursorrules`, `CLAUDE.md`, `.windsurfrules`, and wiki doc. Distill only verified commands and invariants into a root `AGENTS.md` under 1,500 tokens. Replace old files with thin shims.

#### W2 Extract Top 3 Workflows to Skills

Move verbose procedures (DB migrations, PR review, service scaffolding) out of `AGENTS.md` into `.agents/skills/*/SKILL.md` with deterministic Python/Node validation scripts.

#### W3 Unify MCP & Kill Plaintext Keys

Create canonical `.mcp.json` with Streamable HTTP + OAuth 2.1 for SaaS tools and `${VAR}` for local stdio servers. Wire up `scripts/sync-mcp.mjs` and symlink `.cursor/mcp.json`.

#### W4 Enforce CI Gates & Run Parity Eval

Enable `agent-lint.yml` and `CODEOWNERS`. Run one identical benchmark ticket across two different team IDEs (e.g., Cursor + Claude Code) and verify both run the exact same test command and pass CI.

#### Bonus Win: Cloud Coding Agents Get Upgraded for Free

Autonomous background agents—GitHub Copilot Coding Agent, OpenAI Codex Cloud, Devin, and Google Jules—all clone your repository and read root/nested `AGENTS.md` plus `.agents/skills/` automatically. Local portability directly doubles your cloud-agent PR acceptance rate.

## 11. Troubleshooting Clinic (Top 7 Fixes) & Pre-Flight Check

When an agent ignores a rule, misses a skill, or fails to boot an MCP server, the cause is almost always one of these seven deterministic configuration bugs.

| # | Symptom | Root Cause | Exact Fix |
| --- | --- | --- | --- |
| **1** | Claude Code ignores `AGENTS.md` | Older build (<v2.1.277), disabled plugin, or stale `CLAUDE.md` shadowing it. | Keep a 1-line `CLAUDE.md` containing `@AGENTS.md` and verify *Project instructions* in `/config`. |
| **2** | `SKILL.md` never auto-triggers | Vague `description` in YAML frontmatter or folder name mismatch. | Match folder name to YAML `name`; add explicit trigger verbs & target paths in `description`. |
| **3** | Windows dev sees broken symlink | Git symlinks checked out as plain text files without Windows Developer Mode. | Replace symlinks with 1-line text shims (`@AGENTS.md`) or run `scripts/sync-mcp.mjs` via `postinstall`. |
| **4** | Windsurf remote MCP silently fails | Config uses `"url"` instead of Windsurf's `"serverUrl"` key. | Map `url → serverUrl` in your MCP sync script when emitting Windsurf's `mcp_config.json`. |
| **5** | Agent hallucinates old commands | Root `AGENTS.md` exceeds 2,500 tokens or retains outdated scripts. | Prune root `AGENTS.md` under 1,500 tokens and add a CI dead-command check. |
| **6** | MCP tool calls degrade or hit cap | 10+ servers enabled globally, injecting 150+ schemas (hits VS Code 128 cap). | Trim workspace `.mcp.json` to 3–5 core servers or route through a scoped MCP gateway. |
| **7** | Agent violates nested package rule | Rule lives only in root `.cursor/rules/` instead of package `AGENTS.md`. | Move package-specific invariants to `packages/<pkg>/AGENTS.md` so all 7 harnesses inherit them. |

### 6-Point Cross-IDE Pre-Flight Checklist

&check;

**1. Lean Canonical `AGENTS.md`:** Under 1,500 tokens at repo root, with exact single-file test/lint commands and nested package deltas.

&check;

**2. Zero-Duplication Shims:** `CLAUDE.md` imports `@AGENTS.md`; legacy `.cursorrules` and `.windsurfrules` deleted.

&check;

**3. AAIF `.agents/skills/` Layout:** Repeatable workflows packaged with crisp YAML triggers, `scripts/`, and `references/`.

&check;

**4. Secret-Free `.mcp.json`:** Pinned package versions, Streamable HTTP + OAuth 2.1 where available, `${ENV_VAR}` placeholders only.

&check;

**5. CI Lint & `CODEOWNERS` Active:** Token caps, YAML validation, MCP client sync, and secret scanning block broken PRs automatically.

&check;

**6. Two-IDE Smoke Test Passed:** Same feature prompt verified in at least two distinct harnesses (e.g., Cursor + Claude Code or Codex).

#### Final Takeaway: Invest in Portable Repo Architecture, Not IDE Lock-In

Models and editors will keep leapfrogging every quarter. Teams that encode their engineering judgment in AAIF open standards—`AGENTS.md`, `SKILL.md`, and secret-free MCP—can adopt tomorrow's best coding harness in five minutes without rewriting a single rule.

---

## Edition Note & Attribution

This 12-page handbook, its topic structure, and its illustrations were generated with AI under human editorial direction and print-layout QA. Verify commands, pricing tiers, and security settings against official vendor documentation before production use.

- AI & Editorial Disclosure: https://twelve-pages.com/editorial
- Terms & Licensing: https://twelve-pages.com/terms
- Privacy & Cookie Notice: https://twelve-pages.com/privacy
