Intent, enforced.

Stoic is a small language for saying what software must do. The compiler reads it back to you in plain English. A lock freezes the tests. And verify holds every change to them, whoever wrote the code, or whatever did.

curl -LsSf https://stoic-lang.org/install.sh | sh
powershell -c "irm https://stoic-lang.org/install.ps1 | iex"
Other ways

Working with a coding agent? Start with one prompt

Free and open source. One binary. No account.

fees.stoic locked in stoic.lock
<method:fee @call="fee(amount): 8.75%, half to even"  #amount(>=1, +=500, -=0,    +=>="{ ok: true }", -=>="{ ok: false }") /><test:fee500=fee @call="500" =>fee="44" /><test:fee600=fee @call="600" =>fee="52" />

agent-b · “simplify rounding”fees.ts

- return halfEven(amount * 0.0875);
+ return Math.round(amount * 0.0875);

stoic fees.stoic

A method fee that does "fee(amount): 8.75%, half to even" on call. Field amount must be at least 1, accepts 500, and rejects 0. Each accepted example reports exactly "{ ok: true }"; each rejected one, exactly "{ ok: false }". A quoted example is text; a bare one is that value.

A test fee500 of fee: on call with "500", expect fee exactly "44" (reported back and compared).

A test fee600 of fee: on call with "600", expect fee exactly "52" (reported back and compared).

stoic lock fees.stoic

locked 4 tests from 1 file(s) into stoic.lock

node --test

ℹ tests 4

ℹ pass 4

ℹ fail 0

stoic verify results.txt --strict

pass fee_amount_accepts_500

pass fee_amount_rejects_0

pass fee500

WRONG fee600 fee: expected 52, observed 53

NOT verified: 3/4 locked tests passed (4 checked, 0 asserted only, 0 examples)

next: 1 WRONG above. Fix the code until every locked test runs under its ID, passes and reports the values it checks; don't edit a spec or the lock to make this pass.

real output · locked 4 tests · built with this site

The suite was green. The money was wrong.

Here is how it happens. An agent that can change the code can change the tests too. Another agent, working on a different ticket, changes one line of fee rounding, from half-to-even to Math.round, and updates the tests so they pass. Nothing fails. Every fee that ends in a half is now off by a cent, and the suite is green, but it no longer says what you agreed.

Stoic keeps what you agreed where an agent can’t quietly change it. Its tests don’t decide what is right: they report what they observed, and the lock remembers what you said. Verify puts the two side by side, expected 52, observed 53, and the build stops until someone puts it back or a reviewer agrees it changed.

  1. A locked value can’t change silently.

    Tests report what they observed. Verify compares it with the lock and names every difference. stoic verify --strict

  2. A test can’t be dropped, skipped or loosened quietly.

    The lock changes only in a diff someone reviews, and CI checks every branch against the lock on main. --against origin/main

  3. A rule without a test at its edge doesn’t pass.

    Every limit needs an example on each side of it, or the gate fails and names the example to add. untested-rule

Five verbs. One loop.

Nothing about this asks you to change languages, frameworks or models. Stoic sits beside your code, in a file you review like code.

  1. 01

    Write

    fees.stoic

    Say what it must do in a line, not a page. Rules sit on the fields they constrain; behaviour is plain words.

  2. 02

    Read back

    stoic fees.stoic

    The compiler answers in English. If it misread you, you find out before any code exists, not in review.

  3. 03

    Lock

    stoic lock fees.stoic

    The tests and the spec are frozen into stoic.lock. Only a person loosens a test, and only in a diff someone reviews.

  4. 04

    Build

    stoic brief fees.stoic

    Any agent, any model, any language. The brief is the exact contract it works from, every test named.

  5. 05

    Verify

    stoic verify results.txt --strict

    What the tests observed, against what you locked. Missing, skipped, loosened or wrong: it says so, by name.

No keywords. Seventeen glyphs.

There is no vocabulary to memorise. <button>, <service>, <pipeline> and <ledger> are all just words, and they are yours. What is fixed is a small set of glyphs, each with one job, most borrowed from things you already read: HTML’s angle brackets, a shell’s &, a pointer’s ->.

Anatomy of one line

