Business-as-Code

How we build businesses.

Not a plan. Not a pitch deck. Not a slide. A program — vision, products, agent team, financial rails — written once, run forever, forked at will.

acme/business.ts
// Acme Books — the entire company in one file.

import { Business } from 'business-as-code'
import { SaaS } from 'business-as-code/templates'
import { okrs } from 'business-as-code'
import { priya, ralph, tom, mark, sally, quinn, rae, finn, casey, dana } from 'agents.do'

// Principle 01 — A business is a program
export const acme = Business({
  ...SaaS,                                              // Principle 05 — Defaults are inherited
  name: 'Acme Books',
  mission: 'Close the books for every small firm — automatically.',
  icp: 'US accounting firms, 2–200 staff',

  // Principle 03 — Types are organizational discipline
  customer: {
    $type: 'Customer',
    segments: ['SMB', 'Mid'] as const,
  },

  // Principle 01 — Products are functions
  products: [{
    name: 'Monthly Close',
    model: 'outcome',
    price: 499,
    cogs: 40,                                           // ~92% margin
    deliveryTime: '24h',
  }],

  // Principle 04 — Four kinds of work, one cascade
  cascades: {
    monthlyClose: [
      { $type: 'CodeFunction',       fn: ingestTransactions },
      { $type: 'GenerativeFunction', fn: categorizeAndDraft },
      { $type: 'AgenticFunction',    fn: reconcileExceptions },
      { $type: 'HumanFunction',      fn: controllerSignOff },  // human at the bar
    ],
  },

  // Principle 08 — Autonomy is earned, role by role
  team: [
    priya.as('Product',        { mode: 'autonomous' }),
    ralph.as('Engineering',    { mode: 'autonomous' }),
    tom.as('Tech Lead',        { mode: 'supervised' }),
    mark.as('Marketing',       { mode: 'autonomous' }),
    sally.as('Sales',          { mode: 'supervised' }),
    quinn.as('QA',             { mode: 'autonomous' }),
    rae.as('Frontend',         { mode: 'autonomous' }),
    finn.as('Finance',         { mode: 'supervised' }),
    casey.as('Customer Success', { mode: 'autonomous' }),
    dana.as('Data',            { mode: 'autonomous' }),
  ],

  // Principle 06 — Goals are tests
  goals: okrs([{
    objective: 'Profitable growth',
    period: '2026',
    keyResults: [
      { metric: 'arr',         targetValue: 10_000_000 },
      { metric: 'grossMargin', targetValue: 0.70 },
      { metric: 'nrr',         targetValue: 1.10 },
    ],
  }]),

  // Finance is firmware
  budgets: {
    aiCompute:  { monthly:   8_000, alert: 0.80 },
    infra:      { monthly:   3_000, alert: 0.85 },
    humanOversight: { monthly: 2_500, alert: 0.90 },
  },
})

// Principle 07 — Every action is an experiment
acme.experiment('monthly-close-price', {
  variants: [{ price: 399 }, { price: 499 }, { price: 599 }],
  metric: (r) => r.closedWon ? r.contractValue : 0,
})

// Principle 02 — The map is the territory
// This file is the company. No second artifact. No gap to drift across.

Why it works

AI went superhuman at math and code because both have four properties. Business has historically had none of them.

Business-as-Code gives business all four.

  • 01Formal representation
  • 02Execution
  • 03Reward signal
  • 04Fast iteration

Principle 01

A business is a program.

Every recurring activity is a function. The company is the composition. Name it. Type it. Write it down — if you cannot, the business runs on luck.

acme/business.ts
import { Business } from 'business-as-code'

export const acme = Business({
  name: 'Acme Books',
  mission: 'Close the books for every small firm — automatically.',
  icp: 'US accounting firms, 2–200 staff',

  products: [
    { name: 'Monthly Close', model: 'outcome', price: 499, cogs: 40 },
  ],
})
// This file is the company.

Principle 02

The map is the territory.

The code does not describe the business. The code is the business. No second artifact. No gap to drift across.

acme/workflows/onboard.ts
const onboard = Workflow($ => {
  $.on.Customer.created(async (customer) => {
    const account   = await $.do('provision', customer)     // must succeed
    $.send('Email.welcome', { to: customer.email })         // fire and forget
    const enriched  = await $.try('enrich', customer)       // nice to have
    const activated = await $.do('activate', account)       // must succeed
    return { account, enriched, activated }
  })
})
// Durability is declared per step — not bolted on by a queue.

Principle 03

Types are organizational discipline.

Customer, pricing, offer, goals — typed, addressable, meaning-anchored. Org charts are made of types: get them right and the agents know who they are.

acme/types/customer.ts
type Customer = {
  $id: string
  $type: 'Customer'
  $context: 'https://schema.org.ai'
  name: string
  segment: 'SMB' | 'Mid' | 'Enterprise'
  arr: number
}

// Ambiguity is a type error. If you can't name it, you don't yet understand it.

Principle 04

Four kinds of work. One cascade.

Every step is one of four shapes — code, generative, agentic, or human. Work pushes down the cost gradient; the hard calls escalate. Every escalation is the system saying: this one’s worth the dollar.

