This file provides persistent instructions for AI agents working on the Routine Minder codebase. Adhere to these rules to ensure architectural consistency and type safety.
- Tooling: Prefer
npmfor all package management. Usenpx wranglerfor Cloudflare-related tasks. - Communication: Provide a concise technical rationale before executing any file modification.
- Validation: Always run unit tests (
npm run test) after modifying logic inclient/src/lib/. - Safety: Never log or commit secrets. Use
.env.exampleas a template for new environment variables.
- Node Version: Use Node.js 22 for all build and test operations.
- Offline-First Architecture:
localStorageis the primary source of truth for the UI.- All data fetching and background sync logic must reside in
client/src/lib/storage.ts. - Do not create new React hooks for data fetching; use the existing
storage.tsAPI.
- Type Safety:
- Define all Zod schemas in
client/src/lib/schema.ts. - Manually sync types to the worker if changes affect the API contract (until a
shared/package is implemented).
- Define all Zod schemas in
- Environment Variables:
- Vite variables (starting with
VITE_) must be placed inclient/.env.local. - Worker variables (like
API_SECRET) are managed viawrangler.tomlor Cloudflare Dashboard.
- Vite variables (starting with
- Linting & Formatting: Follow existing Prettier and ESLint configurations. Use Tailwind utility classes; avoid raw CSS.
- UI Components: Use
shadcn/uiprimitives fromclient/src/components/ui/. Do not modify these directly. - Styling: Adhere to the Glassmorphism system (
.glass,.glass-card). - Design Future: Consult
design/humble_hearth/DESIGN.mdbefore proposing significant UI refactors. - State Management: Use TanStack Query in page components (
client/src/pages/) to interface withstorage.ts.
- Framework: Hono 4.x.
- Database: Cloudflare D1 (SQLite). Reference
SCHEMA.mdfor current table structures. - Deployment: Always use
--config worker/wrangler.tomlwhen running wrangler from the root. - Middleware: Ensure
X-API-Keyprotection is maintained for all/api/*endpoints.
- Unit Tests: Add tests to
client/src/lib/achievements.test.tsfor any changes to the gamification engine. - E2E Tests: Use Playwright (
e2e/app.spec.ts). Ensure tests pass before submitting changes to the UI or Auth flows.