No. 056 Write the change
Validate src/api request bodies
Use when the behavior is already chosen and a file should change
- Claude Code
- Codex
- Cursor
- Write the change
--- paths: - "src/api/**/*.ts" --- - Validate request bodies with the zod schemas in src/api/schemas/, don't hand-roll checks - Every new endpoint needs an entry in openapi.yaml, CI fails without it
When to use
“Validate src/api request bodies” fits when the behavior is already chosen and a file should change, because it says “paths:”, and it is written to stay in force on later turns rather than to finish one task.
With “Validate src/api request bodies” loaded, the user message can be as small as “fix the empty-cart total in src/cart.js and do not touch the test runner”, because “paths:” is already in force.
When not to use
Leave “Validate src/api request bodies” unused when you only wanted the file explained, or two designs are still open, because “paths:” points the other way
How to run it
Claude Code
Claude Code loads “Validate src/api request bodies” from .claude/rules on later sessions, so “paths:” survives a new chat, which a one-off paste does not.
Codex
Codex keeps “Validate src/api request bodies” only if you put “paths:” in AGENTS.md, or in AGENTS.override.md beside the directory that should inherit it. A paste that is not saved is gone next thread.
Cursor
Cursor keeps “Validate src/api request bodies” by saving “paths:” as .cursor/rules. The chat transcript alone will not reload it tomorrow.
Comparison
对比待补
This before-and-after was not run on this machine.
Related
- Stage: Write the change
- Same stage: Update user.ts to add the null check you suggested
来源:Anthropic · https://code.claude.com/docs/en/best-practices · 2026-12-01