agentleFS
dougcunhadougcunha/TokenHound/.agents/skills/writing-agents-md/SKILL.md

writing-agents-md

Skill3 starsChanged 36 days agoMITView on GitHub

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 (use writing-skills) or human-facing docs and READMEs.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

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

    line 13
  2. Distinctive:

    Run on every line written, kept, or proposed.

    line 27
  3. Distinctive:

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

    line 35
  4. Very specific:

    Add a why-clause (one clause, not a paragraph) only where a rule reads arbitrary and agents keep "correcting" it: "Never edit gen/ — …

    line 60
  5. Distinctive:

    When the root file outgrows a screenful (~60 lines), run the Trim branch before adding anything.

    line 64
  6. Distinctive:

    Run the rent test line by line.

    line 72
  7. Distinctive:

    Run the rent test and pick its scope-ladder rung.

    line 86
  8. Distinctive:

    Search the file for a rule it duplicates or contradicts and update that rule in place — appending is how sediment forms.

    line 87

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  • Every line taxes every task. A rule relevant to 5% of sessions spends attention in the other 95%.
  • Rules dilute each other. Instruction-following is a budget: the more rules resident, the weaker each one binds. A bloated file doesn't enforce more — it enforces less, and the critical rule drowns in the noise.
  • The reader is a frontier model. It already knows git, testing, the language's idioms, and general best practice, and it can read the codebase. It needs decisions, not knowledge, and it parses a crisp rule without an example.

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:

ScopeResident forBelongs there
Global (~/.claude/CLAUDE.md)every projectcross-project workflow rules — the highest bar
Repo root fileevery task in the repocommands, repo-wide tripwires, deviations from convention
Subtree file (<dir>/AGENTS.md)work inside that subtreearea-specific rules, loaded only when the agent touches the area
Skillon triggerprocedures and multi-step workflows
Linked docon demandreference 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

  • Commands that can't be guessed: build/test/run invocations with their required flags and env.
  • Deviations from convention: the places this repo does X where the ecosystem default is Y.
  • Tripwires: constraints whose violation is expensive — generated files never edited by hand, protected branches, irreversible commands.
  • Domain vocabulary the code uses with a non-obvious meaning.
  • Pointers to on-demand material, each worded for when to load it.

Form

  • One rule, one line, imperative, concrete: "Run make check before commit", not "ensure quality gates pass".
  • State each rule once. A repeated rule doesn't reinforce — it competes with its copy, and the copies drift.
  • Phrase the positive target; keep a prohibition only for tripwires, paired with what to do instead.
  • Add a why-clause (one clause, not a paragraph) only where a rule reads arbitrary and agents keep "correcting" it: "Never edit gen/ — regenerated on build."
  • Reserve emphasis (IMPORTANT, NEVER, caps) for the one or two rules whose violation is catastrophic. Emphasis on everything is emphasis on nothing.
  • A clear rule needs no example. If a rule seems to need one, sharpen the rule until it doesn't — an example pays double rent and pins the rule to one surface form.
  • Group rules by concern under flat headings, tripwires first.
  • When the root file outgrows a screenful (~60 lines), run the Trim branch before adding anything.

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

  • Scar tissue — a rule added after one incident, resident forever. The Gate branch's duplicate-search is the immune response; retest neighboring rules while there.
  • Mirror documentation — the file restates what the code already shows (architecture tours, file inventories). Fails the delta test wholesale.
  • Example creep — good/bad code blocks multiplying under each rule. Cut the blocks, sharpen the rules.
  • Emphasis inflation — the caps arms race; see Form. Ends with nothing binding.
  • Harness re-instruction — re-explaining tool use or response format the harness's own system prompt already governs. Pure rent; evict on sight.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.