Use these steps to run kody locally and on Cloudflare Workers.
If you are here to understand the purpose of this repository rather than set it
up, read docs/contributing/project-intent.md first.
Some docs and parts of the repo structure reflect starter-oriented conventions,
and the project intent is to build a personal assistant with an MCP-first
architecture.
We use npm for installs and scripts, with Node 26 as the runtime.
npm installTo scaffold a new project from the epicflare template instead of working
inside this repo, run npx create-epicflare.
The setup flow assumes:
- Node 26 and npm are installed.
- You run commands from the repo root (needs
nx.json,package.json, andpackages/worker/wrangler.jsonc). - Cloudflare D1 and KV: The checked-in
packages/worker/wrangler.jsoncdeclares bindings anddatabase_namevalues but does not commit remote resource IDs (database_id, KVid/preview_id). Production and preview deploys run ensure scripts that create or resolve resources and write generated Wrangler configs with real IDs (seedocs/contributing/setup.md). Local development does not require provisioning remote D1 or KV;npm run devuses local Wrangler persistence.
See docs/contributing/setup-manifest.md for required resources and secrets.
For optional Cloudflare offerings (R2, Workers AI, AI Gateway, extra KV), see
docs/contributing/cloudflare-offerings.md.
Verify Node 26 and that dependencies are installed:
node --version # expect v26.x
npm installFor deploy work, confirm Wrangler can reach your Cloudflare account:
npx wrangler whoami- Copy the local environment file and adjust secrets if needed:
cp packages/worker/.env.example packages/worker/.envCOOKIE_SECRET and SECRET_STORE_KEY are required. The example file includes
placeholder values that work for local development.
- Apply local D1 migrations:
npm run migrate:local- Start local development:
npm run devThe CLI prints the resolved URL (default port 3742). Health check:
curl http://localhost:<port>/healthLocal setup does not create Cloudflare resources. The checked-in Wrangler
template omits remote D1/KV IDs on purpose. The production deploy workflow runs
node tools/ci/production-resources.ts ensure, which creates missing D1/KV
resources when needed and writes
packages/worker/wrangler-production.generated.json with resolved IDs for that
deploy. Cloudflare deploys do not auto-create those resources from bindings
alone, so the workflow runs that ensure step before migrations/deploy.
- Configure GitHub Actions secrets and variables for deploy:
CLOUDFLARE_API_TOKEN(Workers deploy + D1 edit + Workers KV Storage:Edit access on the correct account)COOKIE_SECRET(generate withopenssl rand -hex 32or similar)- See
docs/contributing/setup-manifest.md(GitHub Actions configuration) for full optional secrets/variables and where to get each value.
- Deploy:
npm run deployFor non-interactive or automated setup:
- Ensure
packages/worker/.envexists (copy from.env.exampleif missing). - Run migrations and the full validation gate:
npm run migrate:local
npm run validatenpm run validate is the single authoritative local gate. It runs format, lint,
typecheck, unit tests, Playwright E2E, MCP E2E, backup build, and structure
checks in parallel. CI runs the same checks as parallel jobs (node and workers
unit suites on separate runners).
To seed a deterministic test login after migrations:
node tools/seed-test-data.ts --localCloudflare resources are managed during deploy. Deploy-time ensure steps inject real D1/KV IDs into generated Wrangler configs (not into the checked-in template).
See docs/contributing/setup.md for local dev commands and verification steps.
To create a deterministic test login in a running environment:
npm run migrate:local
node tools/seed-test-data.ts --localDefault fixture credentials (both use password ilikecode):
kody@example.com— admin fixture (seeded with theadminrole)jane@example.com— regular fixture (userrole only)
These credentials are a local test fixture only. Pass
--email <email> --password <password> when you need explicit fixture
credentials (custom accounts are non-admin unless you pass --admin).
Build the project:
npm run buildDeploy to Cloudflare:
npm run deploy