Introduction
Cleat is a compiled, statically typed language for building auditable AI agent backends. It compiles to native binaries via Go — no interpreter, no runtime dependency, single-binary deploys.
What makes Cleat different:
- 8 compiler-enforced primitives —
agent,guard,tool,stream,state,chain,server, andfnare language constructs, not library abstractions. The compiler validates their contracts at build time. - Effect system — every side effect is declared with
needs. A function withoutneedsis pure. The compiler rejects programs that violate effect boundaries. - Type-safe structured LLM output — call an LLM and get back a typed struct. The compiler extracts a JSON Schema at build time from your type definition.
- Automatic correlation IDs — every HTTP request, agent call, tool dispatch, and log message in a request chain shares a single trace ID.
- Built-in testing with mocks —
testblocks andusingoverrides let you test agents and tools without API keys or network access.
Status
Cleat is in alpha. The compiler, formatter, test runner, language server, and standard library are implemented. 826+ tests across 11 packages. The language is usable for building AI backends, but the API may change.
A taste of Cleat
A code review agent that fetches a PR diff, analyzes it, and returns a typed review:
cleat
import "std/io" import "std/http" type ReviewResult = struct { fn">@description("Whether the code is safe to merge") approved: bool, issues: []string, summary: string, } tool fetch_diff(pr: int) -> Result[string, string] needs { net } timeout: 10s { let url = "https://api.github.com/repos/acme/app/pulls/${pr}" let resp: http.Response = http.get(url)? return Ok(resp.body) } agent Reviewer { model: "claude-sonnet-4-20250514" system: "You are a code reviewer. Fetch the PR diff, then provide a structured review." tool: [fetch_diff] max_turns: 10 needs { llm, net } } fn main() -> int needs { llm, net, io } { let review: ReviewResult = Reviewer.run("Review PR #42")? io.println("Approved: ${review.approved}") io.println("Summary: ${review.summary}") return 0 }
The compiler guarantees:
Reviewermust declareneeds { llm }because it uses an LLMReviewer'sneedsmust coverfetch_diff'sneeds { net }ReviewResultfields are all JSON-serializable (verified at compile time)@descriptionannotations become JSON Schemadescriptionfields for the LLM
Next steps
- Installation — build the compiler
- Your First Program — create and run a Cleat program
- Editor Setup — VS Code extension with diagnostics, hover, and autocomplete