---
title: Everywhere
description: The same pieces describe interfaces, databases, infrastructure, pipelines, modules and stacks. One language for everything an agent touches.
kicker: Write
---

# Everywhere

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.

```stoic title=feed.stoic
<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" />
```

## Data

Tables, relations and the rules on each column. `#user=users` refers to the `users` table rather than copying it.

```stoic title=db.stoic
<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>
```

## Infrastructure

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

```stoic title=infra.stoic
<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 />
```

## CI/CD

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

```stoic title=ci.stoic
<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>
```

## 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.

```stoic title=cart.stoic
<!--! 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' }" />
```

## Stacks

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

```stoic title=stack.stoic
<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" />
```

## 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`.

```stoic source title=feed.stoic
<button->ui.buttons.like />
<test:likes=ui.buttons.like @click =>count="1" />
```
