Agent Skill
Writing for agents (Matt Pocock)
A writing reference that loads when you edit a skill, AGENTS.md or CLAUDE.md: wording pointers, what to move into side files, completion criteria, pruning.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkInstall
Commands are pinned to commit d653911, the version we read, wherever the install method supports it.
npx skills
npx skills add mattpocock/skills@d65391149dbb5fe76478e76fa8d5122b2aa5a70e --skill writing-for-agents -a claude-codeCopies the skill into .claude/skills/ in this project, pinned to the reviewed commit.
Plugin marketplace
/plugin install mattpocock-skills@claude-plugins-officialRun inside Claude Code. Installs the whole mattpocock-skills plugin from its default branch, not the pinned commit; the official marketplace is available by default.
Upload
git clone https://github.com/mattpocock/skills.git
cd skills && git checkout d65391149dbb5fe76478e76fa8d5122b2aa5a70e
cd skills/productivity && zip -r ~/writing-for-agents.zip writing-for-agentsThen in Claude open Customize > Skills, choose + > Upload a skill and pick the zip. Code execution must be enabled in Settings > Capabilities. Built from the pinned commit.
npx skills
npx skills add mattpocock/skills@d65391149dbb5fe76478e76fa8d5122b2aa5a70e --skill writing-for-agents -a codexInstalls to .agents/skills/, which Codex scans from the working directory up to the repo root.
npx skills
npx skills add mattpocock/skills@d65391149dbb5fe76478e76fa8d5122b2aa5a70e --skill writing-for-agents -a cursorInstalls to .agents/skills/, one of the folders Cursor reads skills from.
gh skill
gh skill install mattpocock/skills skills/productivity/writing-for-agents --pin d65391149dbb5fe76478e76fa8d5122b2aa5a70e --agent github-copilotNeeds GitHub CLI 2.90.0 or later. Use --scope user to install for every repository.
npx skills
npx skills add mattpocock/skills@d65391149dbb5fe76478e76fa8d5122b2aa5a70e --skill writing-for-agentsPinned to the commit we reviewed. The CLI asks which agents to install for; add -g to install for your user instead of this project.
What it does
It is a style guide for documents that an agent reads rather than a person: a skill, an AGENTS.md or CLAUDE.md, or a doc reached from one of them. It loads whenever you create or edit one of those, and gives the agent a small vocabulary to judge the draft with. A “context pointer” is any always-loaded line that tells the agent where other material lives, such as a skill’s description, and its wording decides when that material gets read. “Context load” is what always-loaded text costs the agent; “cognitive load” is what remembering many manual commands costs you. Each line of the document is placed on an “information hierarchy”: steps in the main file, reference beside them, and anything only some cases need pushed into a separate file behind a pointer.
The rest is concrete editing advice: end every step on a completion criterion the agent can check, collapse a repeated idea into one “leading word” the model already knows, state the behaviour you want instead of banning the one you do not, and delete any sentence that does not change what the model would do by default. When the document is a skill, SKILL-MECHANICS.md adds the choice between a model-invoked skill (it has a description that costs context on every turn) and a user-invoked one (disable-model-invocation: true, no context cost, but you have to remember it), and the idea of a router skill that lists your manual skills for you.
When to use it
You maintain a growing AGENTS.md or CLAUDE.md that has started to feel like sediment, or you write skills that sometimes fire and sometimes do not. It is most useful as a reviewer: ask the agent to apply it to an existing file and you get specific cuts (restated config, no-op instructions like “be thorough”, rules scattered under three headings) rather than general advice to “be concise”. The idea that a description is a pointer whose wording sets the trigger, not a summary, matches what our guide to writing descriptions that trigger finds in practice.
When to skip it
When you are writing your first skill. It assumes you already know the format and talks in its own terms; start with skill creator, which interviews you and produces a working draft, then use this to tighten it. Skip it too if you want proof rather than principles: nothing in it tests whether your change helped. The skill says disagreements over a “no-op” are settled “by running the document, not by debate”, but leaves the running to you. And because it loads for any edit to CLAUDE.md, it adds its full text to the context on small edits where you may not want 11 KB of guidance.
Try it
Review our CLAUDE.md against the writing-for-agents guidance. It's 400
lines and the agent keeps ignoring the migration rules near the bottom.
Tell me what to delete, what to move into docs/ behind a pointer, and
rewrite the migration section with a clear completion criterion.
What it can touch
- Bundles scripts
- No
- Pre-approved tools
- None declared
- Needs
- Nothing beyond the agent
- Client-specific fields
- None, spec fields only
Its instructions steer what your agent does, and it may have changed since the commit we read. How to check a skill.
Instructions only: no scripts, no allowed-tools, no network. The agent edits the document you are working on. The frontmatter has only name and description, so the folder uploads to the Claude apps as it is; the agents/openai.yaml file is ignored by everything except Codex. There is no license field in the frontmatter; the repository is MIT.
At commit d653911 the SKILL.md is 81 lines long. Alongside it:
SKILL-MECHANICS.md(22 lines): invocation choice, when to split a skill in two, and router skills.agents/(1 entry):openai.yaml, the display name and short description Codex shows.
The SKILL.md is short in lines but dense: about 11 KB, written in long paragraphs with the key terms in bold.
How it compares with the other skill-writing skills
| Skill | What it gives you | Pick it when |
|---|---|---|
| Writing for agents | A vocabulary and editing rules for any agent-facing document | You are revising a skill or AGENTS.md that already exists |
| Skill creator | An interview, a draft and evals against a baseline | You are starting a new skill and want it measured |
| Writing skills | A test-first loop: watch the agent fail, then write the fix | You want evidence that each line earns its place |
They combine well: draft with skill creator, prune with this, and check the result with the test-first loop.
Alternatives
Skill creator from Anthropic is the better starting point for a new skill. Writing skills from obra’s Superpowers applies test-driven development to skill text. For the project file itself, the write a useful AGENTS.md workflow builds one from your repository and keeps it short.
SKILL.md
The file exactly as published at the reviewed commit, reproduced under its MIT licence.
---
name: writing-for-agents
description: Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
---
Reference for writing any document an agent consumes: a skill, an `AGENTS.md` / `CLAUDE.md`, a doc reached by a pointer. The packaging differs; the writing does not: the same levers make each one predictable, since the agent takes the same _process_ every run rather than producing the same output.
When the document you're writing is a skill, read [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md) for frontmatter, invocation choice, and router skills.
## Context pointers
A **context pointer** is a reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. A skill's description is one; a line in `AGENTS.md` naming a doc is the same object. The pointer's _wording_, not its target, decides when the agent reaches the material, and how reliably. A must-have target behind a weakly worded pointer is a variance bug: sharpen the wording first, and inline the material only if sharpening fails.
A pointer does two jobs: state what the material is, and list the **branches** that should trigger reaching it (a branch is a distinct case the document handles, so different runs take different paths through it). Every word of an always-loaded pointer costs on every turn, so it earns even harder pruning than the body:
- **Front-load the leading word**: the pointer is where it does its triggering work.
- **One trigger per branch.** Synonyms that rename a single branch are one branch written twice; collapse them and keep only genuinely distinct branches.
- **Cut identity the body already carries.**
## The two loads
Every document and pointer you add spends one of two budgets:
- **Context load** is the cost of always-loaded material on the agent's window: an `AGENTS.md` line, a skill description, anything sitting in context every turn, spending tokens and attention whether or not it fires.
- **Cognitive load** is the cost on the human: which documents exist and when to reach for each. The human is the index. Not a cost to minimise: it is the price of human agency; spend it where human judgement matters, remove it where it does not.
Material reached only through a pointer escapes context load at the price of the pointer's own line; material with no pointer at all rides entirely on cognitive load.
## Information hierarchy
A document is built from two content types: **steps** (the ordered actions the agent performs) and **reference** (definitions, rules, facts consulted on demand). The two mix freely: all steps (a recipe), all reference (a review's rules, this skill), or both. The core decision is where each piece sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
1. **In-file step** is the primary tier: what the agent does, in order.
2. **In-file reference** is consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung), which is a fine arrangement, not a smell.
3. **Disclosed reference** is pushed out into a separate file, reached by a context pointer, loaded only when the pointer fires. Spans a sibling file in the same folder through fully external reference that lives anywhere and any document can point at.
Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
**Progressive disclosure** is the move down the ladder (out of the main file and behind a pointer) so the top stays legible. Not primarily a token optimisation: it is how the hierarchy is protected. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. When a document has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip: a variance lever, not just a legibility one.
**Co-location** is the within-file companion: where the ladder decides _how far down_ a piece sits, co-location decides _what sits beside it_ once there. Keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it. The test: the document should read like documentation written for the agent. Grouped material reads that way; scattered material does not. (Distinct from duplication: that repeats one meaning in two places; scattering fragments one meaning across many.)
**Sprawl** is the failure mode here: a document simply too long, even when every line is live and unique. Attention thins across the excess, and every extra line is one more to keep relevant. The cure is the ladder: disclose reference behind pointers, and split by branch or sequence so each path carries only what it needs.
## Steps and completion criteria
Every step ends on a **completion criterion**, the condition that tells the agent the work is done. Two properties make it a lever:
- **Clarity**: can the agent tell done from not-done? A vague bound ("understanding reached") invites **premature completion**: ending the step before it is genuinely done, attention slipping to _being done_. The visible steps still ahead (the **post-completion steps**) supply the pull; the criterion's clarity is the resistance. Defend in order: **sharpen the bound first** (local and cheap); only if it is irreducibly fuzzy _and_ you observe the rush, hide the later steps by splitting the sequence. Hiding only works across a real context boundary (a hand-off or a subagent dispatch; an inline call leaves the later steps in context and clears nothing).
- **Demand**: how much it requires. "Every modified model accounted for" forces thorough work where "produce a change list" does not. Demand drives **legwork** (the digging the agent does within the work, latent in the wording rather than written as its own step), and it is not step-bound: "every rule applied" binds a body of flat reference just as "every step done" binds a sequence, which is how an all-reference document still carries an exhaustiveness bar.
The strongest criteria are both checkable and exhaustive.
## When to split
Splitting one document into two spends one of the two loads, so split only when the cut earns it:
- **By sequence**: split a run of steps where the post-completion steps tempt the agent to rush the one in front of it. Keeping them out of view drives more legwork on the current task. Beware the reverse: merging sequences exposes each step's later steps to what follows, inviting premature completion.
- **By invocation**, skill-specific: see [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md).
## Leading words
A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the document (_lesson_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds. Coining your own works if you define it clearly, but a made-up word recruits no priors: you pay in definition tokens what a pretrained word gives free; reach for an existing word first.
It anchors twice. In the body, _execution_: the agent reaches for the same behaviour every time the word appears, and inside flat reference it focuses attention on a class of thing to look for. In a pointer, _invocation_: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the material and reaches it more reliably.
Hunt for opportunities to refactor with leading words. A triad spelled out at three sites, a pointer spending a sentence to gesture at one idea. Each is a passage begging to collapse into a single token:
- "fast, deterministic, low-overhead" → _tight_ (a _tight_ loop).
- "a loop you believe in" → _red_, turning a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
You win twice: fewer tokens, and a sharper hook for the agent to hang its thinking on. Assume every document is carrying restatements that leading words retire. Go find them.
**Negation** is the failure mode beside this lever: steering by prohibition drags the forbidden behaviour into context and makes it _more_ available, not less. _Don't think of an elephant_, and the elephant is all there is; the negation is a weak modifier the strongly-activated concept overruns, so the ban half-reads as an instruction to do the thing. Prompt the **positive**: state the target behaviour ("write one-line comments") so the banned one is never spoken. A prohibition earns its place only as a hard guardrail you cannot phrase positively; even then, pair it with the positive target so attention lands on what to do.
## Pruning
- Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit. **Duplication** (the same meaning in more than one place) costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank. (The accidental inverse of a leading word, which repeats a token on purpose, never the meaning.)
- The **environment** is a source of truth too (`package.json` scripts, config files, the directory layout, `--help` output), and a document that restates it is a **cache**: a copy of a lookup, earning its load only when the lookup is expensive. Cache what the agent cannot find by looking: the unwritten convention, the reason behind a choice, the gotcha no config confesses. Leave the one-file, one-command lookups to the environment, where they cannot go stale.
- Check every line for **relevance**: does it still bear on what the document does? A line loses relevance by never bearing on the task (mere exposition, or a branch that should be disclosed) or by going stale as the behaviour or world it describes changes. Shorter documents are easier to keep relevant. Without a pruning discipline the default fate is **sediment**: stale layers that settle because adding feels safe and removing feels risky, until you must core down through them to find what is still live.
- Hunt **no-ops** sentence by sentence: an instruction the model already obeys by default pays load to say nothing. The test (does it change behaviour versus the default?) is model-relative, not reader-relative: two people disagreeing about a no-op disagree about the default, and settle it by running the document, not by debate. When a sentence fails, delete the whole sentence rather than trim words from it. The test also grades leading words: a word too weak to beat the default (_be thorough_ when the agent is already thorough-ish) is a no-op, and the fix is a stronger word (_relentless_), not a different technique.Related skills
Writing skills (Superpowers)
obra's test-first method for writing skills: watch an agent fail without the skill, write the minimum that fixes it, then pressure-test with subagents.
Skill creator
Anthropic's skill for writing new skills and improving old ones: interviews you, drafts SKILL.md, runs evals against a baseline and tunes the description.
CLAUDE.md improver (Anthropic)
Anthropic's Claude Code skill that finds every CLAUDE.md in a repo, grades each one A to F, shows a report, then edits only the files you approve.
Guides and recipes that use Writing for agents (Matt Pocock)
- Agent Skills moves to the Agentic AI Foundation: what changes for skill authors
Anthropic gave Agent Skills to the Agentic AI Foundation on 22 October 2026. Who maintains the spec now, how changes get made, and what stays the same for you.
- Skill description best practices: write descriptions that trigger
The description decides when a skill loads. Fix skills that fire too often or never trigger, with before and after examples and a prompt set to test them.
- Write a useful AGENTS.md: example, template and test
An AGENTS.md example and template with build and test commands, conventions and traps, plus a before-and-after task that shows whether the file actually helps.
- Writing instructions for agents
Briefs, AGENTS.md files and skills an agent can finish without guessing.