Skip to content

Commit 0fb57a0

Browse files
ctrlplusbclaude
andcommitted
docs: add CLAUDE.md for Claude Code guidance
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 356ec40 commit 0fb57a0

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Easy Peasy (v6.1.0) is a React state management library built on Redux + Immer. Source is JavaScript with handwritten TypeScript definitions in `index.d.ts`.
8+
9+
## Commands
10+
11+
```bash
12+
yarn install # Install dependencies
13+
yarn build # Rollup build (ESM + CJS → dist/)
14+
yarn lint # ESLint with auto-fix
15+
yarn test # Jest (jsdom)
16+
yarn test -- tests/actions.test.js # Single test file
17+
yarn test -- --testNamePattern="some test" # Single test by name
18+
yarn test:watch # Watch mode
19+
yarn test:coverage # Coverage report
20+
yarn dtslint # TypeScript type tests (tests/typescript/)
21+
```
22+
23+
## Architecture
24+
25+
**Redux wrapper with symbol-based type detection.** Models are plain JS objects; helpers (`action`, `thunk`, `computed`, etc.) tag properties with symbols (`$_a`, `$_t`, `$_c`, etc.) that `extract-data-from-model.js` uses to build dispatch routing and metadata maps during store creation.
26+
27+
### Middleware chain (in order)
28+
29+
Computed properties → user middleware → Redux Thunk → listeners → effects → persistence
30+
31+
### Key source files
32+
33+
- `src/create-store.js` — Store factory. Assembles middleware, initializes state, handles `addModel`/`removeModel`/`reconfigure`.
34+
- `src/hooks.js` — React hooks (`useStoreState`, `useStoreActions`, etc.) using `useSyncExternalStoreWithSelector`.
35+
- `src/helpers.js` — Public model definition API (`action`, `thunk`, `computed`, `effectOn`, `persist`, `reducer`, `debug`, `generic`).
36+
- `src/extract-data-from-model.js` — Recursive model traversal; builds action/thunk/listener/effect metadata and lookup maps.
37+
- `src/computed-properties.js` — Lazy evaluation via `Object.defineProperty` getters with memoization (`fast-deep-equal`).
38+
- `src/persistence.js` — Async/sync storage adapters, transformation pipeline, migration support.
39+
- `src/lib.js` — Internal utilities (`get`, `set`, `clone`, `createSimpleProduce` wrapping Immer with `autoFreeze: false`).
40+
41+
### Type definitions
42+
43+
All TypeScript types live in the root `index.d.ts` (not generated — hand-maintained). Uses `ts-toolbelt` for advanced type manipulation. Type tests are in `tests/typescript/` and run via `dtslint`.
44+
45+
## Conventions
46+
47+
- Node >= 14 (`.nvmrc` specifies 14), Yarn for package management
48+
- Babel transpiles source; no TypeScript compiler for source code
49+
- Tests use `@testing-library/react` and Jest with jsdom
50+
- ESLint extends airbnb + prettier
51+
- Husky pre-commit hooks run lint and tests
52+
- Immer configured with `autoFreeze: false` for mixed mutability

0 commit comments

Comments
 (0)