form: element!: strict:signup: name#email: field"work only": note"email": rule+"ada@acme.com": example@submit: event"create account": handler
The compiler reads it back

A form signup (strict) that does "create account" on submit. Field email ("work only") must strictly match "email" and accepts "ada@acme.com".

Meet all seventeen

One language for everything an agent touches.

Interfaces and databases, services and pipelines, a module’s methods and a project’s stack. The same pieces describe them all: elements are things, fields are properties, events are triggers, and handlers are plain words.

Interfaces

Components, states and interactions. Notes carry the taste: “pill shaped”, “debounce 300ms”.

feed.stoicStoic
<gallery=photos #caption(edit) #more([like, share"copies a link"])>
  <card* @~hover"subtle lift" @tap="open photo" />
</gallery>
<button"pill shaped" @~+click"debounce 300ms"="save draft" />
The compiler reads it back

A gallery bound to photos. Field caption supports edit. Field more provides actions on each card: like and share ("copies a link"). Each card has an animation on hover ("subtle lift") and does "open photo" on tap.

A button ("pill shaped") that does "save draft" on click ("debounce 300ms"), with a quick animation.

Data

Tables, relations and the rules on each column. A field that names another element is a reference, not a copy.

db.stoicStoic
<table:users=postgres #id("uuid", primary) #email("email", unique)->"lowercased">
  <row* @&insert="send welcome email" />
</table>
<table:orders=postgres #user=users(index) #total(>=0) #status("pending | paid | shipped") />
The compiler reads it back

A table users bound to postgres. Field id supports primary and must match "uuid". Field email supports unique, must match "email", and is transformed by "lowercased". Each row does "send welcome email" in the background on insert.

A table orders bound to postgres. Field user refers to users and supports index. Field total must be at least 0. Field status must match "pending | paid | shipped".

Infrastructure

Services, limits and what happens when things fail. Reuse with ->, and say what to leave out.

infra.stoicStoic
<service:api=container
  #image="ghcr.io/acme/api"
  #replicas(>=3, <=10)
  #region("eu-west-1")
  @deploy="roll out one zone at a time"
  @crash="restart and page oncall"
/>
<service:worker->api @-crash #replicas(>=1, <=4) @&message="process jobs from the queue" />
The compiler reads it back

A service api bound to container that does "roll out one zone at a time" on deploy and does "restart and page oncall" on crash. Field image is ghcr.io/acme/api. Field replicas must be at least 3 and at most 10. Field region must match "eu-west-1".

A service worker (like api) bound to container that does "roll out one zone at a time" on deploy and does "process jobs from the queue" in the background on message. Field image is ghcr.io/acme/api. Field replicas must be at least 1 and at most 4. Field region must match "eu-west-1".

CI/CD

Pipelines as steps, each a plain-words instruction with what to do on failure.

ci.stoicStoic
<pipeline:main @push="run checks" @tag="release to production">
  <step:test @run="cargo test" @fail="block the merge" />
  <step:lint @&run="cargo clippy -D warnings" />
  <step:deploy @run="staging, then production" @fail="roll back" />
</pipeline>
The compiler reads it back

A pipeline main that does "run checks" on push and does "release to production" on tag. It contains a step test that does "cargo test" on run and does "block the merge" on fail. It contains a step lint that does "cargo clippy -D warnings" in the background on run. It contains a step deploy that does "staging, then production" on run, and does "roll back" on fail.

Modules

Methods, their errors in check order, and examples that are tests, each reporting a value verify compares.

cart.stoicStoic
<module!:cart #file="cart.mjs" #export="createCart(catalog)">
  <method:add
    @call="add(sku, qty = 1)"
    #errors="UNKNOWN_SKU, then QTY"
    #qty(>=1, <=99, +=1, +=99, -=0, -=100, +=>="{ ok: true }", -=>="{ ok: false, error: 'QTY' }")
  />
</module>
The compiler reads it back

A module cart (strict). Field file is cart.mjs. Field export is createCart(catalog). It contains a method add that does "add(sku, qty = 1)" on call. Field errors is UNKNOWN_SKU, then QTY. Field qty must strictly be at least 1 and at most 99, accepts 1 and 99, and rejects 0 and 100. Each accepted example reports exactly "{ ok: true }"; each rejected one, exactly "{ ok: false, error: 'QTY' }". A quoted example is text; a bare one is that value.

