Imported from mysticfalconvt/todo-gameification (
AGENTS.md). Install upstream withnpx skills add mysticfalconvt/todo-gameification. Copyright stays with the author.
AGENTS MD – Quick Reference for OpenCode Sessions
-
Dev Setup & Core Commands
pnpm install– install deps.pnpm db:migrate– apply pending migrations (runs on container boot).pnpm dev– start Vite SSR dev server (http://localhost:3000).pnpm build→pnpm start– production build then run built.output/.pnpm test– Vitest suite.pnpm db:generate– hand‑write new SQL migration and updatemeta/_journal.json.
-
Environment
- Required vars:
DATABASE_URL,BETTER_AUTH_SECRET,VAPID_PUBLIC_KEY,VAPID_PRIVATE_KEY. - LLM config for task categorizer/scorer lives in
src/server/llm/client.ts.
- Required vars:
-
Database / Drizzle
- Schema in
src/server/db/schema.ts; migrations are hand‑written SQL files undersrc/server/db/migrations/with an idempotent entry inmeta/_journal.json. - Never rely on
drizzle-kit generateprompts; write migration SQL manually.
- Schema in
-
Routing (TanStack Start)
- Folder‑based routes only. A file like
stats.task.$taskId.tsxcreates an implicit layout (stats.tsx). If the parent lacks<Outlet />, child pages break – always use a folder when you need a nested route. _authenticated/contains all pages requiring a session.
- Folder‑based routes only. A file like
-
Server Functions
- Thin wrappers in
src/server/functions/*.ts; real logic lives in corresponding services undersrc/server/services/*. - Keep auth & input validation here; move business rules to services.
- Thin wrappers in
-
Event Log is Source of Truth
- All state changes (XP, streaks, task completions) are append‑only events in the
eventstable. - Re‑play logic lives in
src/server/services/tasks.ts. When modifying progression, read that replay code first.
- All state changes (XP, streaks, task completions) are append‑only events in the
-
Service Worker Caching
public/sw.jsuses stale‑while‑revalidate for/api/*.- Bump
CACHE_VERSIONat the top whenever an API response shape changes; otherwise clients may keep outdated shapes.
-
Arcade Game Onboarding Migration Pattern
- Adding a new game → update
src/games/registry.ts. - Ship companion migration that:
- Grants every existing user enough tokens to try the game.
- Creates a
try‑<gameId>task withexternal_ref = 'onboarding-try-<gameId>'(idempotent via dedup andtokens.grantedevent reason key).
- Use
0017_arcade_onboarding.sqlas the template.
- Adding a new game → update
-
Testing Quirks
- Vitest runs against an in‑memory SQLite fallback unless
DATABASE_URLpoints to a real Postgres instance. - For integration tests that need background jobs, start
pg-bossviapnpm dev(the dev server launches the queue automatically).
- Vitest runs against an in‑memory SQLite fallback unless
-
Helpful Docs & Sources
- Authoritative design:
architecture-plan.md. - Existing instruction baseline:
CLAUDE.md.
- Authoritative design:
Only add or modify entries here when a future OpenCode agent would otherwise miss these repo‑specific nuances.