Contract-Driven Agentic Loop (CDAL)
"Your agents write the code. CDAL makes it shippable."
Autonomous AI coding agents (Claude Code, Codex, Cursor, Gemini/Antigravity) write code at incredible speed. However, without external physical constraints, agents exhibit predictable failure modes:
- Self-grading: The agent writes the code, breaks a test, then rewrites the test assertions so everything appears "green".
- Silent degradation: Silencing type errors with
@ts-ignoreandas any, skipping broken tests with.skip(), or leaking hardcoded API keys. - Specification drift: Disconnecting code implementation from core business requirements over multi-turn agent sessions.
CDAL Kit solves this by establishing contract-driven development with enforceable physical quality gates:
PLAN ──► CONTRACT ──► RED ──► GREEN ──► VERIFY ──► REVIEW ──► INTEGRATE
Core Pillars of CDAL
- Contracts as the Single Source of Truth (
*.contract.mjs): Declarative domain invariants and state machines defined in pure ECMAScript. No build step required. - Deterministic Code & Docs Generation (
cdal codegen): Emits immutable TypeScript types and Mermaid diagrams directly from contracts. Zero manual sync drift. - Physical Role Scoping (
denyTests: true): Theimplementerrole is physically blocked by PreToolUse hooks (exit code 2) from modifying test files. The developer cannot grade their own work. - Traceability Matrix (
cdal trace --enforce): Every requirement (REQ-*) is mapped 1:1 to automated test suites tagged with// @REQ: <ID>. - Mutation Testing for Gates (
cdal selftest): Proves that your quality gates are not decorative by deliberately injecting mutations and verifying that every validator invariant fails red. - Zero Runtime Dependencies in Core:
@cdal/coreis pure Node.js ESM. PreToolUse hooks execute in under 150ms p95.
Navigation & Guide
- Getting Started: Install CDAL and initialize your first repository in 3 minutes.
- Concepts: Dive into contracts, kinds, roles, the loop, and quality gates.
- CLI Reference: Detailed options and flags for all
cdalcommands. - Runtime Adapters: Setup Claude Code hooks, AGENTS.md, Cursor rules, and Antigravity.
- Custom Kinds: Build and test custom contract abstractions with full mutation testing.
- Quick start in Polish: The getting-started guide in Polish (10 minutes).