Skip to main content

A verification runtime that intercepts AI coding agent file writes, runs them through a configurable verification pipeline, and rolls back atomically on failure.

Project description

Detent โ€” Verification Runtime for AI Agents

Intercept. Verify. Rollback. A verification runtime that sits between AI coding agents and the filesystem, running every proposed file write through a configurable verification pipeline and atomically rolling back on failure.

The Problem

AI coding agents (Claude Code, Codex, Gemini) are powerful but unpredictable. They can write broken code, introduce security issues, or corrupt your codebaseโ€”all silently, before you notice.

Existing solutions are slow:

  • Code review tools require human review (defeats the purpose of agents)
  • CI/CD runs tests after code hits the repo (too late to prevent damage)
  • Linters in editors are superficial (don't catch logic errors or test failures)

You need a protocol-level verification layer that intercepts tool calls in real time, before they hit the filesystem.

What Detent Does

graph TD
    Agent["๐Ÿค– AI Agent (e.g., Claude Code, Codex, Gemini)"]

    subgraph DV["Detent Verification Runtime"]
        S1["1. Create SAVEPOINT (checkpoint)"]
        S2["2. Run Verification Pipeline:<br>- Syntax check (tree-sitter)<br>- Lint (ruff, ESLint, clippy, go vet)<br>- Type check (mypy, tsc, cargo check, go build)<br>- Test execution (pytest, jest, cargo test, go test)<br>- Security scan (semgrep, bandit)"]
        S3["3. Synthesize feedback"]
    end

    FS[("๐Ÿ’พ Filesystem (protected)")]

    Agent -->|tool call: Write src/main.py, content| S1
    S1 --> S2
    S2 --> S3
    S3 -->|โœ… passed? โ†’ allow write| FS
    S3 -.->|โŒ failed? โ†’ rollback| S1

Key Features

โœ… Real-time interception โ€” Catches bad code before it hits your repo โœ… Composable verification โ€” Chain stages: syntax โ†’ lint โ†’ typecheck โ†’ tests โ†’ security โœ… Atomic rollback โ€” SAVEPOINT semantics for file operations โœ… LLM-optimized feedback โ€” Structured JSON that helps agents self-repair โœ… Multi-language support โ€” Python, JavaScript/TypeScript, Go, Rust โœ… Four agent adapters โ€” Claude Code, Codex, Gemini (hook-based enforcement); LangGraph (VerificationNode) โœ… Production-ready โ€” Security hardened, telemetry, circuit breakers, 427+ tests โœ… CLI + Python SDK โ€” Use standalone or integrate with agents

How It Differs

Feature Detent Code Review CI/CD Linters
Real-time interception โœ… โŒ โŒ โœ… (editor only)
Prevents bad code โœ… โŒ โŒ โœ… (superficial)
Atomic rollback โœ… โŒ โŒ โŒ
Runs tests โœ… โœ… โœ… โŒ
Agent-aware feedback โœ… โŒ โŒ โŒ
Multi-language โœ… โœ… โœ… โœ… (varies)

Quick Start

Install

pip install detent

Initialize in your project

cd my-project
detent init

The interactive wizard auto-detects your agent and writes detent.yaml. If you're using Claude Code or Codex, it also registers the hook automatically โ€” no manual config needed.

Connect Detent to your agent

Detent enforces at the tool execution layer (Point 2) via a pre-execution hook โ€” this is what blocks writes and triggers rollbacks. It optionally also runs an HTTP proxy (Point 1) for observability.

Claude Code (hook auto-configured by detent init):

detent proxy &   # start the proxy (Point 1 โ€” optional, for observability)
claude           # hook is already wired via .claude/settings.json

The hook in .claude/settings.json was written by detent init:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Write|Edit|NotebookEdit",
        "hooks": [{"type": "command", "command": "curl -s -X POST http://127.0.0.1:7070/hooks/claude-code -H 'Content-Type: application/json' -d @-"}]
      }
    ]
  }
}

Codex CLI (hook auto-configured by detent init):

detent proxy &        # start the proxy (also serves /hooks/codex)
export OPENAI_BASE_URL=http://127.0.0.1:7070   # Point 1 โ€” optional
codex                 # hook is wired via .codex/hooks.json

Gemini CLI:

detent proxy &   # start the proxy (serves /hooks/gemini)
# Register the BeforeTool hook in your Gemini CLI config:
# curl -s -X POST http://127.0.0.1:7070/hooks/gemini -H 'Content-Type: application/json' -d @-
gemini

LangGraph (no hook โ€” use VerificationNode instead):

from detent.adapters.langgraph import VerificationNode
graph.add_node("verify", VerificationNode(proxy))
graph.add_edge("agent", "verify")
graph.add_edge("verify", "tools")

Hook vs proxy: The hook (Point 2) is what enforces โ€” it intercepts each tool call before it executes, runs verification, and returns allow/deny. The proxy (Point 1) is observational only and does not block writes on its own. See AGENTS.md โ†’ Using Hooks vs Proxy for the full breakdown.

Verify a file manually

detent run src/main.py
โœ… Syntax: PASS
โœ… Lint (ruff): PASS
โœ… Type check (mypy): PASS
โœ… Tests (pytest): PASS

Verification passed. Checkpoint: chk_before_write_001

If verification fails:

โŒ Lint (ruff): FAIL
  src/main.py:5:1 - E501: line too long

Rolling back to checkpoint: chk_before_write_001

Check session state

detent status

