Business-as-Code
Design businesses optimized for autonomous operations delivered by AI agents
Just as Infrastructure-as-Code unlocked Software-as-a-Service in the cloud era, Business-as-Code unlocks AI-delivered Services-as-Software in the autonomous operations era.
The Paradigm Shift
Infrastructure-as-Code transformed how we deploy and scale software. Business-as-Code transforms how we design and operate businesses.
Before IaC: Manual server provisioning, configuration drift, snowflake infrastructure After IaC: Declarative infrastructure, version control, reproducible deployments → SaaS business model
Before BaC: Human-executed workflows, manual operations, process documentation After BaC: Autonomous operations, agent-executed workflows, code-defined business → Services-as-Software
Business-as-Code Fundamentals
Design businesses where agents perform most, if not all, jobs while humans observe, manage, and guide through clear dashboards and escalation workflows.
Native MDXLD Business Definitions
Your entire business is defined in MDXLD - vision, OKRs, org structure, teams, agents, products, and services:
---
$type: Business
name: Acme Financial Services
vision: Autonomous financial operations for modern businesses
okrs:
- objective: Launch AI-delivered bookkeeping service
keyResults:
- metric: businesses_onboarded
target: 100
current: 23
- metric: autonomous_transaction_processing_rate
target: 0.95
current: 0.87
structure:
teams:
- name: Revenue Operations
agents:
- role: Sales Development Rep
count: 5
model: gpt-5
- role: Account Executive
count: 3
model: claude-sonnet-4.5
- name: Customer Success
agents:
- role: Onboarding Specialist
count: 10
model: gpt-5
- role: Support Engineer
count: 8
model: claude-sonnet-4.5
products:
- name: Autonomous Bookkeeping
pricing: $299/month
delivery: fully-automated
services:
- name: Tax Preparation
pricing: $1,200/year
delivery: agent-assisted
---
Acme Financial Services delivers **fully autonomous financial operations** through AI agents that handle bookkeeping, expense management, and tax preparation. Human accountants review edge cases and provide strategic guidance.
## Our Approach
Agents handle 95% of transactions autonomously. Complex cases escalate to human experts through structured workflows. Clients maintain full visibility through real-time dashboards.Autonomous Workflows as Code
Define workflows using on.Object.event() and every.interval() patterns:
import { $, on, every } from 'sdk.do'
// Event-driven workflows
on.Customer.created(async (customer) => {
await $.Agent.assign.Onboarding({
customer,
agent: 'onboarding-specialist-01'
})
await $.Human.review.NewCustomer({
customer,
reviewer: 'success-team-lead',
channel: 'slack',
urgency: 'within-24h'
})
})
on.Transaction.requiresReview(async (transaction) => {
const decision = await $.Human.approve.Transaction({
transaction,
approver: 'finance-manager',
channel: 'github-pr',
context: {
amount: transaction.amount,
vendor: transaction.vendor,
category: transaction.category
}
})
if (decision.approved) {
await $.Transaction.process(transaction)
}
})
// Scheduled autonomous operations
every.day('09:00', async (CMO) => {
await CMO.analyze.MarketingPerformance()
await CMO.launch.ExperimentIfOpportunity()
await CMO.report.ToHumans({ channel: 'slack' })
})
every.week('Monday', async (CFO) => {
await CFO.reconcile.Accounts()
await CFO.generate.FinancialReports()
await CFO.escalate.AnomaliesIfAny({ channel: 'github-issue' })
})
every.hour(async (SupportAgent) => {
const tickets = await $.Ticket.query.Unassigned()
await SupportAgent.triage.And.Respond(tickets)
await SupportAgent.escalate.ComplexIssues({
threshold: 'confidence < 0.8',
channel: 'slack'
})
})Human-in-the-Loop Orchestration
Agents operate autonomously but escalate to humans through familiar tools:
GitHub Pull Requests
on.Agent.needsApproval(async (context) => {
const pr = await $.GitHub.create.PullRequest({
title: `Agent Decision: ${context.decision}`,
body: context.reasoning,
reviewers: context.approvers,
labels: ['agent-escalation', 'needs-human-review']
})
await pr.waitFor.Review()
if (pr.approved) {
await context.proceed()
} else {
await context.revise(pr.feedback)
}
})Slack Block Kit
on.Agent.needsClarification(async (question) => {
const response = await $.Slack.send.InteractiveMessage({
channel: question.team.slackChannel,
blocks: [
{
type: 'section',
text: `Agent needs clarification: ${question.text}`
},
{
type: 'actions',
elements: [
{ type: 'button', text: 'Approve', value: 'approve' },
{ type: 'button', text: 'Reject', value: 'reject' },
{ type: 'button', text: 'Modify', value: 'modify' }
]
}
]
})
return response.action
})Observable Autonomous Operations
Humans maintain oversight through dashboards that show agent activity, performance, and escalations:
---
$type: Dashboard
for: CEO
metrics:
- autonomous_operation_rate: 0.94
- agent_performance_score: 0.91
- human_escalation_rate: 0.06
- customer_satisfaction: 4.7
---
# Autonomous Operations Dashboard
## Agent Performance
- **Sales Agents**: 127 conversations, 23 meetings booked, 5 deals closed
- **Support Agents**: 342 tickets resolved, 18 escalated, avg response 2.3min
- **Finance Agents**: 1,247 transactions processed, 12 flagged for review
## Recent Escalations
1. Large contract negotiation → Assigned to Sales Director (GitHub PR #234)
2. Technical architecture question → Assigned to Engineering Lead (Slack thread)
3. Unusual expense pattern → Assigned to Finance Manager (GitHub Issue #456)Services-as-Software Model
With Business-as-Code, you deliver services entirely through software agents rather than human labor:
- Traditional Service: Human accountant processes 50 transactions/day at $75/hour
- Services-as-Software: Agent processes 10,000 transactions/day at $0.02/hour, human reviews edge cases
This enables service businesses to scale like software businesses while maintaining service quality through human oversight.
Explore Vision, Goals, and the business lifecycle from Ideate to Profit.