Getting Started with CDAL
CDAL works with both existing TypeScript/JavaScript applications (Next.js, Node services, monorepos) and clean greenfield projects.
1. Quick Audit (Zero Installation)
Before making any changes to your project, you can run a local, read-only AI hygiene audit on your repository:
npx cdalkit audit
This scans your codebase locally in < 15 seconds (zero network calls, zero data leaks) and generates a standalone offline HTML report evaluating:
- Agent runtime setup & PreToolUse hooks
- Type silencing density (
@ts-ignore,as any) - Muted or isolated tests (
it.skip,describe.only) - "Self-grading agent" commit patterns
- Requirements traceability (
@REQ) - CI quality gates and secret leaks
2. Initialize CDAL in Your Project
Run the interactive setup wizard in the root of your project:
npx cdalkit init
Or run non-interactively with safe default presets:
npx cdalkit init --preset typescript-strict --yes
This generates:
cdal.config.mjs: Central configuration defining contracts, roles, forbidden rules, and verification steps.contracts/requirements.contract.mjs: Starter contract with traceable business requirements..claude/settings.json: PreToolUse hook router for Claude Code subagent roles.AGENTS.mdand.cursor/rules/cdal.mdc: Universal agent instructions for Cursor, Codex, and OpenHands.- Verification script in
package.json:"verify": "cdal verify".
3. Verify Your Initial Setup
Run the deterministic verification pipeline:
npx cdalkit verify
CDAL executes each step sequentially:
cdal validate --strict— Contract invariants checkcdal codegen --check— Drift detector for emitted TypeScript typespnpm typecheck— TypeScript strict type validationpnpm test— Automated test suitecdal trace --enforce— Ensures all active requirements have@REQ:test coveragecdal selftest— Mutation testing of the quality gates
4. Run the First Agent Cycle
When launching an agent (e.g., in Claude Code):
- PLAN: Specify work order requirements with explicit IDs in
docs/workorders/(e.g.AUTH-REQ-LOGIN). - CONTRACT: Define or update the domain contract:
npx cdalkit window open AUTH-101 # Edit contracts/requirements.contract.mjs npx cdalkit window close npx cdalkit codegen - RED: Author failing tests in
test/auth.test.tstagged with// @REQ: AUTH-REQ-LOGIN. - GREEN: Have the
implementeragent role implement the feature. Notice that if the agent attempts to edittest/auth.test.ts, the PreToolUse hook immediately rejects the write with exit code 2. - VERIFY: Run
npx cdalkit verifyto seal the loop.