Copilot & AGENTS Optimizer Skill
When to use
Use this skill when:
- Running
/docs-optimize to refactor AGENTS.md and copilot-instructions.md
- Adding new content to either file and needing to check if it belongs there
- After changes to
.augment/ (new skills, rules, guidelines) that may make content in these files redundant
- When either file exceeds the line budget
Do NOT use when:
- Writing application code
- Creating new skills or commands
Procedure: Optimize copilot/agents files
0. Analyze current state
Before changing anything, read and understand:
- Read
AGENTS.md — current content, line count, what's duplicated vs. unique.
- Read
.github/copilot-instructions.md — same analysis.
- Scan
.augment/ — which skills, rules, and guidelines already cover topics from the files above.
3b. Scan the playbooks too, not only .augment/. A packages/<n>/AGENTS.md may
duplicate a playbook rather than a shipped rule, and dedup against .augment/ alone
misses it entirely — the content is not in .augment/ at all. Run
findRestatedSteps (src/scripts/derive_playbooks.ts) over each workspace file: a line
carrying a playbook's invokes id outside a link is a restatement to replace with a
pointer. The same id inside a link label is the shape the contract wants — see
agents-md-thin-root § Workspace files.
- Identify duplication — what content exists in both AGENTS.md and
.augment/?
Only after this analysis, proceed with optimization.
AGENTS.md — Project Entry Point for AI Agents
| Property |
Value |
| Audience |
Augment Agent, other AI agents |
Can read .augment/? |
✅ Yes — can follow references |
| Size budget |
≤ 3,000 chars (package root; consumer template ≤ 2,500) — enforced by lint_agents_md.ts; see size-and-scope.md |
| Purpose |
Project-specific setup, Docker, testing, quality tools |
What belongs here:
- Tech stack and framework versions
- Development setup (Docker, Make targets, env files)
- Database and multi-tenancy setup
- Testing framework, suites, and conventions
- Quality tool commands (PHPStan, Rector, ECS)
- Project structure overview (brief, link to module docs)
- Agent infrastructure overview (layer table, key references)
What does NOT belong here:
- Coding standards (→
.augment/rules/ and .augment/guidelines/)
- Architecture principles like SOLID, KISS, DRY (→
.augment/rules/architecture.md)
- PHP conventions (→
../../../docs/guidelines/php/)
- Scope control rules (→
.augment/rules/scope-control.md)
- Language/tone rules (→
.augment/rules/language-and-tone.md)
- Detailed module documentation (→
app/Modules/README.md)
.github/copilot-instructions.md — Self-Contained for Copilot
| Property |
Value |
| Audience |
GitHub Copilot (Code Review bot + Chat) |
Can read .augment/? |
❌ Code Review cannot, ✅ Chat can |
| Line budget |
< 150 lines (ideal < 60); Copilot Code Review reads only the first 4,000 chars |
| Purpose |
Coding standards, review rules, architecture constraints |
What belongs here:
- Architecture rules (thin controllers, service layer, policies)
- PHP 8.2 patterns (readonly, final, enums — with exceptions)
- Project-specific conventions (custom helpers, environment config, naming)
- Code review scope and comment behavior rules
- Language rules (English comments, bilingual PR comments)
- Known issues / false positives that Copilot should avoid
- Package management rules
What does NOT belong here:
- Docker setup or Make targets (Copilot doesn't run commands)
- Testing setup details (Copilot doesn't run tests)
- Agent infrastructure (Copilot doesn't use agents/)
- Things auto-enforced by ECS/Rector (code style, formatting, trailing commas)
- Detailed pattern documentation (too long, Copilot needs concise rules)
Deduplication Strategy
Rule: Content lives in ONE canonical place
.augment/rules/ ← Canonical for behavior rules
.augment/guidelines/ ← Canonical for coding conventions
.augment/skills/ ← Canonical for domain expertise
agents/ ← Canonical for project-specific docs
When duplication is acceptable
copilot-instructions.md must duplicate essential rules because Copilot Code Review
cannot read other files. But keep duplicated content:
- Concise — one-liner summaries, not full explanations
- Focused — only what Copilot needs for code suggestions and PR reviews
- Stable — rules that rarely change (architecture, naming, key conventions)
When duplication is NOT acceptable
AGENTS.md should never duplicate .augment/ content because Augment Agent can read
both. Instead, reference with a table:
| What | Where |
|---|---|
| PHP coding rules | `.augment/rules/php-coding.md` |
| Controller guidelines | `../../../docs/guidelines/php/controllers.md` |
Line Budget Enforcement
| File |
🟢 Good |
🟡 Warning |
🔴 Over budget |
AGENTS.md |
≤ 2,800 chars |
2,801–3,000 chars |
> 3,000 chars — lint_agents_md.ts fails (consumer template: warn 2,300 / fail 2,500) |
copilot-instructions.md |
< 60 lines |
60–150 lines |
> 150 lines, or key rules past the 4,000-char Copilot read window |
Reduction strategies (when over budget)
- Extract to
agents/ — Move project-specific details to dedicated files in agents/
and link from AGENTS.md (e.g., agents/reference/docs/database-setup.md, agents/reference/docs/testing.md)
- Remove duplicates — If content exists in
.augment/, remove from AGENTS.md
- Condense — Turn verbose explanations into concise tables or bullet points
- Remove ECS/Rector-enforced rules — From copilot-instructions.md (auto-fixed anyway)
- Move examples to guidelines — Detailed code examples belong in
.augment/guidelines/
Portability and Stack Coherence
Duplication is not the only way these files go wrong. They also lie
about the project over time:
- Legacy identifiers — references to a former repo name, a sibling
project in the same monorepo, or content that was copied from another
codebase as a starting template and never adapted.
- Stack drift — the file claims "Laravel 11 + MariaDB" but the repo
was converted to a Python library; or it names Docker services that
no longer exist.
- Dead commands —
make start in the docs, but Makefile no
longer has that target.
Before deduplicating, run three scans:
- Legacy identifier scan — compare both files against the package's
FORBIDDEN_IDENTIFIERS blocklist (see scripts/check_portability.ts)
plus any project names from agents/ module docs that don't match
the current project.
- Stack coherence scan — auto-detect the actual stack from
composer.json / package.json / pyproject.toml / etc. and flag
any claim that no longer matches reality.
- Dead-command scan — verify every
make X, task X, composer X,
php artisan X, or npm X still resolves.
Every hit from scan 1 is a 🔴 blocker: leaking another project's name
into a consumer's own docs is the failure mode this skill exists to
prevent. Fix or remove those BEFORE any dedup/condense work — there's
no point deduplicating content that is about to be rewritten.
When the drift is severe (whole sections are wrong), recommend
/agents init to scaffold a clean replacement rather than
patching forever.
agent-config Path Conventions — Preserve, Don't "Fix"
copilot-instructions.md ships a "Known False Positives" section that
tells Copilot Code Review not to flag agent-config path patterns as
broken. When optimizing, keep that section intact — never delete
it as "redundant" and never trim its bullets. The patterns it covers:
- Relative cross-references inside
.augment/ rules / skills
(../docs/guidelines/foo.md, ../contexts/bar.md) — paths resolve
from the file's delivered location, not from the symlink in
.claude/rules/ etc. (per road-to-path-fixes.md Strategy A).
path_prefix: triggers containing src/ —
literal match patterns, not file refs (per Modified Option 1,
P2.2).
- Symlinked rule files under
.claude/rules/, .cursor/rules/,
.clinerules/ — targets resolve into .augment/rules/.
If the consumer project's copilot-instructions.md is missing the
section, add it during optimization using the canonical block
from .augment/templates/copilot-instructions.md. Surfaces include
/agents init and /agents optimize.
Optimization Checklist
When optimizing either file, check:
Related
- Command:
/agents optimize
- Skill:
copilot-config — Copilot behavior and PR review patterns
- Skill:
agent-docs-writing — documentation hierarchy
- Context:
augment-infrastructure.md — full .augment/ overview
Output format
- Optimized file(s) with deduplication applied and line budget respected
- Summary of what was removed, moved, or consolidated
- Line count before/after for each file
Gotcha
- AGENTS.md is read by GitHub Copilot and other tools — changes affect all AI assistants, not just Augment.
- Don't remove content from AGENTS.md that other tools depend on — verify cross-tool compatibility first.
- The model tends to over-optimize by removing "obvious" content that other models actually need.
Do NOT
- Do NOT add content to AGENTS.md that belongs in .augment/ files.
- Do NOT exceed the recommended line budget for copilot-instructions.md.
- Do NOT duplicate rules between AGENTS.md and .augment/rules/.
Auto-trigger keywords
- AGENTS.md optimization
- copilot-instructions
- deduplication
1---2name: copilot-agents-optimization3description: Use when optimizing AGENTS.md or copilot-instructions.md — deduplicates against .augment/ content, enforces line budgets, and focuses each file on its audience.4---56# Copilot & AGENTS Optimizer Skill78## When to use910Use this skill when:11- Running `/docs-optimize` to refactor AGENTS.md and copilot-instructions.md12- Adding new content to either file and needing to check if it belongs there13- After changes to `.augment/` (new skills, rules, guidelines) that may make content in these files redundant14- When either file exceeds the line budget151617Do NOT use when:18- Writing application code19- Creating new skills or commands2021## Procedure: Optimize copilot/agents files2223### 0. Analyze current state2425Before changing anything, read and understand:26271. **Read `AGENTS.md`** — current content, line count, what's duplicated vs. unique.282. **Read `.github/copilot-instructions.md`** — same analysis.293. **Scan `.augment/`** — which skills, rules, and guidelines already cover topics from the files above.303b. **Scan the playbooks too, not only `.augment/`.** A `packages/<n>/AGENTS.md` may31 duplicate a **playbook** rather than a shipped rule, and dedup against `.augment/` alone32 misses it entirely — the content is not in `.augment/` at all. Run33 `findRestatedSteps` (`src/scripts/derive_playbooks.ts`) over each workspace file: a line34 carrying a playbook's `invokes` id outside a link is a restatement to replace with a35 pointer. The same id **inside** a link label is the shape the contract wants — see36 [`agents-md-thin-root` § Workspace files](../agents-md-thin-root/SKILL.md).374. **Identify duplication** — what content exists in both AGENTS.md and `.augment/`?3839Only after this analysis, proceed with optimization.4041### `AGENTS.md` — Project Entry Point for AI Agents4243| Property | Value |44|---|---|45| **Audience** | Augment Agent, other AI agents |46| **Can read `.augment/`?** | ✅ Yes — can follow references |47| **Size budget** | ≤ 3,000 chars (package root; consumer template ≤ 2,500) — enforced by `lint_agents_md.ts`; see `size-and-scope.md` |48| **Purpose** | Project-specific setup, Docker, testing, quality tools |4950**What belongs here:**51- Tech stack and framework versions52- Development setup (Docker, Make targets, env files)53- Database and multi-tenancy setup54- Testing framework, suites, and conventions55- Quality tool commands (PHPStan, Rector, ECS)56- Project structure overview (brief, link to module docs)57- Agent infrastructure overview (layer table, key references)5859**What does NOT belong here:**60- Coding standards (→ `.augment/rules/` and `.augment/guidelines/`)61- Architecture principles like SOLID, KISS, DRY (→ `.augment/rules/architecture.md`)62- PHP conventions (→ `../../../docs/guidelines/php/`)63- Scope control rules (→ `.augment/rules/scope-control.md`)64- Language/tone rules (→ `.augment/rules/language-and-tone.md`)65- Detailed module documentation (→ `app/Modules/README.md`)6667### `.github/copilot-instructions.md` — Self-Contained for Copilot6869| Property | Value |70|---|---|71| **Audience** | GitHub Copilot (Code Review bot + Chat) |72| **Can read `.augment/`?** | ❌ Code Review cannot, ✅ Chat can |73| **Line budget** | < 150 lines (ideal < 60); Copilot Code Review reads only the first 4,000 chars |74| **Purpose** | Coding standards, review rules, architecture constraints |7576**What belongs here:**77- Architecture rules (thin controllers, service layer, policies)78- PHP 8.2 patterns (readonly, final, enums — with exceptions)79- Project-specific conventions (custom helpers, environment config, naming)80- Code review scope and comment behavior rules81- Language rules (English comments, bilingual PR comments)82- Known issues / false positives that Copilot should avoid83- Package management rules8485**What does NOT belong here:**86- Docker setup or Make targets (Copilot doesn't run commands)87- Testing setup details (Copilot doesn't run tests)88- Agent infrastructure (Copilot doesn't use agents/)89- Things auto-enforced by ECS/Rector (code style, formatting, trailing commas)90- Detailed pattern documentation (too long, Copilot needs concise rules)9192## Deduplication Strategy9394### Rule: Content lives in ONE canonical place9596```97.augment/rules/ ← Canonical for behavior rules98.augment/guidelines/ ← Canonical for coding conventions99.augment/skills/ ← Canonical for domain expertise100agents/ ← Canonical for project-specific docs101```102103### When duplication is acceptable104105`copilot-instructions.md` **must** duplicate essential rules because Copilot Code Review106cannot read other files. But keep duplicated content:107- **Concise** — one-liner summaries, not full explanations108- **Focused** — only what Copilot needs for code suggestions and PR reviews109- **Stable** — rules that rarely change (architecture, naming, key conventions)110111### When duplication is NOT acceptable112113`AGENTS.md` should **never** duplicate `.augment/` content because Augment Agent can read114both. Instead, reference with a table:115116```markdown117| What | Where |118|---|---|119| PHP coding rules | `.augment/rules/php-coding.md` |120| Controller guidelines | `../../../docs/guidelines/php/controllers.md` |121```122123## Line Budget Enforcement124125| File | 🟢 Good | 🟡 Warning | 🔴 Over budget |126|---|---|---|---|127| `AGENTS.md` | ≤ 2,800 chars | 2,801–3,000 chars | > 3,000 chars — `lint_agents_md.ts` fails (consumer template: warn 2,300 / fail 2,500) |128| `copilot-instructions.md` | < 60 lines | 60–150 lines | > 150 lines, or key rules past the 4,000-char Copilot read window |129130### Reduction strategies (when over budget)1311321. **Extract to `agents/`** — Move project-specific details to dedicated files in `agents/`133 and link from AGENTS.md (e.g., `agents/reference/docs/database-setup.md`, `agents/reference/docs/testing.md`)1342. **Remove duplicates** — If content exists in `.augment/`, remove from AGENTS.md1353. **Condense** — Turn verbose explanations into concise tables or bullet points1364. **Remove ECS/Rector-enforced rules** — From copilot-instructions.md (auto-fixed anyway)1375. **Move examples to guidelines** — Detailed code examples belong in `.augment/guidelines/`138139## Portability and Stack Coherence140141Duplication is not the only way these files go wrong. They also **lie142about the project** over time:143144- **Legacy identifiers** — references to a former repo name, a sibling145 project in the same monorepo, or content that was copied from another146 codebase as a starting template and never adapted.147- **Stack drift** — the file claims "Laravel 11 + MariaDB" but the repo148 was converted to a Python library; or it names Docker services that149 no longer exist.150- **Dead commands** — `make start` in the docs, but `Makefile` no151 longer has that target.152153Before deduplicating, run three scans:1541551. **Legacy identifier scan** — compare both files against the package's156 `FORBIDDEN_IDENTIFIERS` blocklist (see `scripts/check_portability.ts`)157 plus any project names from `agents/` module docs that don't match158 the current project.1592. **Stack coherence scan** — auto-detect the actual stack from160 `composer.json` / `package.json` / `pyproject.toml` / etc. and flag161 any claim that no longer matches reality.1623. **Dead-command scan** — verify every `make X`, `task X`, `composer X`,163 `php artisan X`, or `npm X` still resolves.164165Every hit from scan 1 is a 🔴 blocker: leaking another project's name166into a consumer's own docs is the failure mode this skill exists to167prevent. Fix or remove those BEFORE any dedup/condense work — there's168no point deduplicating content that is about to be rewritten.169170When the drift is severe (whole sections are wrong), recommend171`/agents init` to scaffold a clean replacement rather than172patching forever.173174## agent-config Path Conventions — Preserve, Don't "Fix"175176`copilot-instructions.md` ships a "Known False Positives" section that177tells Copilot Code Review not to flag agent-config path patterns as178broken. When optimizing, **keep that section intact** — never delete179it as "redundant" and never trim its bullets. The patterns it covers:180181- Relative cross-references inside `.augment/` rules / skills182 (`../docs/guidelines/foo.md`, `../contexts/bar.md`) — paths resolve183 from the file's delivered location, not from the symlink in184 `.claude/rules/` etc. (per `road-to-path-fixes.md` Strategy A).185- `path_prefix:` triggers containing `src/` —186 literal match patterns, not file refs (per Modified Option 1,187 P2.2).188- Symlinked rule files under `.claude/rules/`, `.cursor/rules/`,189 `.clinerules/` — targets resolve into `.augment/rules/`.190191If the consumer project's `copilot-instructions.md` is missing the192section, **add it** during optimization using the canonical block193from `.augment/templates/copilot-instructions.md`. Surfaces include194`/agents init` and `/agents optimize`.195196## Optimization Checklist197198When optimizing either file, check:199200- [ ] "Known False Positives" section present and unmodified?201- [ ] No identifiers from other projects (FORBIDDEN_IDENTIFIERS blocklist)?202- [ ] Tech stack claims match actual project dependencies?203- [ ] All referenced commands/targets exist (Makefile, composer scripts, artisan, task)?204- [ ] Line count within budget?205- [ ] No content duplicated with `.augment/rules/`?206- [ ] No content duplicated with `.augment/guidelines/`?207- [ ] No content duplicated between the two files unnecessarily?208- [ ] AGENTS.md references `.augment/` instead of duplicating?209- [ ] copilot-instructions.md is self-contained for Code Review?210- [ ] No ECS/Rector-enforced rules in copilot-instructions.md?211- [ ] Project structure is brief (link to module docs for details)?212- [ ] All sections still relevant (no outdated references)?213- [ ] Cross-references to `agents/` docs are valid?214215## Related216217- **Command:** `/agents optimize`218- **Skill:** `copilot-config` — Copilot behavior and PR review patterns219- **Skill:** `agent-docs-writing` — documentation hierarchy220- **Context:** `augment-infrastructure.md` — full `.augment/` overview221222223## Output format2242251. Optimized file(s) with deduplication applied and line budget respected2262. Summary of what was removed, moved, or consolidated2273. Line count before/after for each file228229## Gotcha230231- AGENTS.md is read by GitHub Copilot and other tools — changes affect all AI assistants, not just Augment.232- Don't remove content from AGENTS.md that other tools depend on — verify cross-tool compatibility first.233- The model tends to over-optimize by removing "obvious" content that other models actually need.234235## Do NOT236237- Do NOT add content to AGENTS.md that belongs in .augment/ files.238- Do NOT exceed the recommended line budget for copilot-instructions.md.239- Do NOT duplicate rules between AGENTS.md and .augment/rules/.240241## Auto-trigger keywords242243- AGENTS.md optimization244- copilot-instructions245- deduplication