Development
How to build, test, and contribute to Democraft.
This page covers the day-to-day commands and conventions for working on Democraft itself.
Prerequisites
- Node.js ≥ 20
- pnpm ≥ 9 (
corepack enable && corepack prepare pnpm@9 --activate) - Playwright browsers (first time):
pnpm exec playwright install chromium
First-time setup
pnpm build is required once after install because workspace packages resolve from dist/. After that, turbo rebuilds upstream changes automatically when you run pnpm typecheck or pnpm build.
Day-to-day commands
All commands run from the repo root.
Target a single package with the pnpm filter:
Rebuilding a single package
If you edit source under packages/*/src/, rebuild that package for consumers to pick up the change:
Running the Studio
The Studio is launched via the CLI against a demo file. See the quickstart for the full flow with the demo-app example.
Running the docs
The documentation site is a Next.js app under apps/docs/.
The docs are bilingual (pt-BR + en). When you add a page, add the English file as content/<path>.mdx, its Portuguese translation as content/<path>.pt-BR.mdx, and update both metadata files. The two trees must have structural parity — same slugs (modulo translation), same headings.
Conventions
- Namespace:
@democraft/*. CLI binary:democraft. Data dir:.democraft/. Env vars:DEMOCRAFT_*. Diagnostic codes:DC0xx. - Authoring API: lives in
@democraft/core. Keep the surface small — every new step kind or option is a contract. - Types: shared types live in
@democraft/schema. Don't duplicate type definitions across packages. - Tests: vitest, colocated (
*.test.ts). The@democraft/testingpackage holds shared fixtures. - Builds: tsup for packages,
next buildfor the Studio and docs.
Documentation parity
Both locales must stay in sync. When editing docs:
- Make the same change in
content/<path>.mdxandcontent/<path>.pt-BR.mdx. - Keep code snippets identical across locales (only the prose changes).
- Do not translate API names, package names, CLI flags, or diagnostic codes.
- Update both
meta.jsonfiles when adding or reordering pages.
Reporting issues
Capture failures should include the trace.zip from .democraft/runs/<id>/ — it lets others reproduce the exact Playwright session. Run inspect and validate first to rule out structural demo errors.