Stacks

Languages, frameworks and versions, written once and reused by every app that shares them.

stack.stoicStoic
<project:shop #language="typescript" #framework="next.js 15" #runtime="node 22">
  <dependencies #react="^19" #prisma="^6"(orm, migrations) #zod="^3" />
</project>
<service:api->shop #runtime="bun 1.2" />
The compiler reads it back

A project shop. Field language is typescript. Field framework is next.js 15. Field runtime is node 22. It contains dependencies. Field react is ^19. Field prisma is ^6 and supports orm and migrations. Field zod is ^3.

A service api (like shop). Field language is typescript. Field framework is next.js 15. Field runtime is bun 1.2. It contains dependencies. Field react is ^19. Field prisma is ^6 and supports orm and migrations. Field zod is ^3.

Cheap models. Expensive guarantees.

A frontier model can often guess what you meant. A small one can’t, and shouldn’t have to. Stoic moves the weight from the model’s judgement to the toolchain: the brief says exactly what to build, the compiler refuses contradictions before they reach anyone, and verify decides when it’s done. The contract doesn’t care which model signed it.

  • stoic brief

    The spec is the plan

    A brief generated from the spec: every rule, every test ID, the verify command. Planning stops being a conversation and becomes a file.

  • =>fee="52"

    Tests report. The lock judges.

    A checked value is reported back by the test and compared with the locked one. A test body can be wrong; its observation can’t hide.

  • dispute ID: why

    A legitimate way to object

    When a locked test looks wrong, an agent records a dispute instead of quietly weakening it. Verify lists disputes first, and fails until an owner settles them.

  • stoic claim billing --as agent-a

    Many agents, one truth

    Each part of the spec has an owner. Agents claim parts with fencing tokens that only rise, relock only what they hold, and verify says whose change broke what.

  • stoic gate --install all

    Spec first, as it’s written

    Agent tools ask the gate before every file write. Implementation code waits until the ticket’s spec change is locked, and a refusal names the one next step.

  • stoic init

    At home in CI

    An example spec, a CI workflow and a merge rule for the lock. Add --coverage, and a changed line of code that no locked test runs fails the build.

Start with an agent

This website is a Stoic spec.

Its palette, typefaces, spacing, contrast, accessibility, page weight and links are locked tests. Every example on it was compiled by Stoic when the site was built. If we break a promise we made here, the build says WRONG, and we can’t ship.

Read the whole spec →

site/spec/site.stoicexcerpt
<palette:tokens
  #marble"light background"="#F3F0E8"
  #ink"light text"="#17160F"
  #muted"light secondary text"="#575347"
  #basalt"dark background"="#11110E"
  #chalk"dark text"="#ECE8DD"
  #verdigris"verified, links"="#2D6A58"
  #cinnabar"WRONG, errors"="#B0341D"
  #ochre"DRIFT, warnings"="#875810"
  @measure="read the :root custom properties of the built CSS"
/>

<test:contrast_text=tokens
  @measure="ink on marble, chalk on basalt"
  =>light="'AAA'"
  =>dark="'AAA'"
/>
<test:one_h1=web @audit =>offenders="[]" =>"each page has exactly one h1" />
<test:links_resolve=web @audit="every internal href and anchor" =>broken="[]" />
<test:landing_js_budget=weight @measure =>within="true" />
 pnpm verify
verified: 86/86 locked tests passed (86 checked, 0 asserted only, 0 examples)

Free. Open. Yours.

Stoic is free to use, for anything, forever. No account, no telemetry, no server: a single binary and a file in your repository. If it stops being useful, delete the file.

Say what you mean. Then hold it.

macOS & Linux

curl -LsSf https://stoic-lang.org/install.sh | sh

Windows

powershell -c "irm https://stoic-lang.org/install.ps1 | iex"

Homebrew

brew install stoic-lang/tap/stoic

Cargo

cargo install stoic-lang

These work once the first release is published. Until then, cargo install --git https://github.com/stoic-lang/stoic stoic-lang builds it from the repository.

Read the loop