Agent Instruction Files Improver
Treat instruction files as a minimal decision layer, not a project manual. Prefer deleting, consolidating, or moving instructions over adding prose.
Workflow
0. Establish project risk profile and default safe posture
Resolve the target directory, then before auditing, classifying, deleting, rewriting, or moving any instruction, identify whether it is an experimental/side project, internal application, production service, public API/SDK/plugin ecosystem, migration/rollback-sensitive system, or subject to security, privacy, compliance, or release controls.
Use repository and user evidence such as deployment/hosting and CI/CD files, published API schemas or packages, migration/backup/rollback scripts, authentication/permission configuration, privacy/compliance documents, and explicit owner statements. Record each risk as confirmed, inferred, or unknown.
When the risk profile is unknown, use the conservative default: do not propose deleting or weakening safeguards for external compatibility, data migration or rollback, security or permissions, data integrity, release/deployment, privacy, compliance, destructive operations, or secrets. Mark the item needs owner confirmation.
Apply aggressive cleanup only when evidence supports an experimental or side-project context and no external contract or high-risk control is affected. Express every risk-sensitive recommendation as trigger → action → verification.
Example: same rule, different risk
- Original:
Do not preserve backward compatibility.
- Side project:
Remove obsolete internal paths instead of adding new compatibility layers.
- Public API or production:
Do not add compatibility layers unless compatibility is required by an external contract. Before removing an existing path, verify callers, migration requirements, and rollback coverage.
1. Establish scope before judging content
- Find instruction files with
rg --files -g 'AGENTS.md' -g 'AGENTS.local.md' -g '.agents.md' -g 'CLAUDE.md' -g '.claude.md' -g '.claude.local.md'.
- Identify the files that actually govern the target. Record parent-to-child precedence and local overrides.
- Do not inspect or change global instruction files unless the user explicitly includes them.
- Do not treat every nested instruction file as a candidate for expansion. A nested file should exist only for a real domain or workflow boundary.
2. Build an evidence-backed instruction inventory
Read each applicable file completely. For every instruction, verify it against the codebase, configuration, scripts, and recent task evidence.
Classify each item before proposing a change:
| Decision |
Use when |
| Keep |
It is current, non-obvious, applies in scope, and materially changes a decision. |
| Remove |
It is generic, duplicate, stale, contradicted, or directly derivable from files and tool output. |
| Move |
It is valid but specialized, long, or low-frequency; place it in a focused skill or reference and retain only a trigger/link here. |
| Add |
It cannot be reliably inferred, recurs, and prevents a meaningful failure or wrong decision. |
| Rewrite |
The constraint is necessary but vague, untestable, overly absolute, or located at the wrong scope. |
Preserve explicit high-risk guardrails identified in Step 0 and any other high-cost failure controls; do not weaken them merely to make a file shorter.
3. Audit derivability and conflicts
For each candidate addition or retained line, ask:
- Can an agent infer this from
package.json, scripts, CI, directory names, tests, tool help, or nearby code?
- Is it already stated by a parent, child, tool description, or another source of truth?
- Is it needed for most tasks in this scope, or only a specialized workflow?
- Does it specify a condition, action, and verifiable outcome?
If the answer to 1 or 2 is yes, remove or link instead of repeating it. If the answer to 3 is no, move it behind progressive disclosure. Resolve a conflict by choosing one source of truth; never preserve contradictory wording to be "safe."
4. Report before editing
Always present a Minimal Context Report and wait for approval before writing. Use references/templates.md for the report and diff structure. Include:
- files that govern the requested scope and their precedence;
- the risk profile, evidence status, and items needing owner confirmation;
- evidence-backed keep, remove, move, add, and rewrite decisions;
- must-fix conflicts or stale instructions separately from optional polish;
- the expected effect on agent decisions, not a chapter-completeness score.
Use references/quality-criteria.md when a scored assessment is useful or requested. Do not reward a file merely for listing commands, architecture, or every key file.
5. Propose and apply the smallest safe diff
- Show exact diffs, with deletions before additions.
- Add only verified repository-specific facts. Cite the configuration, code, test, or command that supports each addition.
- Keep low-frequency procedures in a skill or one-level-deep reference; the instruction file should state when to load it.
- Do not create an instruction file simply because none exists. Create one only when verified non-inferable constraints recur in the requested scope.
- After approval, preserve the existing structure where possible and apply the diff.
6. Verify the result
After editing, re-check the affected scope:
- every path and command is real and current;
- no child file repeats or contradicts its parent;
- no retained line is obvious from the repository alone;
- high-risk guardrails remain explicit, and unknown risk was not treated as low risk;
- referenced skills and documents exist and are loaded only when relevant.
Report what changed and any facts that still require owner confirmation.
Writing rules
- State project-specific constraints, not generic agent advice.
- Put instructions at the narrowest scope that reliably governs the affected work.
- Prefer conditional instructions: trigger → action → expected verification.
- Treat code, tests, CI, and tool schemas as primary evidence; instruction files should describe the exceptions those artifacts cannot express.
- Use concise tables or bullets only when they reduce ambiguity.
1---2name: agent-md-improver3description: Audit, simplify, and update repository AGENTS.md and CLAUDE.md files. Use when Codex needs to review, improve, deconflict, or reduce agent instructions; maintain project memory; or decide what belongs in an instruction file versus code, a skill, or a reference. Preserve only current, non-obvious, task-relevant constraints backed by repository evidence.4---56# Agent Instruction Files Improver78Treat instruction files as a minimal decision layer, not a project manual. Prefer deleting, consolidating, or moving instructions over adding prose.910## Workflow1112### 0. Establish project risk profile and default safe posture1314Resolve the target directory, then before auditing, classifying, deleting, rewriting, or moving any instruction, identify whether it is an experimental/side project, internal application, production service, public API/SDK/plugin ecosystem, migration/rollback-sensitive system, or subject to security, privacy, compliance, or release controls.1516Use repository and user evidence such as deployment/hosting and CI/CD files, published API schemas or packages, migration/backup/rollback scripts, authentication/permission configuration, privacy/compliance documents, and explicit owner statements. Record each risk as **confirmed**, **inferred**, or **unknown**.1718When the risk profile is unknown, use the conservative default: do not propose deleting or weakening safeguards for external compatibility, data migration or rollback, security or permissions, data integrity, release/deployment, privacy, compliance, destructive operations, or secrets. Mark the item **needs owner confirmation**.1920Apply aggressive cleanup only when evidence supports an experimental or side-project context and no external contract or high-risk control is affected. Express every risk-sensitive recommendation as trigger → action → verification.2122#### Example: same rule, different risk2324- Original: `Do not preserve backward compatibility.`25- Side project: `Remove obsolete internal paths instead of adding new compatibility layers.`26- Public API or production: `Do not add compatibility layers unless compatibility is required by an external contract. Before removing an existing path, verify callers, migration requirements, and rollback coverage.`2728### 1. Establish scope before judging content29301. Find instruction files with `rg --files -g 'AGENTS.md' -g 'AGENTS.local.md' -g '.agents.md' -g 'CLAUDE.md' -g '.claude.md' -g '.claude.local.md'`.312. Identify the files that actually govern the target. Record parent-to-child precedence and local overrides.323. Do not inspect or change global instruction files unless the user explicitly includes them.334. Do not treat every nested instruction file as a candidate for expansion. A nested file should exist only for a real domain or workflow boundary.3435### 2. Build an evidence-backed instruction inventory3637Read each applicable file completely. For every instruction, verify it against the codebase, configuration, scripts, and recent task evidence.3839Classify each item before proposing a change:4041| Decision | Use when |42|---|---|43| **Keep** | It is current, non-obvious, applies in scope, and materially changes a decision. |44| **Remove** | It is generic, duplicate, stale, contradicted, or directly derivable from files and tool output. |45| **Move** | It is valid but specialized, long, or low-frequency; place it in a focused skill or reference and retain only a trigger/link here. |46| **Add** | It cannot be reliably inferred, recurs, and prevents a meaningful failure or wrong decision. |47| **Rewrite** | The constraint is necessary but vague, untestable, overly absolute, or located at the wrong scope. |4849Preserve explicit high-risk guardrails identified in Step 0 and any other high-cost failure controls; do not weaken them merely to make a file shorter.5051### 3. Audit derivability and conflicts5253For each candidate addition or retained line, ask:54551. Can an agent infer this from `package.json`, scripts, CI, directory names, tests, tool help, or nearby code?562. Is it already stated by a parent, child, tool description, or another source of truth?573. Is it needed for most tasks in this scope, or only a specialized workflow?584. Does it specify a condition, action, and verifiable outcome?5960If the answer to 1 or 2 is yes, remove or link instead of repeating it. If the answer to 3 is no, move it behind progressive disclosure. Resolve a conflict by choosing one source of truth; never preserve contradictory wording to be "safe."6162### 4. Report before editing6364Always present a **Minimal Context Report** and wait for approval before writing. Use [references/templates.md](references/templates.md) for the report and diff structure. Include:6566- files that govern the requested scope and their precedence;67- the risk profile, evidence status, and items needing owner confirmation;68- evidence-backed keep, remove, move, add, and rewrite decisions;69- must-fix conflicts or stale instructions separately from optional polish;70- the expected effect on agent decisions, not a chapter-completeness score.7172Use [references/quality-criteria.md](references/quality-criteria.md) when a scored assessment is useful or requested. Do not reward a file merely for listing commands, architecture, or every key file.7374### 5. Propose and apply the smallest safe diff75761. Show exact diffs, with deletions before additions.772. Add only verified repository-specific facts. Cite the configuration, code, test, or command that supports each addition.783. Keep low-frequency procedures in a skill or one-level-deep reference; the instruction file should state when to load it.794. Do not create an instruction file simply because none exists. Create one only when verified non-inferable constraints recur in the requested scope.805. After approval, preserve the existing structure where possible and apply the diff.8182### 6. Verify the result8384After editing, re-check the affected scope:8586- every path and command is real and current;87- no child file repeats or contradicts its parent;88- no retained line is obvious from the repository alone;89- high-risk guardrails remain explicit, and unknown risk was not treated as low risk;90- referenced skills and documents exist and are loaded only when relevant.9192Report what changed and any facts that still require owner confirmation.9394## Writing rules9596- State project-specific constraints, not generic agent advice.97- Put instructions at the narrowest scope that reliably governs the affected work.98- Prefer conditional instructions: trigger → action → expected verification.99- Treat code, tests, CI, and tool schemas as primary evidence; instruction files should describe the exceptions those artifacts cannot express.100- Use concise tables or bullets only when they reduce ambiguity.