|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Guidance for coding agents working in this repository. |
| 4 | + |
| 5 | +## Quick start |
| 6 | + |
| 7 | +- Runtime: Node.js 20 |
| 8 | +- Package manager: Bun |
| 9 | +- Language: TypeScript |
| 10 | +- Test runner: Jest with `ts-jest` |
| 11 | +- Linting: ESLint |
| 12 | +- Primary workflow entrypoint: `make` |
| 13 | + |
| 14 | +Prefer these commands: |
| 15 | + |
| 16 | +- `make check` to run all the verification steps |
| 17 | +- `make test` to run all tests |
| 18 | +- `npx jest path/to/test.test.ts` to run a single test file |
| 19 | +- `make lint` to run ESLint |
| 20 | +- `make typecheck` to run check types |
| 21 | +- `make unused-exports` to detect unused exports |
| 22 | +- `make start` to start the local app stack |
| 23 | +- `make populate-local-dev` to seed local app stack with data |
| 24 | + |
| 25 | +Local app stack endpoints: |
| 26 | + |
| 27 | +- App: `http://localhost:8080` |
| 28 | +- Mailcatcher: `http://localhost:1080` |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +This app is built around event sourcing. |
| 33 | + |
| 34 | +- Commands live in `src/commands/` |
| 35 | +- Read models live in `src/read-models/` |
| 36 | +- Queries live in `src/queries/` |
| 37 | +- Authentication flows live in `src/authentication/` |
| 38 | +- Background sync code lives in `src/sync-worker/` |
| 39 | + |
| 40 | +Important boundaries: |
| 41 | + |
| 42 | +- Commands validate authorization and business rules, then emit domain events. |
| 43 | +- Commands should only use the events passed to them. They should not query read models directly. |
| 44 | +- Read models project events into queryable state. |
| 45 | +- Queries read from read models and render HTTP responses. |
| 46 | +- Communication across the app should happen via events, not by coupling command code to read-model code. |
| 47 | + |
| 48 | +## Project patterns |
| 49 | + |
| 50 | +- Prefer existing fp-ts patterns such as `TaskEither`, `Option`, and `pipe`. |
| 51 | +- Use existing io-ts types and decoders where applicable. |
| 52 | +- Use `deps.logger` for logging instead of `console.log`. |
| 53 | +- Follow the repo’s current style rather than introducing a new abstraction or library unless necessary. |
| 54 | +- Keep changes small and targeted. |
| 55 | + |
| 56 | +Authentication notes: |
| 57 | + |
| 58 | +- Login is passwordless and handled by magic link flows under `src/authentication/`. |
| 59 | +- Member numbers are linked to email addresses through domain events. |
| 60 | +- Be careful with authorization and session-related changes. |
| 61 | + |
| 62 | +## Testing guidance |
| 63 | + |
| 64 | +Tests live under `tests/` and mirror the source layout. |
| 65 | + |
| 66 | +- Use `.test.ts` files. |
| 67 | +- Command tests should assert on resulting events. |
| 68 | +- Read-model tests should feed events into the read model and assert on query results. |
| 69 | +- It is acceptable in read-model tests to use `command.process()` only to generate events for setup. |
| 70 | +- Avoid calling read models from command tests. |
| 71 | +- Tests should follow a behaviour driven testing style |
| 72 | + |
| 73 | +Helpful test utilities already used in the repo: |
| 74 | + |
| 75 | +- `faker` for test data |
| 76 | + |
| 77 | +## Working norms for agents |
| 78 | + |
| 79 | +- Prefer `rg` for searching the codebase. |
| 80 | +- Before broader verification, run the smallest relevant check for the files you changed when practical. |
| 81 | +- If you change behavior, add or update tests in the matching area under `tests/`. |
| 82 | +- Preserve the command/read-model separation when adding features. |
| 83 | +- Avoid speculative refactors unless they are necessary for the task. |
| 84 | +- Do not overwrite unrelated local changes. |
| 85 | + |
| 86 | +## Useful references |
| 87 | + |
| 88 | +- `README.md` for local setup and operational context |
| 89 | +- `CLAUDE.md` for repository guidance already written for coding assistants |
| 90 | +- `Makefile` for the canonical development, test, and lint commands |
0 commit comments