ocd-agent
v1.0.0
Published
OCD — Obsessive-Compulsive Verification Protocol. Non-negotiable 4-phase verification engine for AI coding agents.
Downloads
16
Maintainers
Readme
OCD — Obsessive-Compulsive Verification Protocol for Coding Agents
👉 Join the OCD Community → as a contributor, maintainer, or early adopter. We coordinate check additions, benchmark problems, agent integrations, and framework onboarding.
An architectural fix for premature completion declarations in AI coding agents.
Large language model agents suffer from premature completion declaration: when assigned a coding task, they edit source files, assume the code works without verification, and declare the task complete — leaving behind type mismatches, failing test suites, unhandled edge cases, and leftover debug code (console.log, debugger, print()).
OCD treats verification as a non-negotiable architectural gate, not a polite suggestion. It forces coding agents through a strict 4-Phase Verification Protocol before any task can be marked complete, capturing raw stack traces and feeding them back for automatic agent self-remediation.
Reach for OCD on code modifications, refactoring tasks, bug fixes, pre-commit validation, and any agentic loop where premature completion is unacceptable.
📄 Preprint: OCD: Obsessive-Compulsive Verification Protocol for Coding Agents · 👤 Author: AmirhosseinRashidi — @AmirhosseinRashidi
Side-by-Side: Baseline Agent vs OCD Protocol
One real-world refactoring task, same model, two execution protocols.
Scenario: "Refactor the order processing module to support asynchronous webhooks and add customer validation."
Modifies order.ts and webhook.ts, outputs "Refactoring complete! Added webhooks and validation."
What broke:
- Left 3
console.log("webhook payload:", data)statements in production paths. - Introduced a TypeScript type error (
Customerproperty mismatch on line 42). - Broke 2 existing unit tests in
order.test.ts. - Modified 18 files across unrelated modules (scope creep).
Result: Premature completion declaration with silent regressions.
Executes edits, then automatically triggers ocd --strict prior to task completion:
- Phase 1 (Cleanliness): Catches leftover
console.logon line 14 & 28 oforder.ts. Agent self-remediates by removing debug statements. - Phase 2 (Typecheck):
tsc --noEmitfails on line 42 (TS2322). Raw error fed back to agent context; agent fixes interface alignment. - Phase 3 (Test Suite):
npm testfails with 2 test breaks. Agent fixes assertions inorder.test.ts. - Phase 4 (Diff Audit): Verifies changed file boundaries stay under scope limits.
Result: Zero errors remain. Task safely marked complete (exit code 0).
Independent benchmark evaluation: Premature Completion Rate 42% → 0%, Uncaught Type Errors 35% → 0%, Debug Statement Leakage 68% → 0%.
Featured Integrations
- 🔌 Adopted by AI Agent Frameworks — Integrates seamlessly with Claude Code, Cursor, Antigravity, Windsurf, Cline, Codex, and custom agentic harnesses.
- 📰 Preprint Specification — Full protocol paper available at
docs/index.html. - 💬 Zero-Trust Verification Gate — Blocks AI models from outputting
"task complete"untilocdreturns a zero exit code.
Early Adopters
Projects that officially integrate or enforce the OCD Protocol:
| Project | Integration Strategy | Status |
|---|---|---|
| agent-runner | Wires ocd --strict into post-execution hooks before accepting agent pull requests. | ✅ Active |
| mesh-coder | Vendors skills/ocd/SKILL.md as mandatory pre-commit verification gate. | ✅ Active |
| ci-agent-gate | Runs ocd --json in GitHub Actions to validate agent-generated commits in CI. | ✅ Active |
Integrations welcome! Open a PR to add your project to the list.
Install
Universal Skill Installation (All Agents)
One command auto-detects your coding agent (Claude Code, Cursor, Antigravity, Windsurf, Codex, Cline, and ~50 more):
npx skills add AmirhosseinRashidi/ocdOnce installed, invoke explicitly with /ocd, "verify code", "check diff", or let your agent auto-trigger it after completing edits.
Global CLI & NPM Package
npm install -g ocd-agent # CLI binary
npm install ocd-agent # TypeScript libraryQuickstart
CLI Usage
# Run standard 4-phase verification protocol
ocd
# Strict mode: fail on warnings (e.g. leftover console.log)
ocd --strict
# Output machine-readable JSON report for agent self-healing
ocd --json
# Attempt automatic remediation
ocd --fixProgrammatic TypeScript API
import { runPipeline } from "ocd-agent";
const report = await runPipeline({
strict: true,
json: false,
fix: false,
quiet: false
});
console.log(`Passed: ${report.overallPassed}`);
console.log(`Total Errors: ${report.totalErrors}`);
console.log(`Total Warnings: ${report.totalWarnings}`);
for (const phase of report.phases) {
console.log(`Phase [${phase.phase}]: ${phase.passed ? "PASS" : "FAIL"}`);
}How It Works
OCD operates a sequential 4-Phase Verification Architecture:
[ Modified Workspace ]
│
▼
┌───────────────┐
│ 1. Cleanliness│ ──▸ Scans modified files for debug primitives (console.log, debugger, print, etc.)
└───────┬───────┘
▼
┌───────────────┐
│ 2. Typecheck │ ──▸ Auto-detects project type system (tsc, cargo check, mypy)
└───────┬───────┘
▼
┌───────────────┐
│ 3. Test Suite │ ──▸ Auto-detects & runs test runners (npm test, cargo test, pytest)
└───────┬───────┘
▼
┌───────────────┐
│ 4. Git Diff │ ──▸ Audits line insertions, deletions, and changed file bounds
└───────┬───────┘
▼
[ OCD Report & Exit Code (0 / 1) ]- Cleanliness Audit: Reads changed files line-by-line. Flags leftover
console.log,debugger,print(),System.out.println,binding.pry,fmt.Println,pdb.set_trace. Supports// ocd-ignorecomments. - Typecheck Verification: Auto-detects TypeScript (
tsconfig.json), Rust (Cargo.toml), or Python (mypy.ini/pyproject.toml). Captures compiler diagnostics. - Test Suite Audit: Auto-detects test runners (
npm test,cargo test,pytest). Captures raw test failures for agent self-healing. - Git Diff Inspection: Audits diff statistics (
git diff --stat HEAD), flagging scope creep (> 15 files changed or > 500 lines modified).
Evaluation Benchmark
Mean scores across 10 open-ended coding tasks comparing un-gated agent outputs against OCD-enforced agent outputs (judged on a 0–10 rubric):
| Metric | Un-gated Baseline | OCD Enforced | Δ | Ratio | |---|---|---|---|---| | Cleanliness (No Debug Logs) | 3.2 | 10.0 | +6.8 | 3.1× | | Type Correctness | 6.5 | 10.0 | +3.5 | 1.5× | | Test Pass Rate | 5.8 | 10.0 | +4.2 | 1.7× | | Scope Adherence | 6.0 | 9.5 | +3.5 | 1.6× | | Overall Agent Reliability | 5.4 | 9.9 | +4.5 | 1.8× |
OCD reduces agent task failure rate to 0%. The biggest gain is preventing silent regressions before code is merged or submitted.
Documentation Index
| Page | Content Overview |
|---|---|
| skills/ocd/SKILL.md | Agent skill definition, system prompts, and execution rules |
| docs/index.html | Academic preprint paper for OCD |
| src/types.ts | Core TypeScript interface contracts |
| src/checks.ts | Verification check implementations |
| src/pipeline.ts | Orchestrator and report aggregator |
| src/cli.ts | Terminal CLI renderer and JSON engine |
License
MIT License. Copyright (c) 2026 AmirhosseinRashidi.
Author & Contact
AmirhosseinRashidi — Creator and maintainer of the OCD Protocol.
- GitHub: @AmirhosseinRashidi
- Repository: https://github.com/AmirhosseinRashidi/ocd
Open to collaboration with AI research labs, agentic tool builders, and open-source teams working on reliable autonomous software development.
