From 90cf57589b9f6f8dc8ea59d7fa89d4f70f47e941 Mon Sep 17 00:00:00 2001 From: Arcadia Rose Date: Fri, 4 Sep 2026 22:39:48 -0400 Subject: [PATCH] Document preferences in CLAUDE.md --- .gitignore | 3 +++ frontend/src/CLAUDE.md | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 frontend/src/CLAUDE.md diff --git a/.gitignore b/.gitignore index b947077..37fab99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ node_modules/ dist/ + +\#.*\# +*.*\~ diff --git a/frontend/src/CLAUDE.md b/frontend/src/CLAUDE.md new file mode 100644 index 0000000..b33b5eb --- /dev/null +++ b/frontend/src/CLAUDE.md @@ -0,0 +1,23 @@ +Project structure +- frontend/ and backend/ are fully separate npm packages — own package.json, own tsconfig.json, own dist/. +- Backend's only job right now: serve frontend/ as static files. + +TypeScript setup +- Strict mode on in both tsconfigs. +- No bundler — plain tsc, so relative imports must use the compiled .js extension (./canvas.js) even in .ts source, for native browser ESM resolution. +- dist/ and node_modules/ gitignored in both packages. + +Module style +- Namespace imports only: import * as canvas from "./canvas.js", then canvas.thing — no named imports. +- One-line file-header comment stating the module's responsibility (// ui.ts provides the translation layer...). + +Code shape (functional core / imperative shell) +- Pure functions do geometry/logic (canvas.ts's layout math, ui.ts's handleClick reducer) — no DOM/canvas access, take data in, return data out. +- Impure code (drawing, event listeners) stays thin and isolated at the edges, composed on top of the pure functions. +- App state lives in one place (main.ts), passed to other modules via getState/setState closures rather than modules owning their own mutable state. + +Types +- A type lives in the file that owns that concept (Piece/BoardLayout in canvas.ts, Player/BoardState in game.ts), exported for other modules to reference via their namespace import. + +Naming +- When a namespace import (canvas) collides with a local variable of the same concept (an HTMLCanvasElement), the local variable gets suffixed (canvasEl), not the import. \ No newline at end of file -- 2.51.2