Rollback if needed

detent rollback chk_before_write_001

Architecture

Two-Point Interception

Point 1: Conversation Layer โ€” HTTP reverse proxy intercepts LLM API traffic

  • Detects what the agent plans to do
  • Extracts tool calls from LLM responses

Point 2: Tool Execution Layer โ€” Agent adapters intercept tool calls

  • Enforces what the agent is allowed to do
  • Creates checkpoint, runs verification, controls execution

Components

  • Checkpoint Engine โ€” SAVEPOINT + rollback (in-memory + shadow git)
  • Verification Pipeline โ€” Composable stages (syntax, lint, typecheck, tests, security)
  • Feedback Synthesis โ€” LLM-optimized structured feedback
  • Agent Adapters โ€” Claude Code, Codex, Gemini (hook enforcement); LangGraph (VerificationNode); HTTP proxy for Claude Code + Codex
  • CLI โ€” detent init, detent run, detent status, detent rollback
  • Python SDK โ€” 27+ public APIs for programmatic use

Use Cases

Solo Developers

  • Verify code before committing to main
  • Catch mistakes in real time
  • Build confidence in agent-generated code

Teams

  • Prevent broken PRs from blocking CI
  • Faster code review (bad code never lands)
  • Enforce quality gates automatically

Research

  • Study agent error patterns
  • Benchmark verification techniques
  • Feedback synthesis for agent improvement

Project Status

Current Release: v1.2.0 (2026-03-29)

โœ… v1.0 (Production Ready) โ€” Released 2026-03-16

  • Multi-language support: Python, JavaScript/TypeScript, Go, Rust
  • Hook adapters for Claude Code, Codex, and Gemini (Point 2 enforcement); LangGraph VerificationNode
  • Security scanning (Semgrep + Bandit)
  • OpenTelemetry tracing, metrics, and circuit breakers
  • Security hardening: path traversal fixes, input validation, HTTP allowlist, dependency audit
  • GitHub Actions CI/CD with automated testing and security scanning
  • 427+ tests covering all stages, adapters, and checkpoint engine

v1.1.0 Updates:

  • Hook scope fix: Claude Code PreToolUse hook now fires only on file-write tools (Write|Edit|NotebookEdit), not every tool call
  • Codex hook config moved to .codex/hooks.json (was incorrectly using instructions.md)
  • Adapter-level FILE_WRITE filter as defense-in-depth across all hook adapters
  • Gemini adapter tool name normalization and FILE_WRITE guard
  • Adapter wiring and compatibility fixes (Claude Code, Codex, Gemini)
  • Dependency optimization (removed rich runtime dependency)
  • HTTP header handling improvements
  • Structured logging migration
  • Production stability improvements

v1.2.0 Updates:

  • SAST/DAST pipeline integration: secret scanning (detect-secrets) on every file write
  • Dependency vulnerability scanning (pip-audit) on requirements*.txt files via OSV database
  • 422+ tests covering all stages, adapters, and checkpoint engine

โณ v2.0 (Enterprise) โ€” Planned Q1 2027

  • Detent Cloud (SaaS platform)
  • Multi-agent orchestration
  • VS Code extension
  • Advanced analytics and insights

Development Phases

Phase Component Status
1 Schema, config, project setup โœ… Complete
2 Checkpoint engine โœ… Complete
3 Verification stages โœ… Complete
4 Verification pipeline โœ… Complete
5 Feedback synthesis โœ… Complete
6-8 Agent adapters, observability, security โœ… Complete

All core features shipped in v1.0. Ongoing work focuses on production reliability, performance optimization, and v2.0 planning.

Documentation

Testing

Detent has comprehensive test coverage:

# All tests (427+ total)
make test

# Unit tests only (fast, no external tool deps)
make test-unit

# With coverage report
make test-cov

Test breakdown:

  • 250+ unit tests (syntax, lint, typecheck, tests, security stages, adapters, checkpoint)
  • 100+ integration tests (full pipeline with real tools)
  • Security and regression tests

See DEVELOPMENT.md for detailed testing guidance.

License

Apache License 2.0 โ€” See LICENSE for details.

Community

  • GitHub Discussions โ€” Questions, ideas, show & tell
  • GitHub Issues โ€” Bugs, feature requests
  • Security โ€” Vulnerability reports via GitHub Security Advisories

Made with โค๏ธ for AI-assisted development

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

detent-1.2.0.tar.gz (333.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detent-1.2.0-py3-none-any.whl (133.6 kB view details)

Uploaded Python 3

File details

Details for the file detent-1.2.0.tar.gz.

File metadata

  • Download URL: detent-1.2.0.tar.gz
  • Upload date:
  • Size: 333.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for detent-1.2.0.tar.gz
Algorithm Hash digest
SHA256 39a0f0eb9b340f52dda91173f8712aec35d24399318c707df6161aea2d6186e3
MD5 f58e6977e8eb355d4b6e6bf205004c8f
BLAKE2b-256 4218688119e03bdd5246b4cf1252de9d780421211c06fbda1b30fa0588c46567

See more details on using hashes here.

File details

Details for the file detent-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: detent-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 133.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.2

File hashes

Hashes for detent-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d747cf9827f4f8dec235684898447e70a1f3615153cf7d420ed701bca7163ab
MD5 c71d668664f860396c2b59260fab0307
BLAKE2b-256 3ff8997ef8d1157f9b870b7c352237e45e22ed0df631edd01033954e8675dd2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page