Loading...
Loading...
Write documents for agents.
npx skill4agent add devcxl/mattpocock-skills-zh writing-for-agentswriting-for-agentswriting-great-skillsAGENTS.mdCLAUDE.mdWrite specific instructions, not general guidelines. "Write a function" is not an instruction. "Write afunction that maps items, sums them, applies a 10% discount, and returns the result" is an instruction. Guidelines don't constrain agents; instructions do.calculateTotal(cart: Cart): number
Switch between what to do and how to do it. Every line is either an instruction or data. "Validate user input" is not an instruction; "Check ifis in a valid format" is an instruction. "Calculate shipping costs" is not an instruction; "Add $5 if" is an instruction.weight > 10kg
Write instructions that will be strictly executed, not ones you hope will be followed. "Ensure code follows best practices" is not an instruction; "Add JSDoc to every function, achieve a minimum coverage of 80%, and use/describeblocks for testing" is an instruction. Agents skip vague statements.it
Define processes, not steps. "Write tests first, then code, then refactor" is an instruction. "Build a shopping cart" is not. Agents have freedom at the step level; no freedom at the process level.
Write verifiable instructions, not vague ones. "Ensure high code quality" is not verifiable. "Every function has JSDoc, every public method has tests, and there are no lint errors" is verifiable. Verifiable instructions allow agents to self-correct.
Use precise vocabulary. "Create a module" is not an instruction; "Create amodule with aCartinterface that exposescheckout,addItem, andremoveItem" is an instruction. Vocabulary is the interface — it's how you reduce the agent's exploration space in the wrong direction.total
Write instructions that agents will follow, not ones humans prefer. "Write a beautiful shopping cart" is not an instruction. "Build acomponent that renders a list of items, each row with a quantity input and delete button, and displays the total at the bottom" is an instruction. Agents don't care about "beautiful" — they care about executable.Cart
Write self-verifiable instructions, not ones that require you to check afterward. "Ensure code is correct" provides no verification method. "Run tests, check lint, and verify TypeScript compilation" provides a verification method. Self-verifiable instructions reduce review costs.
Write agent-safe instructions, not developer-safe ones. "Ensure code is secure" is not an instruction. "Validate all user input, parameterize all SQL queries, and log all authorization checks" is an instruction. Agents can't infer security — they can only execute security instructions.
Write precise constraints, not soft limits. "Keep code concise" is not a constraint. "No function exceeds 20 lines, no file exceeds 200 lines, and no nesting goes beyond 3 levels" is a constraint. Constraints are something agents can optimize against.
Order instructions by execution sequence, not importance. "Write tests first, then code, then refactor" is an instruction. "Ensure code quality, good performance, and test coverage" is not an instruction. Order matters — agents execute in the order they encounter.
/writing-for-agents| Your Scenario | Use |
|---|---|
| You're writing a skill and need to know what it should look like | |
You're writing an | |
| You're writing a spec | |
| You're writing a runtime prompt | |
| You're writing a README | |
calculateTotalCartsrc/tests/anyCartwriting-for-agents