This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
These rules apply automatically when this is a git repository, unless the user explicitly says otherwise:
- Branch before changes: Before executing any plan that modifies code, create a new feature branch from the current branch. Use conventional branch naming:
feat/description,fix/description,chore/description,refactor/description, etc. Never make plan changes directly onmainordev. - Commit after plan execution: After completing a plan execution, run the
/commitskill to create a properly formatted commit. - Branch naming: Use lowercase kebab-case after the prefix (e.g.,
feat/add-user-search,fix/login-redirect,chore/update-deps).
# Backend
deno task dev # Run backend in watch mode
deno task start # Production start
# Frontend
cd app && npm run dev # Vite dev server (port 3000, HTTPS)
cd app && npm run build # Production build
cd app && npm run lint # ESLint
cd app && npm run storybook # Storybook (port 6006)
# Full stack
deno task check # fmt + lint + test (all backend)
deno task migrate # Run database migrations
deno task migrate:tests # Migrations on test database
# Testing
deno task test # All backend tests (needs MongoDB)
deno test -A deno/server/inter/http/routes/__tests__/channels.test.ts # Single test file
deno test -A --filter "channel:create" # Filter by test name
cd app && npm run types # TypeScript check (frontend)
cd app && npm run chromatic # Visual regression testingMonorepo: Deno workspace (backend) + npm (frontend), single Docker container.
app/ # React 19 PWA (Vite, styled-components, MobX)
deno/
server/ # Main backend (Clean Architecture)
core/ # Domain logic: commands, queries, bus, events, errors
infra/ # MongoDB repos, db client
inter/ # HTTP routes (Planigale), CLI, middleware
api/ # @quack/api — shared types + client class
config/ # @quack/config — config loader
encryption/ # @quack/encryption — ECDH, AES-GCM, PBKDF2
storage/ # @quack/storage — file storage abstraction (fs/gcs/memory)
migrate/ # Database migrations
tools/ # Dev utilities
plugins/ # Plugin system (e.g., giphy)
mobile/ # Capacitor Android shell
- Core (
deno/server/core/): Domain logic.createCommand()(write ops, Valibot validation, MongoDB transactions) andcreateQuery()(read ops). Internal event bus for cross-domain communication. Domain errors (AppError,ResourceNotFound,AccessDenied). - Infra (
deno/server/infra/): GenericRepo<Query, Model>base class with CRUD. Domain-specific repos. MongoDB client. - Inter (
deno/server/inter/): HTTP routes organized by domain underhttp/routes/. Session-based auth middleware. Error-to-HTTP mapping.
Domains: channel/, message/, user/, session/, emoji/, readReceipt/, command/.
- Components:
atoms/→molecules/→organisms/→pages/(strict import hierarchy — atoms/molecules cannot import from organisms/pages, enforced by ESLint) - State: MobX models in
app/src/js/core/models/. RootAppModelwith sub-models (channels, users, messages, etc.). Components wrapped withobserver(). - Contexts (8): AppContext, ThemeSelectorContext, InputContext, MessageContext, HoverContext, SidebarContext, SizeContext, TooltipContext — all follow
createContext(null)+useXxx()hook +XxxProviderpattern. - Styling: styled-components with transient
$props, 4 themes incontexts/themes.json. - Real-time: SSE at
/api/sse(not WebSocket) — server pushes events, client dispatches to MobX models.
REST: Component → MobX action → API client → HTTP route → Command/Query → Repo → MongoDB
SSE: Core event → SSE stream → API client EventSource → MobX model → observer() re-render
PBKDF2 key derivation → ECDH key exchange (P-256) → AES-GCM message encryption. XOR-based 2-of-2 secret splitting for key backup.
- Conventional Commits:
feat:,fix:,refactor:,chore:,docs:,test:,perf: - Branches:
main(production),dev(integration), PRs targetdev, squash merge - File naming: Backend
camelCase.ts, componentsPascalCase.tsx, hooksuseXxx.ts, modelscamelCase.ts, tests__tests__/name.test.ts - Backend barrels:
mod.ts; Frontend: no barrels (direct imports) - Import order: external libs → types → core/models → components (atoms→molecules→organisms) → utils
- Never mention AI usage in code or documentation
- Do not add AI co-author lines to commits
Backend: @planigale/planigale (HTTP framework), @planigale/sse, @planigale/testing (test agent), mongodb, valibot
Frontend: react@19, mobx + mobx-react-lite, styled-components, react-router-dom@7, vite, storybook
docs/ARCHITECTURE.md— system architecture diagramdocs/CONVENTIONS.md— detailed coding patterns with examplesdocs/adr/— 13 Architecture Decision Records