Zabaca's open-source stack bootstrap. It holds the zbc CLI, the infrastructure modules that make deploying an application easy, a small set of applications most software companies want (warehouse, …) as app templates, and space, a small company's whole workspace, as an app each consumer pulls into its own repo.
Who it's for: zbc is open source, and its consumers are other software companies, not just Zabaca. A consumer forks this repo or installs just the CLI, then vendors the engine and built-in modules as a git subtree at vendor/zbc (ADR-0005). Nothing is Zabaca-hosted — every consumer runs their own copy of everything, including any supporting service.
Two kinds of thing ship to consumers. A module provisions or deploys one resource (turso, cloudflare, r2, …). An app template is a whole application scaffolded into the consumer's repo — it earns its place by being something most software companies would want, or by being required for the zbc workflow itself (secret-relay); anything specific to one project belongs in that project, consuming zbc.
Domain vocabulary and principles live in CONTEXT.md; the map of contexts is CONTEXT-MAP.md.
Projects live here under packages/<project>/; per-environment module instances live under packages/infra/environments/<env>/. Applying an environment is one command — zbc apply <env> — which discovers every instance in the environment directory, resolves the dependency graph from imports, decrypts secrets, and converges each service to the desired state.
├── zbc.config.ts # project metadata + environment list
├── .sops.yaml # age public keys for secrets encryption
│
├── packages/
│ ├── cli/ # zbc — CLI source + bundled module templates
│ │ ├── src/
│ │ │ ├── commands/ # init, add, apply, destroy
│ │ │ ├── engine/ # apply graph + secret loading
│ │ │ └── utils/
│ │ └── templates/ # source of truth scaffolded by `zbc init` / `zbc add`
│ │ ├── infra/
│ │ │ ├── modules/ # turso, cloudflare, … (each with registry.json)
│ │ │ └── src/ # defineModule helpers + shared types
│ │ ├── workflows/ # CI workflows (preview.yml, production.yml)
│ │ ├── root/ # package.json, tsconfig.json scaffolds
│ │ ├── sops.yaml
│ │ └── zbc.config.ts
│ └── infra/ # live consumer of the templates above
│ ├── modules → ../cli/templates/infra/modules # symlink
│ ├── src → ../cli/templates/infra/src # symlink
│ └── environments/
│ ├── production/ # add module instances per project
│ └── preview/ # ephemeral preview resources
│
└── .github/
└── workflows/
├── production.yml # zbc apply production on push to main
└── preview.yml # zbc apply/destroy preview on PR events
zbc init [project] [--ci github] # scaffold zbc into a repo (greenfield or existing)
zbc init --subtree # …vendoring engine + modules as a subtree at vendor/zbc
zbc init <name> --subtree --dir deploy/zbc # …into a subfolder of a non-Bun repo (pnpm), engine at deploy/zbc/vendor/zbc
zbc add <module> # add a built-in module (turso, cloudflare, …)
zbc apply <env> # apply all module instances for an environment
zbc apply <env> <instance> # apply a specific instance (+ its dependencies)
zbc apply <env> --json <path> # …and write the result (instance outputs) as JSON
zbc list <env> # list what an environment declares, in dependency order
zbc run <env> <instance> <action> # run one operator-invoked module action (--yes if irreversible)
zbc destroy <env> # tear down every instance that defines destroy
zbc secret get <env> <key> # print one decrypted secret value on stdout
zbc update # bring the vendored engine + built-in modules up to this CLI's version
zbc add space # pull the space (a vendored app) into vendor/space as a git subtree
zbc update space # pull a newer copy of the space over it, keeping the project's editsinit is the one-time scaffold. It drops zbc.config.ts, .sops.yaml, the packages/infra/ skeleton, and (with --ci github) the workflows. It does not add modules — those come on demand. With --subtree (the standard for new consumers — ADR-0005) it instead runs git subtree add --squash of Zabaca/zbc-core at vendor/zbc — pinned to the tag matching the CLI version — and skips copying packages/infra/src/; the engine and built-in modules are then real files with upstream history. --dir <path> scaffolds into that folder (created if missing) exactly as if run from inside it — the route for a repo that is not a Bun workspace: the host's root package.json, lockfile and node_modules stay untouched, installs stay in the folder, and with --ci github the workflows go to the repo's top-level .github/workflows/ with working-directory set to the folder. Every subtree command (init, update, zbc add space/update space, the foreign-file audit, the re-vendor hint) derives the prefix git sees from the project root relative to git rev-parse --show-toplevel — deploy/zbc/vendor/zbc — and the stamp records it for information only when it is not vendor/zbc. .claude/settings.json is written by default only for a greenfield init at the repo top level; a Bun-workspace repo, a subfolder or an existing .claude/ needs --claude, and --no-claude skips it everywhere. zbc-core is generated by CI (.github/workflows/publish-core.yml, dispatched by /release, splits packages/cli/templates/infra/ and tags it); never PR zbc-core directly.
add brings in a single module: in a subtree project it resolves the module from vendor/zbc/modules/<name>/ (nothing to copy — it installs dependencies and prints the secrets/instructions); in copy mode it copies index.ts into packages/infra/modules/<name>/ first. Either way it runs bun add for declared dependencies and prints the secrets you need to put in secrets.yaml along with the provider's signup/token URLs.
update pulls a newer zbc-core tag into vendor/zbc via git subtree pull --squash. In a copy-mode project — where there is no subtree to pull — it re-lays the templates this CLI carries over what is there: packages/infra/src/ plus every built-in module the project already added, deleting files of ours this CLI no longer ships at that path so the project isn't left running two engine vintages at once. A directory's name does not say who wrote what is in it (one consumer's d1 is our module at an older release, another's was written before ours existed), so the CLI carries a fingerprint of every revision the templates have had (packages/cli/templates/history.json, written by bun scripts/template-history.ts, formatting and comments ignored) and replaces or removes only a file some version of ours read like. A built-in-named module with a file that matches none is the project's own or its edit: it is kept whole and named. An edited engine file stops the update before anything is written, because the engine cannot be refreshed in part. --overwrite-engine-edits takes ours for the engine, --overwrite-edits for the modules as well, --overwrite-module <name>[,<name>] for the modules named and no others, and a file at a path we never shipped is never deleted under either. It never adds a built-in the project didn't ask for (a library a refreshed module imports and the project lacks is named, with the zbc add that brings it), skips symlinked paths (this repo's own packages/infra/{src,modules}), demands a clean git tree first (it overwrites and deletes), and names — never installs — any dependency a refreshed module declares that the project doesn't have. A stamp saying subtree with no engine under the prefix is refused rather than relabelled: that is the vendoring-never-landed failure, and it prints the re-vendoring command. Copy mode is still a dead end by design, and every zbc apply says so; zbc update just means an engine fix no longer has to be hand-diffed in. After the pull, update audits the prefix and names every file under vendor/zbc/ that zbc-core does not ship at that path — three surveyed consumers each wrote their own vendor/zbc/VENDORING.md, which a subtree push would deliver upstream. It is a warning by default (a different core vintage produces the same signal) and a hard failure under --strict. Consumer-authored files belong outside the prefix.
The vintage stamp. Both init modes and update write .zbc-vendor.json at the project root — mode, the CLI version that vendored, the zbc-core ref, and when. Commit it. zbc apply reads it and warns when the vendored engine is behind (or ahead of) the CLI running the apply, when the vintage is unknown, or whenever the project is in copy mode. It is never fatal, and it is silent for a subtree project on the matching version. The stamp lives at the root and not in vendor/zbc/ for the reason above: a file in the prefix rides a subtree push.
Contributions flow the other way with git subtree push — which is why consumer commits must stay purely inside or purely outside vendor/zbc/: a mixed commit gets half-split upstream. Consumer-owned modules belong outside the prefix (packages/infra/modules/), committed normally.
Getting things back out. Three surfaces exist because consumers kept rebuilding them in shell:
zbc secret get <env> <key>prints one decrypted value and nothing else, so a local script can doTOKEN=$(zbc secret get production TURSO_API_TOKEN)instead ofsops -d … | grep. Absence and blankness arectx.secret's rules, not new ones: a missing key exits non-zero with the key named and writes nothing to stdout, and a present-but-empty one needs--allow-blank.zbc apply <env> --json <path>writes{ env, instances: [{ name, module, outputs }] }once the apply succeeds — the preview workflow reads its deploy URLs from it withjqrather than grepping them out of the log. It takes a path rather than printing to stdout because modules run build steps with inherited stdio, so stdout is not a channel the CLI can promise to keep clean. A value a module declared as a secret output is written as[redacted](see below), wherever in the document it appears — so a minted credential does not reach the file. Everything else is verbatim, so still treat it as sensitive and delete it after reading, as the workflow does.zbc list <env> [--json]reports what the environment declares, in the order apply would run it: module,ephemeral,retain, whether the module defines adestroy, and each instance's imports. It runs no module and calls no provider. It answers "what should exist"; enumerating what a provider actually holds is not something the engine can do yet.--checkalso reads every instance's config with its module's schema and exits non-zero when one is refused, each named on stderr: an apply parses a config only as it reaches the instance, so this is the way to learn it before anything is applied (a pull request's CI, say). It reads no secret and no import.
Actions (ADR-0017)
are the third verb. apply converges and destroy tears down; neither is a home
for a one-shot irreversible act an operator performs deliberately — buying a
domain, rotating a key — so consumers put those outside zbc, in scripts no
module imports, and therefore outside the graph, the decrypted secrets and the
imports edge the act needs. A module may declare actions: { <name>: { description, irreversible?, run } }, reachable only as zbc run <env> <instance> <action>: never from apply or destroy, never applying the instance itself,
emitting nothing, and refused without --yes when irreversible — before the
config is parsed or any import applied. Its imports resolve as a
full-environment destroy's do — applied when the body asks — except for an
irreversible action, whose imports are applied up front so the body is never
re-entered mid-purchase. An action body must read imports through
ctx.output/ctx.outputValue, never ctx.imports. zbc run <env> <instance>
(no action) lists what an instance declares, and zbc list reports the same. An action is also the one place a module may store a secret (ADR-0023): ctx.storeSecret(key, value) writes one key of the environment's secrets.yaml through sops, for the credential a provider shows once and something outside any apply needs later. From apply, destroy or a probe the same call throws, because an apply runs in CI, where a changed file is lost, and must be the same when run twice. The run names the file to commit. The write is done by the CLI that is running, not by the vendored engine, so zbc run refuses an action when the CLI is older than the version .zbc-vendor.json records: an older one drops the environment a store names. A module asks canStoreInEnvironment(ctx) before an irreversible call whose result goes to another environment.
Outputs are values, not only strings. ctx.output still returns a string,
because a worker secret, a --var and a binding field all are one. An output
whose shape is the point — nameServers: string[] — is read with
ctx.outputValue(ref, field): the same edge and the same three absence
failures, without the string rule and without allowBlank (0, false and
'' are values). ctx.output on a present non-string now names the type it
found and points here.
Testing a module. createTestContext (exported from packages/infra/src,
vendor/zbc/src in a subtree project) builds an ApplyContext over stubbed
secrets and imports, so a module's real apply is callable from a test with no
engine and no provider. It applies the engine's own secret/output rules —
so a test sees the failure a deploy would — and records what the module asked
for as ctx.secretsRead / ctx.outputsRead.
const ctx = createTestContext({
secrets: { CLOUDFLARE_API_TOKEN: 'tok' },
imports: { 'main-db': { databaseUrl: 'libsql://test' } },
})
const outputs = await myModule.apply({ … }, ctx)apply is declarative and idempotent. Run it the first time — everything is provisioned and deployed. Run it again — no-op except code deploy. Config changed — it converges. Same command locally and in CI.
An instance marked ephemeral: true is destroyed and re-applied on every run, so each run starts from a clean resource. That is the engine's rule, not a module's: ephemeral sits on the instance, any module that defines destroy can be ephemeral, and one that doesn't is a hard error before anything is applied. (ephemeral inside a module's config is the pre-0.14 spelling. It is still honoured — with a deprecation line on every apply — but only for the four modules that ever declared it: turso, r2, fly, cloudflare-token. Everywhere else that key was always stripped by the config schema, and it stays inert.) zbc destroy is separate: it tears down every instance that defines a destroy, ephemeral or not, in reverse dependency order, and is what cleans up when a PR is closed.
An instance marked retain: true (ADR-0019) is the opposite: zbc destroy <env> leaves its resource standing and prints that it did, and zbc destroy <env> <that instance> is refused. It is for a resource whose loss is a loss of records (a database, the bucket of their files) on a module whose destroy deletes, and like ephemeral it sits on the instance, because the same d1 module backs scratch databases a preview throws away. The instance carries no destroy at all, so an older engine that has never heard of retain skips it too. retain with ephemeral is refused when the instance is declared. If another instance's destroy reads a retained instance's output, the engine applies it on demand as usual (adopting the live resource) and leaves it standing. Deleting a retained resource means removing retain in a reviewed change first, or deleting it in the provider by hand.
Modules live in packages/infra/modules/ (consumer-side) — really at packages/cli/templates/infra/modules/<name>/ (source of truth). Each module is a directory with two files:
index.ts— schema (zod) +apply/destroylogic viadefineModuleregistry.json— manifest read byzbc add: files to copy, npm dependencies, required secrets, signup/token URLs, post-install instructions
Not every directory under modules/ is a module. registry.json's kind says which of three it is: module (the default), library — code the modules beside it import as ../<name>, defining no module (cloudflare-api, gcp-api, host-exec, incus-core, provision-core) — and app. A manifest's modules key names the siblings its code imports, and zbc add installs that graph first, transitively, so a copy-mode install never leaves a relative import dangling (ADR-0015).
A new built-in module = drop a directory under packages/cli/templates/infra/modules/<name>/ containing those two files. It's then available via zbc add <name> in any consumer repo.
Module shape (index.ts):
import { z } from 'zod'
import { defineModule } from '../../src/define-module'
export const tursoModule = defineModule({
name: 'turso',
configSchema: z.object({
orgName: z.string(),
dbName: z.string(),
group: z.string().default('default'),
primaryLocation: z.string().default('iad'),
}),
outputs: z.object({
databaseUrl: z.string(),
authToken: z.string(),
}),
async apply(config, ctx) {
// idempotently ensure database exists
return { databaseUrl, authToken }
},
})Instances live in packages/infra/environments/<env>/ and wire a module to specific config:
// packages/infra/environments/production/main-db.ts
import { tursoModule } from '../../modules/turso'
export default tursoModule.instance({
name: 'main-db',
config: {
orgName: 'zabaca',
dbName: 'myproject-production',
primaryLocation: 'aws-us-west-2',
},
})// packages/infra/environments/production/web.ts
import { cloudflareModule } from '../../modules/cloudflare'
export default cloudflareModule.instance({
name: 'web',
config: {
workdir: 'packages/web',
accountId: '<cloudflare account id>',
build: {
command: 'bun run build -- --filter=@myproject/web',
cwd: '.',
},
workerSecrets: ['SOME_RUNTIME_SECRET'],
},
})Imports (imports: [mainDb]) are between instances, typed, refactor-safe, with outputs flowing from dependency to dependent, and a module's apply reads them through ctx.output({ from, output }, field) — the engine's one rule for that lookup, which fails by name rather than handing the module undefined. A destroy reads them the same way: the engine applies the imported instance on demand when one asks. Whether they're wired into the deployed service is up to the module and is explicit per entry: the cloudflare module lets each workerSecrets/workerVars entry be either a plain name (a key in this environment's secrets.yaml) or a { name, from, output } reference that pulls a value from an imported instance's outputs — from must be an instance listed in this instance's imports, and output a key that instance emits, or apply fails with a hard error naming both. Secrets are pushed via wrangler secret put (stdin-piped); vars via wrangler deploy --var (command-line visible — never route sensitive values through workerVars).
Bindings (ADR-0014) are the same edge, one level deeper. workerSecrets/workerVars reach the worker's environment; a binding lives in the file wrangler reads at deploy time, and wrangler has no CLI flag for it — which is why four consumers wrote a d1 module and every one of them still hardcodes database_id in wrangler.jsonc. The cloudflare module's bindings key closes it for any resource type: { type: 'd1_databases', binding: 'DB', field: 'database_id', from: 'app-db', output: 'databaseId' } — type is the wrangler config key holding the binding array (dotted for nested ones, queues.producers), field the key on the matched entry to set, and the value is either that { from, output } reference or a value literal. The binding must already be declared in the package's own wrangler config (placeholder id and all): wrangler still owns worker topology, zbc only supplies the identifier the provisioning instance just produced, and a binding no declaration matches is a hard error before wrangler runs (with wranglerEnv set that means the env.<name> block specifically — wrangler does not inherit binding keys into a named environment, so a top-level declaration is not the one that would ship). r2Bindings is the R2 shorthand for the same code path and is unchanged. The module patches a generated copy of the config, deploys it with --config, and deletes it.
The deploy, read back. wrangler deploy exiting 0 says the upload was accepted, not which version answers a request, and seven consumers each wrote the same loop after zbc apply: poll a path until it names the commit just deployed. The cloudflare module's deployCheck is that loop inside the apply: { path: '/api/health' } beside deployIdVar GETs the path on the deployed Worker until the body contains the deploy id twice in a row (the edge serves old and new together for a while) and fails the apply after timeoutMs with the last answer seen. origin says where to ask when the hostname is a custom_domain in the Worker's own wrangler config, headers carry a literal or a { secret } for a path behind a token, and the id is the deployId output. It is not a ready probe because the engine runs a probe only at an imports edge, and a deployed Worker is usually what nothing imports.
Readiness (ADR-0013) is the second rule on that edge. Every provider returns success from a create call before the created thing works — a fresh Cloudflare token is refused by the very scope it was granted, a fresh GCP service account 404s its own keys endpoint — and four consumers each hand-rolled a retry loop inside their module because there was nowhere else to put one. A module may now declare ready: { proves, probe, timeoutMs?, intervalMs? } alongside apply, and the engine holds that instance's outputs at every imports edge until the probe passes, retrying while it throws or returns false. The probe belongs to the module because readiness is a claim about the capability the caller will use: leeandco measured /tokens/verify answering 200 at ~112ms while the scope-gated call was still refusing at ~1621ms. An instance nothing imports is never probed, and a module that declares no ready pays nothing. cloudflare-token is the first to declare one — it probes the minted token against the read permission groups it was granted (write does not imply read on Cloudflare), falling back to the account-owned token verify when it was granted no probeable read group.
Secret outputs (ADR-0016) are the third rule on that edge, and the survey's largest convergent case: four consumers mint a credential inside apply — a GCP service-account key, a Tailscale auth key, a scoped Cloudflare token — and each hand-rolled the discipline of keeping it out of logs and off disk. A module now declares which outputs are credentials: secretOutputs: { tokenValue: { rotates: 'each-apply' } }. The value still crosses an imports edge in memory verbatim; the engine replaces it with [redacted: <instance>.<output>] in every message it prints or throws (a provider echoing the Authorization header it refused is how the leak actually happens), and with [redacted] in zbc apply --json (by declared key on the minting instance, and by value everywhere else in the document, so an importer re-emitting it does not put it on disk either). rotates names who consumes the credential — 'each-apply' when the apply itself does, so rolling is free, or 'never' when a holder outside the apply does, in which case an ephemeral: true instance of that module is refused before anything applies, because destroy-and-recreate is a silent rotation. It cannot reach a module's own console.log, a spawned child's stdio, or a credential the minting module leaks before it returns — the engine never sees those bytes, and in the last case has not yet been told the value. cloudflare-token is the first declarer.
d1 provisions a Cloudflare D1 database (idempotent list→create, destroy tolerating an already-absent database) and emits { databaseName, databaseId }. It exists because five consumers each wrote it and none could close the gap after it: they all still hardcoded database_id in wrangler.jsonc. With ADR-0014's bindings they no longer have to — { type: 'd1_databases', binding: 'DB', field: 'database_id', from: 'app-db', output: 'databaseId' } fills it in at deploy time. It also converges schema inside apply: statements is end-state DDL replayed every run (so each must be idempotent), and additiveColumns issues the one thing SQLite has no IF NOT EXISTS spelling for, treating "duplicate column name" as success. A versioned history goes in migrationsDir, a folder relative to the project root that apply hands to wrangler d1 migrations apply --remote (wrangler's own format and d1_migrations ledger, through a throwaway config naming the database by its id) before statements run. It runs on the d1 instance's own apply, so a Worker that imports it deploys only after its schema is there, and a failed migration leaves that Worker undeployed. The migrator is the project root's wrangler, or the one in the package wranglerWorkdir names (the Worker's own, in a workspace that installs wrangler there), so migrations and the deploy run one pinned version. CLOUDFLARE_API_TOKEN needs Account → D1: Edit.
queue provisions a Cloudflare Queue (paginated list→create) and the Email Sending event subscriptions that fill it, one per sending domain, and emits { queueName, queueId, subscriptionIds }. A Worker consumes it by naming the queue in its own wrangler config (queues.consumers); wrangler attaches a consumer by name and does not make the queue, so the Worker's instance imports the queue's. A subscription is found by name on its queue and brought to the declared events; one of that name whose source reads back as another domain or zone is a hard error, never an overwrite. destroy removes only the subscriptions the instance names and leaves the queue, which may hold messages. CLOUDFLARE_API_TOKEN needs Account → Queues: Edit.
cloudflare-email provisions Cloudflare Email Service (public beta) for a domain via the REST API (the first REST-direct CF module, wrangler has no Email onboarding surface): outbound sending (SPF/DKIM/DMARC/bounce-MX auto-provisioned) and inbound routing (literal rules + catch-all → forward / worker / drop). It reuses CLOUDFLARE_API_TOKEN but needs extra token scopes (Email Routing Rules Edit, Zone Settings Edit, and DNS Edit on the zone; Email Sending Edit and Email Routing Addresses Edit on the account) and a Workers Paid plan for sending. Beta caveats: 5 MiB outbound cap, unpublished rate limits (pilot before high-volume use), and forward destinations require a manual email-click verification, apply triggers the email, then fails with instructions until you re-run. In this repo it powers sending from mail.cedarpad.com; mail sent to that subdomain is dropped by its catch-all.
cloudflare-stored-token is a Cloudflare API token minted once and kept in secrets.yaml, for a holder that is not an apply: a laptop, a job in another repository, a reader of one bucket. cloudflare-token rolls its value on every apply and keeps none, which is right when the apply is the only user and an outage for anyone else holding it; two consumers each wrote this module for that case, shelling out to sops because a module could not store a secret. Here the halves are split (ADR-0023): zbc run <env> <instance> mint creates the token and stores it under the keys store names (the value, or the S3 pair R2 derives from it), rotate --yes re-applies its policies and rolls it, and apply creates and rolls nothing: it proves the stored keys still work, so a token revoked in the dashboard fails an apply and not its holder. buckets grants permission groups on named R2 buckets alone. Minting needs a root token, from secrets.yaml or from the environment of that one command, so the root can stay out of an environment whose other readers should not hold it. It emits no credential.
gcp-service-account converges one Google service account and mints a fresh key on every apply, pruning the account's user-managed keys to maxKeys oldest-first so the key the previous apply handed out keeps working while a deploy is in flight. It reads the Google REST API through the gcp-api library (a hand-rolled RS256 JWT bearer grant — no SDK, no gcloud) authenticated by one bootstrap key in secrets.yaml (GCP_SERVICE_ACCOUNT_KEY, per-instance via credentialSecret). The minted saKey is declared a secret output (rotates: 'each-apply'), so it crosses imports in memory and reaches neither the log nor zbc apply --json, and its readiness probe is the exchange a dependent will make — the minted key for an access token — so no importer gets a key the token endpoint has not seen yet. (The provider's other lateness, an account that 404s its own keys collection seconds after being created, happens before apply returns and so is retried inside it; no engine hook reaches between two statements of one apply.) It ships the service-account half only — two surveyed consumers welded Google Calendar provisioning into the same module because the Calendar had to be created as the account just minted, and imports plus readiness is what that ordering actually needs. A module wanting Calendar (or any other Google resource) imports this one and reads saKey. Unlike those consumers it defines destroy, so a preview environment can own an ephemeral account of its own — which is how a preview rotation is kept from invalidating production's credential. IAM's delete is a 30-day soft delete, so re-applying a destroyed id undeletes it (handled in apply); a per-PR serviceAccountId skips that round trip, within IAM's 30-character limit.
App templates live at packages/cli/templates/apps/<name>/ and declare kind: "app", a targetDir, and their modules dependencies in registry.json. zbc add <app> auto-vendors those modules, copies the full package verbatim into the target, runs bun install, and prints the instance files to create. A template is placeholder-free: all per-project identity lives in the instance files (the cloudflare module's workerName, r2Bindings to an r2 module instance, workerVars literals), so this repo's own packages/<app>/ is a plain symlink into the template (the template path is also an exp
BD0
licit workspace entry in the root package.json, since bun's workspace glob doesn't follow symlinks) and nothing is mirrored.
space (vendored app) is a small company's whole workspace as one Cloudflare Worker: mail, chat and calls, a calendar, forms and signed documents, clients and knowledge. It lives at packages/cli/templates/apps/space/ (eight packages, the Telegram and texts bridges, and a kit that builds an install's instances from the project's own zbc modules; the texts bridge, packages/texts-bridge, is Go and AGPL-3.0-or-later because it links libgm, a separate program the MIT space reaches only through the texts door's HTTP calls, so nothing in the MIT packages may import it), it is a member of this repo's workspace so its suites run here (.github/workflows/space-tests.yml), and it is not in the npm package. A workflow (publish-space.yml) splits the folder to the public copy, Zabaca/zbc-space, on every merge that touches it and tags a version when the folder's package.json version changes; nobody changes that repository directly. A consumer runs zbc add space, which pulls the copy as a squashed git subtree into vendor/space/ at the newest version tag (--ref main for the newest commit), adds the folder to the project's workspace, installs the modules the kit builds from, writes the files a new install starts from for the environment named (--env), and records the ref and the commit pulled under apps in .zbc-vendor.json. zbc update space pulls a newer copy over it; the project's own edits ride through as any merge carries them, and the command then names the files under the prefix the copy does not ship and the files that differ from the commit pulled, as information. The folder's own README and docs/install.md are the guide to a first install.
The space is written for a public reader, and six rules hold for its code, tests, comments and docs, and for every commit message and pull request here that touches it:
- No real person. Invented people only.
- No real company. Zabaca appears as the author and maintainer only (the licence, a credit, package metadata, the public repositories' addresses), never as an install.
- No real address, host, phone number, Cloudflare account or zone id, Google project or app id. Invented ones use reserved example domains and numbers. A third party's public service (an API host, a mail provider's domain the code must recognise) is named where the code talks to it.
- No reference to a private record: a ticket, a decision, a client file, a session, or a date given as provenance. The reason stays in the comment; where it came from goes.
- No business data: no BB84 persona, mail, calendar, contact or contract wording of a real install.
- No history from anywhere else: a change arrives as files, never as another repository's commits.
The folder's own check holds the third rule and what of the others a program can read (bun run check:public in the folder, also a test in packages/workspace); an install's declaration, install file, content file and secrets are never in this repository.
Ephemeral preview instances use dynamic naming and destroy+recreate on every apply:
export default tursoModule.instance({
name: 'main-db',
ephemeral: true,
config: {
dbName: `myproject-preview-pr-${process.env.PR_NUMBER}`,
},
})- production —
zbc apply production, dispatched deliberately by/release(gh workflow run production.yml -f instances=…). A merge to main deploys nothing - preview —
zbc apply preview, ephemeral per-PR resources, triggered on PR open/push, cleaned up on PR close viazbc destroy preview
All secrets are committed to the repo, encrypted with SOPS + age. Each developer and CI environment has their own age keypair.
.sops.yamllists all age public keys (committed to repo) as recipients- Secrets are encrypted to all recipients — anyone listed can decrypt
- Each developer's private key stays on their machine only (never shared)
- No secrets stored in provider dashboards, password managers, or other external systems
- Developer generates their own keypair:
age-keygen - Developer shares their public key (not secret)
- Add the public key to
.sops.yaml - Re-encrypt all secrets with the new recipient:
sops updatekeys <secrets.yaml> - Developer stores their private key at the default SOPS location:
- macOS:
~/Library/Application Support/sops/age/keys.txt - Linux:
~/.config/sops/age/keys.txt
- macOS:
- Remove their public key from
.sops.yaml - Re-encrypt:
sops updatekeys <secrets.yaml> - Rotate any secrets they had access to
CI has its own age keypair. The private key is stored as a single GitHub Actions secret (SOPS_AGE_KEY). The public key is listed in .sops.yaml alongside developer keys.
- Add the project under
packages/<project>/. - For each environment it needs, add module instances in
packages/infra/environments/<env>/— typically a Turso database and a Cloudflare Worker deploy, wired via imports. - Put any required secrets (API tokens, provider credentials) into
packages/infra/environments/<env>/secrets.yaml, encrypted via SOPS. - Run
zbc apply <env>locally to validate. Preview still applies automatically on PRs; production does not — it ships when someone runs/release.
Nothing releases on merge. Pushing to main deploys nothing, publishes
nothing and tags nothing — releasing is one deliberate act, run through the
/release skill (.claude/skills/release/SKILL.md). That skill is the
reference; this is the summary.
It became manual on 2026-09-03, after both failure directions happened. #115
shipped the instance-level ephemeral rule with no version bump and never
reached npm. Earlier, two commits landed under the split prefix between v0.10.6
and v0.10.7 with no version naming them — one renaming provision-core's marker
directory, which re-provisions a consumer's whole fleet. Neither was reported,
because neither was a failure: the workflows did what they said.
bun scripts/release.ts # dry run: what would ship, and every refusal
bun scripts/release.ts minor --push # bump, commit, tag zbc-cli-v<version>, push main
gh workflow run publish-npm.yml # never publish locally — it stages and burns the version
gh workflow run publish-core.yml # tags zbc-core-v<version> — every release; init/update pin it exactly
gh workflow run production.yml -f instances=ALLWrite the CHANGELOG entry before the bump, and only when the release changes
something a consumer already depends on — packages/cli/CHANGELOG.md is for
releases you must read before upgrading, not a commit log.
scripts/release.ts refuses eight ways a release goes wrong, all at once:
not-main, dirty, not-synced, tag-exists, cli-tag-exists,
npm-published, nothing-to-release, not-ahead.
Note: existing scaffolded repos have their own checked-in workflows from
whenever they last ran zbc init — template changes do not flow into them
automatically. They need a re-scaffold or manual patch to pick up workflow
updates.
The Prose design system is split across two packages:
packages/design-system/— pure component library. No build, no app. Exports React components + CSS tokens.packages/design-system-viewer/— Astro showcase app that consumes the library via@zbc/design-system. The first proving ground for the consumer pattern.
Run the viewer locally:
bun run dev # turbo dispatches to @zbc/design-system-viewerOpens at http://localhost:3000. The viewer shows all components and pages in isolation, with dark/light toggle.
- Module/src layout:
packages/infra/modules/andpackages/infra/src/are symlinks intopackages/cli/templates/infra/. Thecli/templates/tree is the source of truth (it's whatzbc initscaffolds into new projects); this repo is a live consumer of its own templates. Edit modules atpackages/cli/templates/infra/modules/<name>/, not via the symlink. - Agent plugin:
packages/cli/plugin/is thezbcClaude Code plugin consumers install (/plugin marketplace add Zabaca/zbc,/plugin install zbc@zbc;zbc initenables it in the scaffolded.claude/settings.json). It has two skills:zbc(operate a project, withcli.md,modules.mdandwiring.mdbeside it) andzbc-module(write a module). The marketplace serves it from main, so it describes the CLI as it stands here. When you change a command, a flag or the set of built-in modules, update the skill in the same PR.src/plugin.test.tsfails on a flag or command it doesn't know and on a module the catalog doesn't list. It deliberately has noversionfield, because a pinned version that nobody bumps would hold installs back. - Runtime: Bun — use
buneverywhere (bun install,bun run,bunx). Do not use npm or yarn. - Publishing
@zabaca/zbc: dispatchpublish-npm.yml; do not publish from your machine. npm restricts 2FA-bypass tokens for direct publishing, so a localbun publishstages a version that never commits and can never be published again (0.16.2 and 0.16.3 were burned this way). CI publishes by trusted publishing (OIDC) — there is no npm token; each package namesZabaca/zbc+publish-npm.ymlas its trusted publisher on npmjs.com.bun pm packbuilds the tarball andnpm publish <tarball>uploads it: npm is the only client that speaks OIDC, andnpm publishrun from the package directory drops thezbcbin entry, so never run it there. - Styling: Tailwind CSS v4 — uses the new
@import "tailwindcss"syntax and CSS-first config. Notailwind.config.js. - No shadcn/ui — this is a deliberate choice. Components are hand-authored to match the Prose design system exactly.
- Single-tenant design system —
packages/design-system/is purpose-built for Zabaca. Do not treat it as a generic component library. .claude/directory — mostly gitignored. The exception is.claude/skills/, which is committed and contains AI slash command definitions.- Mode A vs Mode B — design system authoring (Mode A) happens in claude.ai/design; implementation (Mode B) happens here, governed by
/mode-band/visual-review.
Issues live in Fredrin as tickets, managed via the fredrin CLI — not GitHub Issues. See docs/agents/issue-tracker.md.
Scope a ticket to what a Worker can do from a worktree. A Worker cannot deploy to production, verify against it, publish, tag, merge, or touch a provider dashboard — those are operator steps after merge, and a ticket must not list them as acceptance criteria. Full list in docs/agents/issue-tracker.md under "What a Worker cannot do".
Linked at the top of this file. Infrastructure keeps its glossary at the root (CONTEXT.md + docs/adr/) because it spans packages/cli/ and packages/infra/; Agent keeps its own under packages/agent/; walgit keeps its own with the package, so it ships to consumers (edit it at packages/cli/templates/apps/walgit/CONTEXT.md, never through the symlink); agentgit keeps its own under packages/agentgit/. See docs/agents/domain.md for how to maintain them.
MIT — Copyright (c) 2026 Zabaca.