How it Works ​
Carotene bridges the gap between human architectural intent and rapid code generation through a strict, four-step pipeline: Parse, Infer, Generate, and Implement.
This pipeline ensures that every line of business logic written—whether by a human or an AI agent—is mathematically verified against your original design before it ever reaches production.
1. Parse (The Blueprint) ​
It all starts with your .carrot files. You define your data shapes (model), your storage layers (store, state), your structural boundaries (frontend, backend), and your behavioral guardrails (reads, mutates, calls).
When you run the Carotene CLI, the compiler parses these files into a language-agnostic Abstract Syntax Tree (AST). At this stage, Carotene validates the topology of your system. If you tell a frontend view to updates store.Databasedirectly without going through a backend function, the compiler catches the security violation and fails the build immediately.
2. Infer (The Engine) ​
Carotene does not want you writing thousands of lines of infrastructure boilerplate. Instead, it uses an Inference Engineto analyze your AST and apply sensible, industry-standard defaults based on context.
- Contextual Networking: If a frontend
callsa backend function, the compiler infers a standard JSON-RPC over HTTP request. If the frontendobservesa backend stream, the compiler infers a WebSocket connection with a pub/sub backplane. - Contextual Storage: A
storein the backend defaults to Postgres. Astorein an iOS frontend defaults to local SQLite.
You get "magic" when you want speed, and you use typed config blocks to explicitly override the defaults when you need granular control.
3. Generate (The Scaffolding) ​
Once the AST is validated and inferred, Carotene invokes its pluggable code generators for your target languages (TypeScript, Go, Rust, Swift, etc.).
Carotene generates a standard, idiomatic software project that includes:
- Data Layers: ORM schemas (e.g., Prisma/Drizzle), SQL migrations, and state management slices (e.g., Zustand/Redux).
- Networking: Fully typed API gateways, internal service mesh routing, and client SDKs.
- Test Suites: Read-only, deterministic test files generated directly from the
testblocks in your contract. - Implementation Stubs: Empty functions wrapped in dependency-injected boundaries.
The generated code is not a proprietary "black box." It is clean, readable infrastructure that looks exactly like what a senior platform engineer would write.
4. Implement & Verify (The Sandbox) ​
The final step is filling in the empty implementation stubs with custom business logic. This is where human engineers and AI agents collaborate.
- For AI Agents: Carotene runs a native Model Context Protocol (MCP) server. Your agent (Claude Code, Cursor, etc.) connects to the CLI, reads the contract, understands the exact inputs/outputs, and writes the logic.
- The Sandbox: Before the code is accepted, Carotene runs the generated tests in a Permissionless Sandbox.
- If the AI hallucinated an unauthorized network call (
fetch('https://evil.com')), the sandbox crashes. - If the AI tries to write to the database when the contract only permitted
reads, the dependency-injected database client throws a type error.
- If the AI hallucinated an unauthorized network call (
The AI receives the exact sandbox error trace, autonomously corrects its logic, and tries again. Once the sandbox passes, you have a mathematically verified, secure, and fully architected application ready for deployment.