acme/cascades/process-refund.ts
const processRefund = new CascadeExecutor({
  name: 'processRefund',
  steps: [
    { $type: 'CodeFunction',       fn: checkStandardPolicy,  onMiss: 'cascade' },
    { $type: 'GenerativeFunction', fn: extractRefundReason,  onMiss: 'cascade' },
    { $type: 'AgenticFunction',    fn: assessRefundRisk,
        onMatch: d => d.confidence > 0.85 ? d.action : 'cascade' },
    { $type: 'HumanFunction',      fn: approveRefundEscalation },
  ],
})
// The system never crashes — it cascades.

Principle 05

Defaults are inherited.

You don’t write invoicing, payroll, or compliance from scratch — template business types ship the 80%. The spread operator is the inheritance.

acme/business.ts
import { SaaS } from 'business-as-code/templates'

export const acme = Business({
  ...SaaS,                       // inherit invoicing, payroll, compliance, dunning
  name: 'Acme Books',
  pricing: { model: 'outcome', amount: 499, unit: 'close' },
})
// Defaults are inherited. You only write what's different.

Principle 06

Goals are tests.
Tests are rewards.

OKRs are typed assertions the runtime checks continuously against the live business. The reward signal isn’t a quarterly review — it’s tied to actual dollars on actual rails.

acme/goals.ts
import { okrs } from 'business-as-code'

export const goals = okrs([{
  objective: 'Profitable growth',
  period: '2026',
  deadline: '2026-12-31',
  keyResults: [
    { description: 'Reach $10M ARR',                metric: 'arr',         targetValue: 10_000_000 },
    { description: 'Hold gross margin above 70%',   metric: 'grossMargin', targetValue: 0.70 },
    { description: 'Keep net retention above 110%', metric: 'nrr',         targetValue: 1.10 },
  ],
}])
// Goals you can fail. Assertions, not aspirations.

Principle 07

Every action is an experiment.

Ad creative, pricing tiers, onboarding flows: every variant ships, and the market grades it in real numbers. Winners compound. Losers get cut.

acme/experiments/pricing.ts
const pricingExperiment = Experiment({
  name: 'monthly-close-price',
  variants: [
    { price: 399, weight: 0.33 },
    { price: 499, weight: 0.33 },
    { price: 599, weight: 0.34 },
  ],
  execute: (variant) => offer({ price: variant.price }),
  metric: (result) => result.closedWon ? result.contractValue : 0,
})
// Every action is an experiment. The market is the reward function.

Principle 08

Autonomy is earned.

Agents start in manual, earn supervised, then autonomous — and demote the same day they slip. Slow to promote. Fast to demote.

acme/agents/drafter.ts
const drafter = Agent({
  name: 'Drafter',
  role: 'Outbound Copywriter',
  mode: 'supervised',  // 'manual' | 'supervised' | 'autonomous'
  goals: [{ id: 'open-rate', description: 'Email open rate > 40%', target: 0.40 }],
})

type TrackRecord = {
  accuracy: number
  samples: number
  trend: 'improving' | 'stable' | 'declining'
}
// Autonomy is earned. Slow to promote, fast to demote.
// Trust is not faith. Trust is data.

Principle 09

The business compounds.

Spread the first business, override what changes, ship. A thousand forks — each running, each transacting, each compounding the rails the first one paid for.

acme-eu/business.ts
import { Business } from 'business-as-code'
import { acme } from './acme'

export const acmeEU = Business({
  ...acme,
  name: 'Acme EU',
  locale: 'en-EU',
  pricing: euPricing,
  compliance: gdpr,
})
// The second business is a diff.

One more

Open question in, running business out.

Open question, captured anywhere — chat, email, a thought during a walk. The runtime takes it from there:

acme/workflows/idea.ts
import { on, list, research, ai } from 'business-as-code'

on('idea.captured', async (idea) => {
  for await (const market of list`10 market segments for ${idea}`) {
    const insights = await research`${market} in the context of ${idea}`
    for await (const icp of list`ideal customer profiles for ${{ idea, market, insights }}`) {
      const canvas = await ai.leanCanvas({ idea, market, icp, insights })
      const story  = await ai.storyBrand({ canvas, icp })
      const page   = await ai.landingPage({ story, canvas })
      const posts  = await ai.blogPosts({ canvas, count: 25 })
      await page.publish()
    }
  }
})

And every step inside that — researching the market, ranking the ICPs, drafting the canvas, shipping the page — calls back to the same handful of verbs whether silicon or carbon answers:

acme/team.ts
import { priya, ralph, tom } from 'agents.do'
import { legal, ceo } from 'humans.do'

const spec      = await priya`spec out user authentication`
const code      = await ralph`build ${spec}`
const reviewed  = await tom`review ${code}`
const contract  = await legal`review the licensing agreement`
const approved  = await ceo`approve the partnership`

// The verb is the same whether silicon or carbon answers it.
// The code never says.

The verb is the same whether silicon or carbon answers it. The code never says.

Come build with us.

If you’re an ambitious founder with unique insight into a niche, the studio was built for you — we handle the technology while you focus on the business.