writing-for-agents
Skill1 starsChanged 2 months agoMITView on GitHub
The discipline for writing documents an agent reads — skills, AGENTS.md, CONTEXT.md, any doc behind a pointer. Triggers — "this brief is bloated", "why doesn't the agent pick this up", "should this be its own skill".
97 other projects use a version of this, 82 of them edited.
Adopted by
Most recently taken up by
- mattpocock/skillsedited, first seen Oct 8, 2026
- grezxune/ai-toolsedited, first seen Oct 5, 2026
- AlexisBalayre/claude-code-configedited, first seen Oct 5, 2026
- KroxiDev/engineering-skillstheir own version, first seen Oct 5, 2026
- michielvandermeer/skillsedited, first seen Oct 4, 2026
- Integralist/agent-skillsedited, first seen Oct 4, 2026
Used with
Projects with it also use setup-ts-deep-modules, writing-beats and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
loulanyueSkillsetup-ts-deep-modules
Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.
Also in 13 projects that use this
RoentekSkillwriting-beats
Writing, exploit — assemble raw material into a journey of beats, grounding each term before a beat leans on it.
Also in 16 projects that use this
RoentekSkillwriting-shape
Writing, exploit — shape raw material into an article, paragraph by paragraph.
Also in 16 projects that use this
pahwarangerSkillsetup-skills
Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's ticket tracker (GitHub or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `to-tickets`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the ticket tracker, triage labels, or domain docs.
Also in 5 projects that use this
qwlabsSkillclaude-handoff
Hand the current conversation off to a fresh background agent that picks up the work immediately.
Also in 12 projects that use this
qhuang20Skillmigrate-to-shoehorn
Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.
Also in 14 projects that use this
- +2 more from Roentek
Other versions97 projects use a version of this.
Word for word · 0
None found.
Edited · 82
- mattpocock/skills★ 335k95% same
- aws/graph-explorer★ 48495% same
- niki914/zafiro★ 22195% same
- tt-a1i/matt-skills-with-to-goal★ 18295% same
- iamyoki/qwen-image-2.1-skill★ 14695% same
- murray17/rovai-ai★ 12297% same
- willdady/platypus★ 11499% same
- timharris707/skills★ 4036% same
- VoDaiLocz/kilo-kit-mcp★ 2795% same
- ConnorGriffin/skills★ 2227% same
72 more not listed
Wrote their own version · 15
- vinvcn/mattpocock-skills-zh-CN★ 4.6ksame name
- devcxl/mattpocock-skills-zh★ 426same name
- leandrocfe/skills★ 38same name
- aethrox/doctrine★ 18same name
- KroxiDev/engineering-skills★ 4same name
- jesse-merhi/skills★ 3same name
- shumingyang-opencode/mattpocock-skills-zh-tw★ 3same name
- YSAA1/harness-workflow★ 3same name
- dafaalz/agent-skills★ 2same name
- AkshitIreddy/agent-skills★ 1same name
5 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository50 other files it gives its agents.
- AGENTS.mdAGENTS.md
- core/AGENTS.mdAGENTS.md
- index/AGENTS.mdAGENTS.md
- mcp/AGENTS.mdAGENTS.md
- tools/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- analyze-specSkill
- auditSkill
- captureSkill
- catch-me-upSkill
- connect-brainSkill
- cortex-auditSkill
- cortex-briefSkill
- cortex-enrichSkill
- cortex-impactSkill
- cortex-installSkill
- cortex-nextSkill
- cortex-profileSkill
- cortex-reviewSkill
- cortex-scaffoldSkill
- cortexSkill
- cortex-skillsSkill
- cortex-viewSkill
- dailySkill
- diagnosing-bugsSkill
- domain-modelingSkill
- dreamSkill
- grillingSkill
- handoffSkill
- improve-codebase-architectureSkill
- install-projectSkill
- level-upSkill
- migrate-engineSkill
- onboardSkill
- optimize-contextSkill
- optimize-promptSkill
- plugin-syncSkill
- reindexSkill
- resolving-merge-conflictsSkill
- resumeSkill
- scan-projectsSkill
- setup-pluginsSkill
- shipSkill
- site-syncSkill
- skill-auditSkill
- skill-creatorSkill
- team-addSkill
- team-initSkill
- weekly-reviewSkill
- wizardSkill
The file
We split this skill into the rules it gives an agent
4 rules. 2 are common, 0 are distinctive, and 2 are very specific to this project.
2
Common
Most of the 87 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
When the document you're writing is a skill, read SKILL-MECHANICS.md for frontmatter, invocation choice, and router skills.
- Common: line 24
Every document and pointer you add spends one of two budgets:
- Common: line 49
Every step ends on a completion criterion — the condition that tells the agent the work is done.
- Very specific: line 99
Every document Cortex writes into a repo is one of these, so this is the authoring discipline behind the rituals that produce them:
“Common” is measured: kept by at least 6 in 10 of the 87 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.
Files
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 — the agent taking the same process every run, not producing the same output.
When the document you're writing is a skill, read 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 — the cost of always-loaded material on the agent's window: an
AGENTS.mdline, a skill description, anything sitting in context every turn, spending tokens and attention whether or not it fires. - Cognitive load — 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) — that 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:
- In-file step — the primary tier: what the agent does, in order.
- In-file reference — consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung) — a fine arrangement, not a smell.
- Disclosed reference — 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 — and 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.
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 — a fuzzy gate becomes 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.jsonscripts, config files, the directory layout,--helpoutput — 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. - Cite a name, not a line number — a
path:lineis a cache whose half-life is one edit anywhere above the thing it points at, and the split is by lifespan rather than by document type. A finding is consumed within hours and never re-read, sopath:linestays correct and required there: a review comment or a grounded role reviewer must keep giving it, because staleness cannot reach what nobody reads twice. A durable document — a brief, a skill, a comment meant to outlive its commit — is re-read for months, so it points at a function, a constant or a heading:markerLine, notfindings.mjs:196. The load-bearing half is that this one is checkable: tooling validates paths because a path is a name, so a line number is the citation form that opts out of verification. A rename is loud and shows up in a diff; a line moving from 196 to 218 is silent. Not hypothetical — this repo shipped exactly that inside one PR on one day, when an edit to an unrelated finding above the target shifted the cited line and left no trace. (Cortex addition to this section.) - 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.
What this governs in Cortex
Every document Cortex writes into a repo is one of these, so this is the authoring discipline behind the rituals that produce them:
| Cortex writes | Written by | The lever that matters most |
root AGENTS.md + the routing table | /cortex-scaffold | the table is a set of context pointers — their wording decides whether a leaf is ever reached |
scoped AGENTS.md leaves | /cortex-brief | disclosure: a leaf exists so the root stays legible |
CONTEXT.md | /domain-modeling | single source of truth — a term defined twice is defined nowhere |
skills/<name>/SKILL.md | /skill-creator | see SKILL-MECHANICS.md |
.cortex/memory/ digests | /dream | relevance — a digest that restates the diff is sediment on arrival |
Two Cortex-specific notes:
/optimize-contextis the audit; this is the discipline it audits against. When that ritual reports a repo's agent files as bloated, the findings are the levers here — sprawl, duplication, no-ops, a must-have target behind a weakly worded pointer. It never deletes prose on its own authority, so the judgement calls come back to the user.- Cortex sets
disable-model-invocation: truefor a second reason. Upstream weighs it purely as context load versus cognitive load. Cortex adds safety: a once-only or destructive ritual must never auto-fire, and that outranks the load trade. Keep the flag when editing their frontmatter.grep -l '^disable-model-invocation: true' skills/*/SKILL.mdis the list of record — anchor it, because this page and/skill-creatordiscuss the flag in prose and an unanchored grep counts them as carrying it.
The official rules this sits on
The levers above are judgement. The hard limits are Anthropic's, and a document that breaks one is wrong however well it reads. The pages that state them:
- Skills — the frontmatter keys Claude Code recognises
(anything else is ignored without an error; custom data goes under
metadata:),descriptionpluswhen_to_usetruncated at 1,536 characters,SKILL.mdkept under 500 lines. - Subagents — their own frontmatter keys, and the tool list a subagent inherits when it names none.
- Memory and
Best practices — how long a
CLAUDE.mdmay run,@pathimports, and emphasis that works on one line and stops working on many. - Hooks — which exit codes block, and which events can.
- Prompting Claude Opus 5.5 — effort, and a text-only end of turn read as a report rather than as proof the work is done.
Cortex carries each rule as data with the sentence that states it (core/claude-code.js), and its
findings report every breach under claude-setup/ — on this repo too, where any finding fails the
build.
Adapted from mattpocock/skills (MIT). The reference body
and SKILL-MECHANICS.md are upstream and unmodified apart from the citation bullet under Pruning,
which is marked in place so a re-sync can tell it apart; "What this governs in Cortex" and "The
official rules this sits on" are Cortex additions.
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
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.

