You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What does the local dev environment look like — designed for where Patchy Cloud is going (Effect 4, more than one service) but shipped small first? The dev runner and how agents start it, drive it, keep it alive across turns, and tear down only what they created; per-worktree ports and state; how the CLI is pointed at the local instance and never at a remote one by accident; the Postgres and test story (hermetic database, no describe.skip anywhere but CI); seeding; --dry-run --json; dev version stamping.
Resolves to requirements the Effect v4 port map inherits, and possibly a prototype ticket for the runner. Input: Local dev for a multi-service Effect monorepo — the options.
A small Effect 4 CLI under scripts/ owns the plan; pnpm dev is its entry point. Ships small: server + embedded Postgres only. No forward-designed service registry or reserved service names — rework when the next service's shape is known.
Per-worktree ports from a hash of the worktree path (t3code's rule, scan upward for a free port), so worktrees run and test in parallel. Per-worktree state in <worktree>/.local/dev/ (Postgres data, logs, env, plan.json); nothing shared across worktrees.
Start is idempotent and end to end: compute plan → initdb if missing → start Postgres → run migrations automatically on every start → seed → start server → write .local/dev/env + plan.json → print the plan. The runner daemonises so the instance survives the agent's shell call; later turns attach.
Subcommands: status, stop, logs, reset. stop kills only the PIDs plan.json records and keeps state; reset = stop + wipe .local/dev/ + re-initdb. Both scoped to the current worktree, always.
--dry-run --json prints the resolved Plan with no side effects. Plan (also written as plan.json) is the only machine-readable contract; logs are for humans. The runner's first tests are plan-computation tests (hash → ports, worktree detection), which need no processes.
Supervisor is undecided → prototype ticket Dev runner supervisor prototype.
CLI targeting
The CLI reads .local/dev/env by walking up from cwd and ranks it above PATCHY_API_URL and ~/.patchy; only --api-url overrides. Mutating commands print where the target came from. A dev checkout can never publish to a remote instance by accident. (Surprising precedence, hard to reverse once agents depend on it — the port records it as an ADR when implemented.)
Postgres and tests
embedded-postgres everywhere — dev, tests, CI. No Docker, no postgres:17-alpine service, pinned version. Neon's local story is a cloud-backed proxy, so the inner loop stays hermetic; Neon branches are reserved for per-PR CI once preview deployments exist (fog).
No skip gate.PATCHY_REQUIRE_POSTGRES_TESTS / PATCHY_TEST_DATABASE_URL go away. Vitest globalSetup starts one cluster per run, applies migrations + seed, template-clones per test (CREATE DATABASE … TEMPLATE), with non-durable settings on. The only permitted skip is a platform one, and it fails loudly in CI.
Seeding
Fresh dev instance = one dev company + one working token, the token written into .local/dev/env so the CLI works immediately after pnpm dev. Seeds are SQL fixtures applied through the migration runner; the same fixture module feeds tests. Expanded as tiers 1 and 2 land, not before.
Source resolution and versions
exports point at src/*.ts unconditionally; bundle at release (t3code's way). Keep tsx; don't churn .js specifiers for Node type-stripping.
Dev version stamp 0.0.0-dev.g<sha>[.dirty] from git describe --dirty, so bug reports distinguish releases from dirty checkouts and a dev build never satisfies a release range. No ordering — that's a release-channel concern, out of scope.
Activity
allisonmahmood commentedon Aug 26, 2026
Resolution
Requirements the Effect v4 port map inherits. Grilled with Allison, 2026-08-26; input was Local dev for a multi-service Effect monorepo — the options.
The runner
scripts/owns the plan;pnpm devis its entry point. Ships small: server + embedded Postgres only. No forward-designed service registry or reserved service names — rework when the next service's shape is known.<worktree>/.local/dev/(Postgres data, logs,env,plan.json); nothing shared across worktrees.initdbif missing → start Postgres → run migrations automatically on every start → seed → start server → write.local/dev/env+plan.json→ print the plan. The runner daemonises so the instance survives the agent's shell call; later turns attach.status,stop,logs,reset.stopkills only the PIDsplan.jsonrecords and keeps state;reset= stop + wipe.local/dev/+ re-initdb. Both scoped to the current worktree, always.--dry-run --jsonprints the resolvedPlanwith no side effects.Plan(also written asplan.json) is the only machine-readable contract; logs are for humans. The runner's first tests are plan-computation tests (hash → ports, worktree detection), which need no processes.CLI targeting
.local/dev/envby walking up fromcwdand ranks it abovePATCHY_API_URLand~/.patchy; only--api-urloverrides. Mutating commands print where the target came from. A dev checkout can never publish to a remote instance by accident. (Surprising precedence, hard to reverse once agents depend on it — the port records it as an ADR when implemented.)Postgres and tests
postgres:17-alpineservice, pinned version. Neon's local story is a cloud-backed proxy, so the inner loop stays hermetic; Neon branches are reserved for per-PR CI once preview deployments exist (fog).PATCHY_REQUIRE_POSTGRES_TESTS/PATCHY_TEST_DATABASE_URLgo away. VitestglobalSetupstarts one cluster per run, applies migrations + seed, template-clones per test (CREATE DATABASE … TEMPLATE), with non-durable settings on. The only permitted skip is a platform one, and it fails loudly in CI.Seeding
.local/dev/envso the CLI works immediately afterpnpm dev. Seeds are SQL fixtures applied through the migration runner; the same fixture module feeds tests. Expanded as tiers 1 and 2 land, not before.Source resolution and versions
exportspoint atsrc/*.tsunconditionally; bundle at release (t3code's way). Keep tsx; don't churn.jsspecifiers for Node type-stripping.0.0.0-dev.g<sha>[.dirty]fromgit describe --dirty, so bug reports distinguish releases from dirty checkouts and a dev build never satisfies a release range. No ordering — that's a release-channel concern, out of scope.