Instead of writing code style rules and safeguards in AGENTS.md files, use agent hooks (Claude Code, OpenAI Codex) combined with nano-staged to automatically run linters and formatters on changed files only. This approach is more reliable because LLMs often forget AGENTS.md instructions, faster because tools like oxlint and oxfmt are 5-10x quicker than ESLint/Prettier, and cheaper in tokens. The setup involves installing nano-staged, configuring linters per file type, and wiring a Stop hook in .claude/settings.json that exits with code 2 to continue the conversation when linting fails. A guard script prevents infinite loops when running unsupervised. The broader principle: every rule encoded as automation is a rule the LLM cannot forget.
Table of contents
The extremely short versionAutomatic safeguardsThe reason safeguard performance mattersQuick toolsPostCSS creator shares how to make your open source popularAgent hooksPre-commit hooksSort: