Products & Toolsagent hooksnano stagedllm safeguardsdevtools

Evil Martians Recommends Agent Hooks and nano-staged for LLM Safeguards

||By LDS Team
6.2
Relevance Score
Evil Martians Recommends Agent Hooks and nano-staged for LLM Safeguards
Photo: evilmartians.com · rights & takedowns

Evil Martians published a May 26, 2026 blog post advising developers to move LLM safeguard rules out of AGENTS.md and into automated hooks and linters, attributing the guidance to a post authored by Irina Nazarova. The post demonstrates a short setup: install nano-staged, add a .nano-staged.json mapping file types to linters (examples include oxfmt, oxlint, and stylelint), and attach the command to an agent hook via a .claude/settings.json snippet. It also recommends adding husky to run nano-staged on git commit. This approach reduces token costs and tightens the agent feedback loop by running linters only on changed files instead of re-sending long AGENTS.md instructions to the LLM.

What happened

Per an Evil Martians blog post published May 26, 2026, the authors argue that teams should stop encoding behavioral rules and style constraints in AGENTS.md and instead run those checks through automated pre-commit / agent-hook tooling. The post, authored by Irina Nazarova, provides a concrete recipe: install nano-staged, create a .nano-staged.json that maps file globs to linters (the example shows oxfmt, oxlint, and stylelint), add a Stop hook in .claude/settings.json that runs ./node_modules/.bin/nano-staged --unstaged --quiet --bail || exit 2, and optionally add husky to invoke nano-staged on git commit.

Technical details

Per the post, the .nano-staged.json example runs linters only on changed files rather than the whole repository. The post shows inline command examples and recommends writing custom linter rules (for example, an ESLint rule) if an LLM repeats the same error, noting that doing so pushes the constraint into a deterministic check rather than relying on the agent to remember documentation text.

Editorial analysis - technical context

Moving checks from doc-based instructions into deterministic tooling is a common engineering pattern for reducing human error and variability. Running linters on changed files only cuts compute and latency compared with re-sending long documentation to an LLM, and integrating checks into pre-commit hooks or CI yields faster, reproducible feedback for developers and agents alike.

Context and significance

For teams building agent-driven developer workflows, the blog frames a pragmatic cost and reliability tradeoff: token and latency savings from not re-transmitting large AGENTS.md files, plus the lower flakiness of deterministic linters. This matters for practitioners who embed agents into developer loops because small, frequent feedback cycles are typically cheaper and easier to automate than relying on an LLM to enforce style and safety rules from free-text docs.

What to watch

Observers should watch adoption signals in open-source agent integrations and pre-commit templates: more templates that include nano-staged or equivalent per-file linters, example .claude/settings.json hook snippets, and community recipes for converting repeated LLM failure modes into custom linter rules. Also watch whether agent platforms add first-class support for running repository-scoped linters as agent hooks.

Key Points

  • 1Move LLM rules from AGENTS.md into automated hooks and linters to reduce token use and make enforcement deterministic.
  • 2Running linters on changed files with nano-staged trims compute and speeds feedback compared with re-sending full docs to the model.
  • 3Embedding checks in pre-commit hooks or CI creates reproducible, low-flakiness safeguards that are easier to maintain than prose-based rules.

Scoring Rationale

Practical, actionable guidance for developer workflows integrating agents. Useful optimization for teams building agent loops, but not a paradigm-shifting release.

Sources

Public references used for this report.

1 source

Practice interview problems based on real data

1,625 SQL & Python problems across 15 industry datasets — the exact type of data you work with.

Try 250 free problems