home / skills / plaited / agent-eval-harness / optimize-agents-md@plaited_development-skills

optimize-agents-md@plaited_development-skills skill

/.plaited/skills/optimize-agents-md@plaited_development-skills

This skill helps optimize AGENTS.md and rules for token efficiency by compressing content and standardizing verification patterns.

This is most likely a fork of the optimize-agents-md skill from plaited
npx playbooks add skill plaited/agent-eval-harness --skill optimize-agents-md@plaited_development-skills

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.5 KB
---
name: optimize-agents-md
description: Optimize AGENTS.md and rules for token efficiency. Auto-invoked when user asks about improving agent instructions, compressing AGENTS.md, or making rules more effective.
license: ISC
---

# Optimize AGENTS.md

Apply Boris Cherny's compression principles to AGENTS.md and rules files.

**Target**: ~2.5k tokens (most are 10k+ unnecessarily)

## When to Use

- User wants to improve their AGENTS.md or CLAUDE.md
- Agent instructions feel verbose or redundant
- Rules exist but lack verification patterns
- Setting up a new project's agent configuration

## Anti-Patterns to Fix

| Anti-Pattern | Problem | Fix |
|--------------|---------|-----|
| Context stuffing | Repeating info agents already know | Delete obvious instructions |
| Static memory | No learnings section | Add `## Learnings` with dates |
| Format drift | Inconsistent structure | Use consistent headers |
| Missing verification | No way to check work | Add `*Verify:*` patterns to rules |
| Verbose rules | Paragraphs instead of patterns | Compress to pattern + verify + fix |

## Workflow

### Phase 1: Analyze Current State

```bash
# Count tokens (rough estimate: words × 1.3)
wc -w AGENTS.md

# Find redundancy with project files
grep -l "bun test" AGENTS.md package.json
```

Look for:
- Instructions duplicating package.json scripts
- Explanations of common tools (git, npm, bun)
- Verbose descriptions that could be tables
- Rules without verification patterns

### Phase 2: Compress AGENTS.md

**Structure target:**

```markdown
# AGENTS.md

## Overview
[1-2 sentences: what this project is]

## Capabilities  
[Bullet list of key features/commands]

## Structure
[Brief file tree of key paths]

## Commands
[Essential commands only - not everything in package.json]

## Verification
[How to check work is correct]

## Workflow
[Key constraints: plan first, verify incrementally]

## Rules
[Links to rule files or inline compressed rules]

## Learnings
[Dated entries from actual issues encountered]
```

**Compression techniques:**
- Tables over paragraphs
- Bullets over sentences
- Delete anything in package.json
- Delete tool explanations (agents know git, npm, bun)
- Merge related sections

### Phase 3: Optimize Rules

Transform verbose rules into verification patterns:

**Before (verbose):**
```markdown
## Type Aliases Over Interfaces

In this codebase, we prefer using TypeScript type aliases 
instead of interfaces. This provides better consistency 
and flexibility when working with unions and intersections.

Example:
// Good
type User = { name: string }

// Bad  
interface User { name: string }
```

**After (compressed with verification):**
```markdown
**Type over interface** - `type User = {` instead of `interface User {`
*Verify:* `grep 'interface [A-Z]' src/`
*Fix:* Replace `interface X {` with `type X = {`
```

**Pattern format:**
```
**Rule name** - Brief description with example
*Verify:* Command or tool to check compliance
*Fix:* How to resolve violations
```

### Phase 4: Add Living Document Features

**Learnings section:**
```markdown
## Learnings
- 2024-01-15: Skills use CLI tools, never duplicate logic
- 2024-01-20: Rules need verification patterns for self-checking
```

**Update trigger:** Add learnings when:
- A mistake required correction
- A pattern was discovered
- A constraint was clarified

## Verification

After optimization:

1. **Token count**: `wc -w AGENTS.md` × 1.3 ≈ tokens (target: <2.5k)
2. **No redundancy**: `grep` for duplicated info in package.json
3. **Rules have patterns**: Each rule has `*Verify:*` line
4. **Learnings exist**: `## Learnings` section present

## Example Transformations

### Commands Section

**Before (340 words):**
```markdown
## Development Commands

To install dependencies, run the following command...
[lengthy explanation of bun install]

To run tests, you can use...
[explanation of test runner]
```

**After (40 words):**
```markdown
## Commands
```bash
bun install    # Setup
bun run check  # Lint/format
bun test       # Unit tests
```
```

### Capability Description

**Before:**
```markdown
This package provides TypeScript Language Server Protocol 
integration that allows you to get type information, find 
symbols across your workspace, locate references to symbols,
and perform batch analysis of files.
```

**After:**
```markdown
**LSP** (`lsp-*`): Type-aware hover, symbol search, references, batch analysis
```

## Related Skills

- **scaffold-rules** - Install optimized rules with verification patterns
- **validate-skill** - Validate skill structure

Overview

This skill compresses and sharpens AGENTS.md and rule files for token efficiency and actionable checks. It trims redundancy, enforces a compact structure, and converts verbose rules into verification patterns so agents can follow and self-audit instructions reliably.

How this skill works

It inspects AGENTS.md and related rule files for duplicated content, long prose, and missing verification steps. It rewrites sections into a fixed compact layout, converts rule paragraphs into Pattern/Verify/Fix triples, and adds a living Learnings section with update triggers. The result targets ~2.5k tokens and includes commands to verify token count and redundancy.

When to use it

  • You want to shrink an AGENTS.md that is 10k+ tokens
  • Agent instructions feel verbose, repetitive, or unfocused
  • Rules exist but lack automated verification patterns
  • Setting up or standardizing agent configs for a new project
  • Preparing docs for agents that must operate with strict token budgets

Best practices

  • Use the compact AGENTS.md structure: Overview, Capabilities, Structure, Commands, Verification, Workflow, Rules, Learnings
  • Prefer bullets and tables over paragraphs; delete obvious tool explanations
  • Convert each rule to: Rule name + one-line example, *Verify:* command, *Fix:* steps
  • Keep Commands minimal—only essential developer/agent commands
  • Add a dated ## Learnings section and append entries when issues occur

Example use cases

  • Reduce a verbose AGENTS.md from 12k tokens to ~2.5k while keeping verification
  • Convert prose rules into grep-based checks so CI can self-audit agent outputs
  • Standardize agent instruction format across multiple repos for consistent behavior
  • Add Learnings entries after production incidents to prevent repeat mistakes
  • Prepare a compact agent guide for evaluation harnesses that run many trials

FAQ

How do I measure token reduction reliably?

Estimate tokens as words × 1.3, then run wc -w on AGENTS.md and multiply by 1.3. Target under ~2.5k tokens.

What if a rule cannot be verified with a simple grep?

Add a lightweight script or linter command as the *Verify:* step. Prefer deterministic commands that can run in CI.