context-file-optimizer
Audit and rewrite AGENTS.md, CLAUDE.md, and other AI agent context files to be minimal and effective. This skill should be used when creating, reviewing, or rewriting context files (AGENTS.md, CLAUDE.md, .cursorrules, etc.) to follow research-backed guidelines that improve agent performance and reduce costs. Based on findings from arxiv.org/abs/2602.11988.
What this skill does
# Context File Optimizer Audit and rewrite AI agent context files following research-backed principles. Verbose context files hurt agent performance (-2 to -3%) and increase costs (+20%). Minimal, tooling-focused files improve performance (+4%) with lower overhead. ## Principle Hierarchy Three layers inform what belongs in a context file: 1. **karpathy-guidelines** (skill) — Foundational behavioral principles: think before coding, simplicity first, surgical changes, goal-driven execution. These govern how an agent acts; they don't need to be restated in every project's CLAUDE.md since the skill is globally available. 2. **Code quality standards** — Project coding rules (DRY, KISS, thin handlers, no hardcoded values, no silent failures, ~20-line functions, no premature abstraction). These ARE project-specific and belong in CLAUDE.md. **Preserve them — do not cut them as "general advice".** 3. **This skill** — Strips everything else: architecture prose, directory listings, duplicated docs, tutorial content. ## When to Use - Creating a new AGENTS.md, CLAUDE.md, or similar context file - Reviewing an existing context file for bloat or ineffectiveness - Consolidating overlapping context files in a project - Migrating from auto-generated to human-curated context ## Audit Process ### Step 1: Inventory All Context Files Locate every file that injects context into agent sessions: ```bash # Common context file locations fd -t f "AGENTS.md|CLAUDE.md|\.cursorrules|\.windsurfrules|copilot-instructions" . ``` Read each file. Note total word count and section count. Flag any file over 700 words. ### Step 2: Identify Duplication Cross-reference content across all context files found. Mark sections that appear in more than one file or that duplicate information already present in README, pyproject.toml, package.json, Dockerfile, or other standard project files. Common duplication sources: - Service URLs repeated across multiple context files - Tool commands duplicated between AGENTS.md and CLAUDE.md - Architecture descriptions that restate what's in README - Dockerfile patterns that agents can read from the actual Dockerfiles - Linter rules that agents can read from config files (pyproject.toml, eslint.config.mjs) ### Step 3: Classify Each Section For every section in every context file, classify it: | Classification | Action | Examples | |---------------|--------|---------| | **Tooling spec** | KEEP | Required CLI tools, package managers, linter commands | | **Build/test command** | KEEP | Exact test commands with paths, build commands | | **Non-obvious gotcha** | KEEP | "Worker caches env vars", "pitchers stored as P not SP/RP" | | **Operational rule** | KEEP (condense) | "Stop after 2-3 failures", "never use pip" | | **Code quality standards** | KEEP | DRY, KISS, thin handlers, no silent failures, ~20-line functions — project coding rules belong in CLAUDE.md | | **Architecture overview** | CUT | System diagrams, component descriptions | | **Directory listing** | CUT | File tree enumerations, module inventories | | **Duplicated docs** | CUT | Content from README, config files, or other context files | | **Tutorial/reference** | MOVE to docs/ | MCP tool guides, pipeline authoring references | | **Code examples of patterns** | CUT | Agents discover patterns from actual code | | **Tool installation instructions** | CUT | One-time setup, not per-session | | **Behavioral guidelines** | CUT | Karpathy-style agent behavior rules — covered by the `karpathy-guidelines` skill globally | ### Step 4: Rewrite Apply these rules when rewriting: **Structure rules:** - Target ~500-650 words per file (research optimal: ~640) - Use tables for dense reference data (tool names, commands, URLs) - Use code blocks for exact commands agents should run - One-line descriptions over paragraphs - No prose explanations of architecture — agents explore codebases effectively on their own **Content rules — what TO include:** - Required tools with their primary commands - Exact test/build/lint commands with full paths - Session workflow (start → work → close checklist) - Domain-specific gotchas that cause real bugs (not general advice) - Pointers to detailed docs for complex subsystems (e.g., "see docs/pipelines.md") **Content rules — what NOT to include:** - Repository overviews or architecture descriptions - Directory listings or component enumerations - Content duplicated in README, config files, or other context files - Code pattern examples (agents read actual code) - Installation or one-time setup instructions - Verbose prose explaining "why" behind conventions **Multi-file projects:** Assign clear responsibilities to each file: - AGENTS.md → Tooling commands, session workflow, operational rules - CLAUDE.md → Conventions that affect how code is written (standards, patterns, domain knowledge) - Avoid any content appearing in both files ### Step 5: Validate After rewriting, verify: 1. **Word count** — Each file should be under 700 words 2. **No duplication** — No section appears in more than one context file 3. **No redundancy** — No section restates what's in standard project files 4. **Commands are exact** — Every command can be copy-pasted and run 5. **Displaced content preserved** — Any cut reference material was moved to docs/, not deleted ## Research Reference Read `references/research-findings.md` for the full experimental data supporting these guidelines, including specific performance numbers and the verbatim conclusion from the paper.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.