Imported from nearbycoder/clank.run (
templates/auth-todo/AGENTS.md). Install upstream withnpx skills add nearbycoder/clank.run --skill auth-todo. Copyright stays with the author.
Agent guide
This is a Clank full-stack application. Keep the safe path short, the generated output reproducible, and the app deployable after every task.
Working commands
npm run devbuilds, starts, watches, health-swaps, and browser-reloads the app at http://127.0.0.1:3000.npm run jobs:workerbuilds and starts a durable background worker.npm run jobs:schedulerbuilds and starts the cron scheduler.npm run buildcompilessrc/intodist/.npm testbuilds and runs the application-owned contract against an isolated database.npm run test:watchreruns that contract while tests are being edited.npm run doctorperforms local readiness diagnostics.npm run deploy:checkbuilds and verifies a deterministic artifact without login or upload.npm run deploybuilds, creates/links the project when needed, migrates, health-checks, and activates it.clank help --jsonexposes the CLI contract for automation.
File map
src/backend.ts: auth, schemas, owned data, queries, mutations, durable jobs, and authorization.src/jobs.ts: provider-neutral worker/scheduler process entry.src/view.tsx: accessible UI and stable agent-addressable controls.src/app.tsx: hydration, auth client, live query, and browser interactions.src/server.tsx: routes, SSR, CSP, static files, and API wiring.fixtures/: deterministic synthetic application states; never production data.tests/app.contract.mjs: manifest, backend, ownership, fixture, and SSR contract.migrations/: immutable ordered SQL history.clank.deploy.json: build, artifact, database, health, jobs, and public environment contract..clank/: local artifacts and project link; never commit it.
Invariants
- Preserve user ownership on every todo query and mutation.
- Enqueue follow-up work through mutation
jobsso application writes and job delivery commit atomically. Keep handlers idempotent because delivery is at least once. - Honor
context.signal, bound external calls, and put permanent failures in the dead-letter state for explicit inspection or retry. - Treat browser and agent input as untrusted; validate at the backend boundary.
- Give every backend function a precise
description; mark additive writes withagent: { destructive: false }, destructive writes explicitly, and internal functions withagent: false. - Pass the typed
createApi<typeof backend>()function reference to each server-backed control'sagentAction; the app contract must keep every rendered action current and MCP-visible. - Preserve the default
/__clank/mcpendpoint and OAuth flow unless an integration requires a documented path change. - Never edit, rename, or remove an applied migration. Add the next numbered migration.
- Keep secrets out of source, deployment config, logs, labels, and agent metadata. Use
clank secrets set. - Keep stable
agentIdand usefulagentLabelvalues on important controls. - Keep
/healthzcheap and independent of optional external services. - Do not hand-edit
dist/; it is generated. - Keep fixtures deterministic, secret-free, and limited to
.example.invalididentities.
Definition of done
Run npm test, npm run doctor, and npm run deploy:check. For UI changes, verify registration/login and todo creation in a browser. For data changes, update the deterministic fixture and verify both a fresh database and an existing migrated database. For backend changes, connect to /__clank/mcp, inspect tools/list, and verify the narrowest OAuth scope that can perform the action.