Copilot agents optimization

From event4u-app/agent-config · View interactive version

Copilot agents optimization is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when optimizing AGENTS.md or copilot-instructions.md — deduplicates against .augment/ content, enforces line budgets, and focuses each file on its audience.

How to use this skill

Skill file

Copilot & AGENTS Optimizer Skill

When to use

Use this skill when:

Do NOT use when:

Procedure: Optimize copilot/agents files

0. Analyze current state

Before changing anything, read and understand:

  1. Read AGENTS.md — current content, line count, what's duplicated vs. unique.
  2. Read .github/copilot-instructions.md — same analysis.
  3. 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

CODE0 § Workspace files.

  1. 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:

What does NOT belong here:

`.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:

What does NOT belong here:

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:

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 | `../../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)

  1. 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)

  1. Remove duplicates — If content exists in .augment/, remove from AGENTS.md
  2. Condense — Turn verbose explanations into concise tables or bullet points
  3. Remove ECS/Rector-enforced rules — From copilot-instructions.md (auto-fixed anyway)
  4. 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:

project in the same monorepo, or content that was copied from another

codebase as a starting template and never adapted.

was converted to a Python library; or it names Docker services that

no longer exist.

longer has that target.

Before deduplicating, run three scans:

  1. 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.

  1. 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.

  1. 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:

(../../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).

literal match patterns, not file refs (per Modified Option 1,

P2.2).

.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

Output format

  1. Optimized file(s) with deduplication applied and line budget respected
  2. Summary of what was removed, moved, or consolidated
  3. Line count before/after for each file

Gotcha

Do NOT

Auto-trigger keywords

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.