Back to .md Directory

ContractSpec Codebase

**Mission**: ContractSpec is the deterministic, spec-first compiler that keeps AI-written software coherent, safe, and regenerable.

May 2, 2026
0 downloads
1 views
ai agent safety
View source

ContractSpec Codebase

Mission: ContractSpec is the deterministic, spec-first compiler that keeps AI-written software coherent, safe, and regenerable.

Quick Reference

ConcernRule FileKey Points
Contractscontracts-first.mdSpec before implementation
Mission & Contextcontractspec-mission.mdWhy we exist, who we serve
Architecturepackage-architecture.mdlibs → bundles → apps
Code Qualitycode-quality-practices.mdTesting, naming, standards
File Organizationcode-splitting.mdMax 250 lines, domain grouping
Type Safetytype-safety-dependencies.mdNo any, latest deps
Frontendfrontend.mdAtomic design, state handling
Backendbackend.mdHexagonal, DDD
Design Systemdesign-system-usage.mdNo raw HTML
AI Governanceai-agent.mdTraceability, composability
Documentationdocs.mdDocBlocks first

Core Principles

  1. Spec-First: Contracts define behavior before implementation
  2. Multi-Surface Consistency: One spec → API, DB, UI, events
  3. Safe Regeneration: Code can be regenerated without breaking invariants
  4. Standard Tech: TypeScript, Zod, no magic abstractions
  5. Incremental Adoption: Stabilize one module at a time

Code Style (Enforced)

  • Language: TypeScript (strict mode)
  • Formatting: 2 spaces, semicolons, double quotes, trailing commas
  • Types: Explicit, no any, proper type guards
  • Files: Max 250 lines (components: 150, utilities: 100)

Before You Code

  1. Read relevant rules for your change type
  2. Check existing patterns in the codebase
  3. Plan with DocBlocks if adding new features
  4. Run /ai-audit to verify decisions

AI Agent Guidelines

When working with AI assistants:

  • Rules are applied contextually based on file type
  • Conflicts resolved by: Security > Compliance > Safety > Quality > UX > Performance
  • All decisions should be traceable and reversible
  • Use /ai-audit to verify governance compliance

Commands Available

  • /commit - Create conventional commit
  • /test - Run tests with analysis
  • /lint - Check and fix lint issues
  • /fix - Auto-fix common issues
  • /explain - Understand code
  • /refactor - Guided refactoring
  • /review-pr - Code review
  • /ai-audit - Governance check

Getting Help

  • Check the specific rule file for detailed guidance
  • Use /explain <concept> for architecture questions
  • Run /ai-audit to verify your approach

Related Documents