Skip to content

Guards

Every guard, what it catches, and exactly when it runs while your AI agent works.

Guards are checks that run by themselves while your agent works. You don’t ask for them and the agent doesn’t have to remember them.

They come with the plugin:

npx lintsure plugin

It works for Claude Code, Cursor, Codex and Gemini CLI. The guards for the last three are new, so tell us if one misbehaves. Plugin and agent adapters has the install detail.

Every guard at a glance

Guard Catches When it runs What happens
Drift Guard An edit that breaks one of your project’s rules Before the edit in strict mode, right after it otherwise Refuses the edit, or tells the agent
Made-up code An import of a file or package that doesn’t exist, a call to a function that doesn’t exist, a copy of code you already have Right after the file is saved Tells the agent
Secret Guard A key or password written into a file Right after the file is saved Tells the agent to move it to an environment variable
Test Guard A test skipped, deleted, or changed so it can’t fail Right after the file is saved Tells the agent
Package Guard A new package whose name is one letter off a well-known one Right after the file is saved Asks you
Scope Guard A change to CI, to a .env file, or to a file that sets the rules Right after the file is saved Asks you
Privacy Guard Personal data written to a log Right after the file is saved Tells the agent
Danger Guard A shell command that deletes, leaks or hides something Before the command runs Asks you, with the reason
Threat Guard Known AI attack tooling Before the command or edit Asks you
Loop Guard The same call five times with nothing changing After the call Tells the agent to change approach
End-of-task check Anything the scan finds in the files that changed When the agent finishes a task Lists the findings

Before, or just after

This is worth being exact about.

Before the edit lands. Only your own rules can do this, and only in strict mode. The edit is refused and the agent is told which rule it broke.

Just after the file is saved. Everything else that looks at an edit. The file is on your disk for a moment with the problem in it. The guard tells the agent, and the agent fixes it in the same session. Nothing has been committed.

Before a command runs. Danger Guard and Threat Guard. The command waits for your answer.

So if a key is written into a file, it is caught seconds later, before any commit. But it was in the file. If it is a real key, treat it as seen and replace it.

Tells the agent, or asks you

Guards sort what they find into two kinds.

  • A slip the agent can fix itself. A made-up import, a skipped test, a key in a file. The agent is told and carries on.
  • A choice that is yours. A new package, a change to CI, a rule you wrote. The agent asks you once and does what you say.

Nothing is decided for you, and an edit you asked for by name is never treated as a mistake.

The files that set the rules

Some files tell agents and reviewers what to do: CLAUDE.md, AGENTS.md, REVIEW.md, CODEOWNERS, your agent’s settings, an approval policy, and git hooks.

A change to one of these changes what every later check looks for. So when an agent edits one that already exists, Scope Guard puts it to you. Creating a new one is fine.

Guards and your project’s rules

Guards read the rules of the project the edited file is in: the nearest folder above it with a .lintsure folder. So one session can work across several projects and each keeps its own rules. See One agent, many projects.

What guards don’t do

  • They don’t see commits an agent makes with git hooks switched off. Some agents commit and push that way. A check that must never be skipped belongs in CI: use the GitHub Action.
  • They don’t judge your design. They catch rule breaks. A pull request review is still worth having.
  • They don’t run in a chat window on the web. They need an agent that runs on your machine.

Switch one off

Each guard has a setting. Plugin and agent adapters lists them.

Lintsure is a readiness tool, not an audit or legal advice. Results cover code only; a qualified person should review them. Disclaimer