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, Cursor, Codex) 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, Cursor)"]

    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, 366+ 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": "",
        "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/instructions.md

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.0.6 (2026-03-25)

โœ… 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
  • 366+ tests covering all stages, adapters, and checkpoint engine

Latest Updates (v1.0.1 โ†’ v1.0.6):

  • 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

โณ 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 (366+ total)
make test

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

# With coverage report
make test-cov

Test breakdown:

  • 200+ unit tests (syntax, lint, typecheck, tests, security stages)
  • 100+ integration tests (full pipeline with real tools)
  • 60+ adapter and checkpoint tests
  • 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.1.0.tar.gz (303.7 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.1.0-py3-none-any.whl (128.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: detent-1.1.0.tar.gz
  • Upload date:
  • Size: 303.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for detent-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2f9fdc72c8ab3667736a2afe768196ce5582336d93f5acb8482e1808e55b4984
MD5 63e623f5a8747ffb8c7d9d7fb2327287
BLAKE2b-256 59ff2626b946349715b01cb19239adf86f1cd7afd3c64c6f3a1840d2b78bfff0

See more details on using hashes here.

Provenance

The following attestation bundles were made for detent-1.1.0.tar.gz:

Publisher: publish.yml on ofircohen205/detent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: detent-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 128.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for detent-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8aa4cebc26aa9ad3f36da9d3804300eca662815b4b577bc80894a0c64f71f52d
MD5 742de1565e9f2f3a0e3e41fc11299d5b
BLAKE2b-256 5065f622d18ea9042ecccc3d2d1e77c25367fe5209920949886249a7a95f5bf0

See more details on using hashes here.

Provenance

The following attestation bundles were made for detent-1.1.0-py3-none-any.whl:

Publisher: publish.yml on ofircohen205/detent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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