CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
Agent hooks for TDD and command rules
Probity sits between your agent and the actions it wants to take. It reads session context, checks writes and commands against deterministic or AI-validated rules, and tells the agent how to recover when a step is not allowed. The built-in rules cover TDD, command blocking, required commands, content patterns, and filename casing.
Builders who want their agent to follow TDD and safety rules while editing code.
You can keep an agent on a TDD path and stop unsafe writes or commands before they land.
What it does
Enforce test-driven development
The built-in `enforceTdd()` rule requires a failing test first, then the smallest code change, then refactoring on green.
Block risky shell commands
`forbidCommandPattern()` stops commands that match a pattern, such as destructive operations.
Require prior steps
`requireCommand()` can require a command to happen first, such as running tests before commit.
Block unwanted file content
`forbidContentPattern()` prevents writes that contain a matching string or regex.
Enforce filename casing
`enforceFilenameCasing()` keeps filenames in a chosen casing style.
Work across agent transcripts
Rules can read recent session activity so they can judge actions in context.
How to get it
- 1Run
npm install -D @nizos/probity
README
Probity
Probity forces AI coding agents to follow your rules. It hooks into your agent and checks every file write and shell command before it happens. When an action breaks a rule, Probity blocks it and tells the agent why.
You can use it to enforce Test-Driven Development with the built-in rule, block destructive commands, or keep unwanted patterns out of your code. Writing your own rules takes a few lines of TypeScript, and one config works across most coding agents.
Probity is featured on the Modern Software Engineering channel, where Emily Bache and Nizar Selander discuss what TDD looks like when an agent writes the code. A separate Q&A with factor10's Jimmy Nilsson covers using Probity on real projects, and links the full kata run.
How it works
When a rule is broken, the agent sees a reason and a path forward:
Probity: you're adding production code before a failing test has been
observed.
The next TDD-legal step is to add one focused test in src/cart.test.ts
and run it to a clean assertion failure before implementing only the
minimum code to pass it.
The agent corrects course and continues.
Rules can be deterministic, matching commands or file content by string or regex, or AI-validated using official SDKs. Both kinds can read recent session activity, so actions are judged in context.
Quick start
npm install -D @nizos/probity
Create probity.config.ts at your project root:
import { defineConfig, enforceTdd } from '@nizos/probity'
export default defineConfig({
rules: [
{
files: ['src/**', 'test/**'],
rules: [enforceTdd()],
},
],
})
Then wire it into your agent. One-time setup per agent.
Built-in rules
enforceTdd(): failing test first, minimal implementation, refactor on greenforbidCommandPattern(): block shell commands by patternrequireCommand(): require a prior command (e.g. tests before commit)forbidContentPattern(): block writes containing a patternenforceFilenameCasing(): enforce a filename casing style
FAQ
Does it work with my agent? Probity currently works with Claude Code, Codex, and GitHub Copilot CLI, with more coming.
Does it work with my language? Probity reads each agent's session transcript directly, so there are no per-framework reporters to install. It works with any language and test runner that your agent can work with.
Does Probity need its own API key or subscription? No. AI-validated rules use each vendor's official SDK and reuse whatever authentication your agent already has, so Probity doesn't require its own access or billing.
Does this cost extra tokens? AI-validated rules add a turn each time they check an action, so yes, some. Working in small TDD steps adds turns of its own, with or without Probity. Pattern-based rules add none.
Does enforcing TDD with an agent guarantee good design? Not on its own. Probity keeps the agent on track: a failing test before the code, the minimum to pass it, refactoring on green. That removes a lot of handholding and prompt fatigue. The shape the implementation and the tests take is still yours to steer.
I'm already using TDD Guard. Should I switch? Yes. Probity handles refactors and multi-step edits more reliably, is safe with parallel sessions, and supports more agents. See Migrating from TDD Guard.
Documentation
- Setup: wire Probity into your agent
- Configuration: config file shape, path scoping, and custom rules
- Rules: built-in rules and their options
- Migrating from TDD Guard: steps and customization mapping
Contributing
Contributions are welcome. See the contributing guidelines to get started.
License
Files in the repo
- .claude
- .claude-plugin
- .devcontainer
- .github
- .husky
- docs
- hooks
- src
- test
- .commitlintrc.json
- .gitignore
- .prettierignore
- .prettierrc.json
- CLAUDE.md
- CONTRIBUTING.md
- eslint.config.js
- LICENSE
- package-lock.json
- package.json
- probity.config.ts
- README.md
- tsconfig.build.json
- tsconfig.json
Discussion (0)
Ask about usage, or say what you built with itSign in to join the discussion.
No comments yet. Be the first to say what this is good for.
More hooks
Warcraft III Peon voice notifications (+ more!) for Claude Code, Codex, IDEs, and any AI agent. Stop babysitting your terminal. Employ a Peon today.
Read the Qur'an while Claude Code works. Start a session with 'claude --cwq' and a reader beside it walks forward through the Qur'an one ayah per prompt, resuming where you left off — in a terminal pane or a browser tab. Zero dependencies, fully offline.
Clean up Claude's token vomit with a separate LLM. Save your tokens, Opus is hopeless
A pre-execution guard for AI coding agents. It blocks destructive Git and file system commands, plus common attempts to access sensitive files, before a tool call runs. Supports Amp Code, Antigravity CLI, Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, Grok Build, Hermes Agent, Kimi Code, OpenClaw, OpenCode, and Pi.
Automated TDD enforcement for Claude Code