Skip to content
Back to skills

Optimize Agent Instructions

ASecurity

Audits and rewrites the canonical AGENTS.md instruction file in any repo. Strips stale or foreign content and applies Karpathy's four behavioral principles. It reports legacy CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md mirrors but does not rewrite them by default, preventing instruction duplication and context bloat. Trigger when the user says "optimize my CLAUDE.md", "audit agent instructions", "improve my AGENTS.md", "apply Karpathy principles to my agent files", "clean up my ...

  • 7 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 2, 2026
ai-agentsbashgit

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned October 3, 2026

npx -y skills add richfrem/agent-plugins-skills --skill optimize-agent-instructions --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Optimize Agent Instructions?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Optimize Agent Instructions
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/richfrem-optimize-agent-instructions/badge)](https://www.skillsdirectory.com/skills/richfrem-optimize-agent-instructions)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: optimize-agent-instructions
plugin: agent-agentic-os
description: >
  Audits and rewrites the canonical AGENTS.md instruction file in any repo. Strips stale
  or foreign content and applies Karpathy's four behavioral principles. It reports legacy
  CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md mirrors but does not rewrite
  them by default, preventing instruction duplication and context bloat.
  Trigger when the user says "optimize my CLAUDE.md", "audit agent instructions",
  "improve my AGENTS.md", "apply Karpathy principles to my agent files", "clean up
  my copilot instructions", "review my GEMINI.md", or "update my AI instruction files".
allowed-tools: Read, Write, Bash
---

# Optimize Agent Instructions (`optimize-agent-instructions`)

Audits and rewrites the canonical `AGENTS.md` instruction file in any repository to preserve concise, high-signal behavioral constraints.

## Contents

- [Critical Constraints](#critical-constraints)
- [Quick start](#quick-start)
- [Workflow](#workflow)
- [Verification](#verification)
- [References](#references)

## Critical Constraints

1. **Single Canonical Authority**: `AGENTS.md` is the sole source of truth; never create separate conflicting rules in mirrors.
2. **Preserve Domain Invariants**: Never delete project-specific rules, architecture boundaries, or test commands without confirmation.
3. **No Stale Artifacts**: Strip personal usernames, dates, historical session notes, and outdated post-mortems.

## Quick start

Inspect the current instruction file for stale session notes and line count:

```bash
wc -l AGENTS.md CLAUDE.md GEMINI.md 2>/dev/null
```

## Workflow

1. **Discovery**: Inventory existing files (`AGENTS.md`, `CLAUDE.md`, `GEMINI.md`) and identify rules to preserve.
2. **Audit & Scoring**: Score instruction files against Karpathy principles, brevity, and platform mappings.
3. **Plan Rewrite**: Present explicit diff of removals (stale logs), additions (behavioral rules), and kept invariants.
4. **Synthesis**: Write lean, consolidated `AGENTS.md`.
5. **Mirror Verification**: Ensure platform mirrors are short pointers rather than duplicate full-text files.

## Verification

Confirm `AGENTS.md` contains core behavioral principles and zero stale notes:

```bash
head -n 40 AGENTS.md
```

## References

- [detailed-reference.md](references/detailed-reference.md) — 12-point Quality Checklist, Karpathy principles, and platform mappings.
- [acceptance-criteria.md](references/acceptance-criteria.md) — Acceptance criteria for instruction optimizations.
- [fallback-tree.md](references/fallback-tree.md) — Remediation pathways when instruction files conflict.

Files in this skill

  • SKILL.md9.3 KB
  • evals/evals.json1.8 KB
  • references/acceptance-criteria.md42 B
  • references/sample-claude-md36 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…