Everywhere

The same pieces describe interfaces, databases, infrastructure, pipelines, modules and stacks. One language for everything an agent touches.

Stoic began as a way to describe interfaces, and turned out to describe almost anything. The pieces don't change: elements are things, fields are properties, = on a field points at another thing, events are triggers, and handlers are plain-words instructions. Only the words do.

That matters more than it sounds. An agent working on a feature touches the interface, the table behind it, the service that serves it and the pipeline that ships it. One language for all four means one review habit, one lock and one verify gate.

Interfaces

Components, states and interactions. Notes carry the taste that usually lives in a designer's head.

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. #user=users refers to the users table rather than copying it.

db.stoicStoic
<table:users=postgres #id("uuid", primary) #email("email", unique)->"lowercased">
  <row* @&insert="send welcome email" @delete="archive their orders" />
</table>
<table:orders=postgres #user=users(index) #total(>=0) #status("pending | paid | shipped")>
  <row* @update="notify user when status changes" />
</table>
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 and does "archive their orders" on delete.

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". Each row does "notify user when status changes" on update.

Infrastructure

Services, their limits, and what happens when things fail. -> reuses a service; @-crash leaves out what the copy shouldn't inherit.

infra.stoicStoic
<service:api=container
  #image="ghcr.io/acme/api"
  #replicas(>=3, <=10)
  #cpu(<=2)
  #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" />
<queue:jobs #retention(<=7) #consumers=worker />
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 cpu must be at most 2. 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 cpu must be at most 2. Field region must match "eu-west-1".

A queue jobs. Field retention must be at most 7. Field consumers refers to worker.

CI/CD

A pipeline is a list of steps, each a plain-words instruction with what to do when it fails.

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="deploy api to 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 "deploy api to staging, then production" on run, and does "roll back" on fail.

Modules

This is where Stoic is strictest, because it's where agents write the most code. Methods, errors in the order they're checked, and examples that are tests, each reporting a value verify compares.

cart.stoicStoic
<!--! Every method returns { ok: true, … } or exactly { ok: false, error }. A failed call changes nothing. -->
<module!:cart #file="cart.mjs" #export="createCart(catalog)">
  <method:add
    @call="add(sku, qty = 1): add qty to sku's line"
    #errors="UNKNOWN_SKU, then QTY"
    #qty(
      "an integer",
      ^"on a fresh cart, add('apple', value)",
      >=1,
      <=99,
      +=1,
      +=99,
      -=0,
      -=100,
      +=>="{ ok: true }",
      -=>="{ ok: false, error: 'QTY' }"
    )
  />
</module>
<test:merge_cap=add ^"add('apple', 98)" @call="'apple', 2" =>="{ ok: false, error: 'QTY' }" />
The compiler reads it back

A module cart (strict). Note: Every method returns { ok: true, … } or exactly { ok: false, error }. A failed call changes nothing. Field file is cart.mjs. Field export is createCart(catalog). It contains a method add that does "add(sku, qty = 1): add qty to sku's line" on call. Field errors is UNKNOWN_SKU, then QTY. Field qty must strictly be at least 1 and at most 99, must strictly match "an integer", accepts 1 and 99, and rejects 0 and 100. Each example is tried given on a fresh cart, add('apple', value). 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.

A test merge_cap of add: given add('apple', 98), on call with "'apple', 2", expect exactly "{ ok: false, error: 'QTY' }" (reported back and compared).

Stacks

Languages, frameworks and versions, written once. Keep a shared stack.stoic and point each app at it with ->stack.shop, overriding what differs.

stack.stoicStoic
<project:shop #language="typescript" #framework="next.js 15" #runtime="node 22" #database=postgres>
  <dependencies #react="^19" #prisma="^6"(orm, migrations) #zod="^3" />
</project>
<service:postgres #version="17" #storage(>=20) />
<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. Field database refers to postgres. It contains dependencies. Field react is ^19. Field prisma is ^6 and supports orm and migrations. Field zod is ^3.

A service postgres. Field version is 17. Field storage must be at least 20.

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

Across files

A reference says where to look, so there are no import lines: ->buttons.like is like in buttons.stoic next to this file, and ->ui.buttons.like is in ui/buttons.stoic. Tests can bind to an element in another file with =file.name.

feed.stoicStoic
<button->ui.buttons.like />
<test:likes=ui.buttons.like @click =>count="1" />

All 6 examples on this page were compiled by Stoic at build time.