用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/gmackie/agent-skills --skill writing-for-agents命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | writing-for-agents |
| description | Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md. |
| license | MIT |
| metadata | {"tags":"agent-instructions,context,skills","groups":"agent-authoring","invocation":"model","source":"https://github.com/mattpocock/skills@84fdeffd12f2ee307994d1eb6feb48173b6e0502:skills/productivity/writing-for-agents"} |
Use this reference when writing any document an agent consumes, including a skill, an AGENTS.md or CLAUDE.md, or a document reached by a pointer. The packaging differs, but the writing does not. The same levers make the agent follow a predictable process on every run without forcing the same output.
When the document you're writing is a skill, read SKILL-MECHANICS.md for frontmatter, invocation choice, and router skills.
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 document 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. It states what the material is and lists 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 prune it even harder than the body:
Every document and pointer you add spends one of two budgets:
AGENTS.md line, a skill description, or anything else in context every turn spends tokens and attention whether or not it fires.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.
A document is built from two content types that mix freely. Steps are the ordered actions the agent performs. Reference contains definitions, rules, and facts consulted on demand. A document may contain only steps, only reference, or both. The core decision is where each piece sits on the information hierarchy, a ladder ranked by how soon the agent needs the material:
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 moves material down the ladder, out of the main file and behind a pointer, so the top stays legible. Its primary purpose is to protect the hierarchy, not to optimize tokens. Branching is the cleanest disclosure test: inline what every branch needs, and put behind a pointer what only some branches reach. When a document has steps, in-file reference that should be disclosed buries them. Whether the agent attends to them becomes a coin flip, which affects variance as well as legibility.
Co-location is the within-file companion. 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 instead of scattering them. Reading one part then brings its neighbours with it. The document should read like documentation written for the agent. Grouped material does; scattered material does not. This differs from duplication, which repeats one meaning in two places. Scattering fragments one meaning across many places.
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.
Every step ends on a completion criterion, which tells the agent when the work is done. Two properties make it useful:
The strongest criteria are both checkable and exhaustive.
Splitting one document into two spends one of the two loads, so split only when the cut earns it:
SKILL-MECHANICS.md.A leading word is a compact concept that already lives in the model's pretraining and that the agent thinks with while running the document, such as lesson, fog of war, or tracer bullets. Repeated as a token, never as a sentence, it accumulates a distributed definition and anchors a whole region of behaviour in few tokens by recruiting priors the model already holds. You can coin your own if you define it clearly, but a made-up word recruits no priors. You pay in definition tokens for what a pretrained word gives free, so 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 or a pointer spending a sentence to gesture at one idea can collapse into a single token:
You gain fewer tokens and a sharper hook for the agent's thinking. Assume every document carries restatements that leading words can 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 that the strongly activated concept overruns, so the ban partly reads as an instruction to do the thing. Prompt the positive. State the target behaviour, such as "write one-line comments", so the banned behaviour 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.
package.json scripts, config files, the directory layout, and --help output. A document that restates the environment is a cache, a copy of a lookup that earns its load only when the lookup is expensive. Cache what the agent cannot find by looking: the unwritten convention, the reason behind a choice, or the gotcha no config reveals. Leave one-file and one-command lookups to the environment, where they cannot go stale.