B
Blocks
Specification

Blocks Specification v2.0

Guardrails that keep your agentic code generation aligned with your domain

Blocks is a development-time validation framework for AI-generated code. It creates a feedback loop where AI agents (like Claude Code) can iteratively run validation until all code aligns with domain requirements.

Key Innovation

Unlike runtime validation frameworks, Blocks validates source code intent at development time, treating code as the artifact to validate.

Same input → Same code → Same output

If source code passes validation during development, it will produce correct output at runtime.

What Blocks Solves

For AI-generated codebases, Blocks addresses three interconnected problems:

  1. Catching AI mistakes - LLMs hallucinate; Blocks catches semantic errors before they ship
  2. Enforcing standards - Consistent patterns across AI-generated code
  3. Domain alignment - AI stays within business domain boundaries

The Feedback Loop

┌─────────────────────────────────────────────────────────┐
│                                                         │
│   AI Agent (Claude Code, etc.)                          │
│        │                                                │
│        ▼                                                │
│   Generate/Modify Code                                  │
│        │                                                │
│        ▼                                                │
│   blocks run --all                                      │
│        │                                                │
│        ├── Pass ──► Done                                │
│        │                                                │
│        └── Fail ──► Read errors, fix code, repeat       │
│                                                         │
└─────────────────────────────────────────────────────────┘

Quick Reference

ConceptDescription
$schemaVersion declaration: "blocks/v2"
philosophyAI context for domain validator
domain.entitiesCore data types with fields
domain.semanticsDomain vocabulary (merged signals + measures)
validatorsValidation pipeline configuration
blocksBlock definitions with inputs/outputs
aiAI provider configuration
cacheCaching configuration

Design Principles

DecisionChoiceRationale
Philosophy enforcementAI context onlyLet AI interpret, don't over-engineer
Entity typesSimple fieldsKeep accessible, compile to JSON Schema internally
Signals + MeasuresMerged as "semantics"Same concept, reduce confusion
Rule inheritanceAuto-mergeDRY without complexity
Path resolutionExplicit pathsRemove ambiguity
Validation flowAlways run allComplete diagnostics matter
Cache expiryContent-hash onlyDeterministic behavior
AI failuresConfigurableDifferent contexts need different behavior

Next Steps