Local development

Run a development copy of Calends, the common commands, how the code is laid out, and what to check before a pull request.

On this page

Use this guide to start a development environment and run checks before changing Calends source code.

  1. Install Node.js 24, clone the repository and run the setup commands below.
  2. Open the local app; follow the instructions for .dev.vars if you need to bypass sign-in.
  3. Run checks relevant to your changes, then review the full checklist before submitting.

Start

You’ll need Node.js 24.

Terminal window
git clone https://github.com/imetn/calends && cd calends
npm ci
npm run db:migrate:local
npm run dev

To bypass sign-in during development, add DEV_BYPASS_AUTH=1 to .dev.vars, preserving existing contents.

npm run dev starts two processes: Vite (front end with hot reload, bound to 0.0.0.0:5173 with LAN and Tailscale *.ts.net access) and wrangler (the Worker and a local D1, :8787), with a watchdog that automatically restarts the Worker if its port stops responding without restarting Vite. Open http://127.0.0.1:5173 locally.

The local database is kept in .wrangler/state at the repository root.

Common commands

Command What it does
npm test Unit tests (billing, phases, metrics, shared plans, categories and more)
npm run typecheck TypeScript type check
npm run lint oxlint
npm run format / npm run format:check Prettier format / check
npm run i18n:check Checks every language has every string
npm run build Production build
npm run email:preview Renders every reminder email with sample data into .preview/email/ as HTML; sends nothing

Code layout

app/src/ app and public page
shared/ billing, phases, metrics, FX, masking, i18n — shared by browser and Worker
worker/ API, auth (password + passkeys), MCP, reminders and channels, backup, ICS
worker/migrations/ D1 / SQLite schema
docker/ self-hosting image entrypoint

Stack: React 19, the React Compiler and Vite for the app, with HeroUI / React Aria for dialogs, menus and controls; shadcn/ui for the public page; Cloudflare Workers + D1 on the server.

Before a pull request

Terminal window
npm run typecheck && npm run lint && npm run format:check && npm run i18n:check && npm test && npm run build

A few ground rules (see CONTRIBUTING.md in the repository):

  • Domain logic lives in shared/ and must run in both the browser and the Worker — no DOM or Node APIs. Add unit tests in shared/*.test.ts for billing, phase or metric changes.
  • Every user-visible string goes through t(), and never at module top level. Add new strings to en and zh-CN at least.
  • Keep stored data compatible. Old records must keep working; schema changes go in a new file under worker/migrations/; new data must round-trip through backups.
  • Privacy: anything that could identify a person or account stays off the public page; shared/mask.ts allow-lists what’s shared.
  • Keep the UI consistent with existing components and check phone width (390px), desktop, light and dark.

Use an isolated .wrangler/state and fictional data for import, restore and migration checks. The public demo is a dedicated deployment, not an npm run demo seed command. Read the repository’s AGENTS.md, ARCHITECTURE.md and CONTRIBUTING.md before changing a subsystem.