Writing agents md

From compozy/agh · View interactive version

Writing agents md is an AI agent skill from the GitHub repository compozy/agh. Author lean AGENTS.md/CLAUDE.md instruction files — resident system-prompt context where every line pays rent. Use when writing an agent instruction file from scratch, auditing or trimming a bloated one, or gating whether a new rule earns residence and at which scope. Don't use for on-demand skills

How to use this skill

Skill file

Writing AGENTS.md

Keep agent instruction files lean enough that every rule in them binds.

Physics: resident context

An AGENTS.md or CLAUDE.md (COPILOT.md, .cursorrules — any harness instruction file) is not documentation. It is a fragment of the system prompt: the harness injects it verbatim into every session, before the task is known, and it never unloads. A skill loads on demand; this file is resident. Three consequences govern everything below:

The file that survives these constraints is a delta: the difference between stock agent behavior and what this project needs. Everything that isn't delta is rent paid for nothing.

The rent test

Run on every line written, kept, or proposed. A line stays only if all three hold; a line that fails is deleted or relocated, never softened.

  1. Delta — it changes what the agent would otherwise do. Restated defaults, general best practices, and motivational prose fail here.
  2. Frequency — it bears on most sessions at its scope. A rule only some tasks need moves down the scope ladder instead.
  3. Economy — keeping it resident is cheaper than deriving it on demand. A non-obvious test invocation passes (saves a search every session); anything the toolchain announces on its own — type errors, lint output, failing CI — fails.

Scope ladder

Place each rule at the narrowest scope that still covers the tasks needing it:

| Scope | Resident for | Belongs there |

|---|---|---|

| Global (~/.claude/CLAUDE.md) | every project | cross-project workflow rules — the highest bar |

| Repo root file | every task in the repo | commands, repo-wide tripwires, deviations from convention |

| Subtree file (<dir>/AGENTS.md) | work inside that subtree | area-specific rules, loaded only when the agent touches the area |

| Skill | on trigger | procedures and multi-step workflows |

| Linked doc | on demand | reference some tasks need; word the pointer for when to read it |

Two mechanics decide placement more than anything else: nested files load lazily, so the directory tree is the progressive disclosure these files natively support. And in Claude Code, an @path import expands at load time — resident, full rent — while a plain path mentioned in prose is read only on demand.

What earns residence

Form

Branches

Write — a new file for a repo:

  1. Collect delta candidates from the repo itself: manifests, Makefile/CI config for real commands; layout for deviations from convention; history and existing docs for tripwires.
  2. Draft each candidate per Form and place it on the scope ladder.
  3. Run the rent test line by line; delete or relocate failures.

Done when: every line passes all three rent tests at its chosen scope.

Trim — an existing file:

  1. Verdict every line: keep / rewrite / relocate (with target scope) / evict (with the failed test). Flag contradictory rules for the user to resolve — never silently pick a side.
  2. Present the verdict table, then apply it: rewrite survivors per Form, create subtree files and pointers for relocations.

Done when: every original line has a verdict and the surviving file passes the Write bar.

Gate — a single new rule, usually promoting a chat correction:

  1. Phrase the candidate as one positive imperative line.
  2. Run the rent test and pick its scope-ladder rung.
  3. Search the file for a rule it duplicates or contradicts and update that rule in place — appending is how sediment forms.

Done when: the rule lives at exactly one scope, exactly once.

Failure modes

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.