Skip to content

Commit c8a4194

Browse files
authored
Improve AGENTS.md (#188)
1 parent 82cd960 commit c8a4194

File tree

4 files changed

+55
-16
lines changed

4 files changed

+55
-16
lines changed

AGENTS.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,33 @@ Guidance for coding agents working in this repository.
1313

1414
Prefer these commands:
1515

16-
- `make check` to run all the verification steps
16+
- `make dev` to start the local Docker-backed development stack
17+
- `make dev-all` to start the broader local development workflow
18+
- `make populate-local-dev` to seed the local stack with test data
19+
- `./scripts/login.ts admin` to automate logging into the seeded admin account
1720
- `make test` to run all tests
1821
- `npx jest path/to/test.test.ts` to run a single test file
1922
- `make lint` to run ESLint
20-
- `make typecheck` to run check types
23+
- `make typecheck` to run type checking without emitting files
24+
- `make watch-typecheck` to run type checking in watch mode
2125
- `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
26+
- `make audit` to run the Bun security audit
27+
- `make smoketest` to run smoke tests
28+
- `make check` to run the standard verification suite: test, lint, typecheck, unused-exports, audit
29+
- `make fix` to apply automatic ESLint fixes
30+
31+
Use `make start` only inside the devcontainer. It is not the normal local app entrypoint.
2432

2533
Local app stack endpoints:
2634

2735
- App: `http://localhost:8080`
2836
- Mailcatcher: `http://localhost:1080`
2937

38+
Seeded local users created by `make populate-local-dev`:
39+
40+
- `foo@example.com` for a regular member
41+
- `admin@example.com` for a super user
42+
3043
## Architecture
3144

3245
This app is built around event sourcing.
@@ -36,43 +49,68 @@ This app is built around event sourcing.
3649
- Queries live in `src/queries/`
3750
- Authentication flows live in `src/authentication/`
3851
- Background sync code lives in `src/sync-worker/`
52+
- HTTP handlers live in `src/http/`
53+
- Top-level routes are wired in `src/routes.ts`
54+
- Event store code lives in `src/init-dependencies/event-store/`
3955

4056
Important boundaries:
4157

4258
- Commands validate authorization and business rules, then emit domain events.
4359
- Commands should only use the events passed to them. They should not query read models directly.
4460
- Read models project events into queryable state.
4561
- Queries read from read models and render HTTP responses.
62+
- Read models are eventually consistent, so do not assume command results are immediately visible in read-side code.
63+
- The sync worker ingests external state and turns it into events instead of bypassing the event model.
4664
- Communication across the app should happen via events, not by coupling command code to read-model code.
4765

66+
Important domain notes:
67+
68+
- Events are immutable facts. Prefer adding a new event over mutating prior state assumptions.
69+
- The event store uses optimistic concurrency and resource versioning.
70+
- Authentication is passwordless and handled by magic link flows under `src/authentication/`.
71+
- Member numbers are linked to email addresses through domain events.
72+
- Actor types include `system`, `token`, and `user`.
73+
- Be careful with authorization, session, and member-linking changes.
74+
75+
External integrations:
76+
77+
- Recurly provides subscription-related data.
78+
- Google Sheets provides training and trouble-ticket data.
79+
- Paxton data is read from an external service.
80+
- Sync-related tests commonly use fixtures under `tests/data/`.
81+
4882
## Project patterns
4983

5084
- Prefer existing fp-ts patterns such as `TaskEither`, `Option`, and `pipe`.
5185
- Use existing io-ts types and decoders where applicable.
5286
- Use `deps.logger` for logging instead of `console.log`.
53-
- Follow the repos current style rather than introducing a new abstraction or library unless necessary.
87+
- Follow the repo's current style rather than introducing a new abstraction or library unless necessary.
5488
- 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.
89+
- Preserve the existing command, read-model, query, and sync-worker boundaries instead of shortcutting across layers.
90+
- When wiring new behavior, prefer extending the matching layer and handler path rather than adding ad hoc logic to routes or HTTP glue.
6191

6292
## Testing guidance
6393

64-
Tests live under `tests/` and mirror the source layout.
94+
Tests live under `tests/` and usually mirror the source layout.
6595

6696
- Use `.test.ts` files.
6797
- Command tests should assert on resulting events.
6898
- Read-model tests should feed events into the read model and assert on query results.
6999
- It is acceptable in read-model tests to use `command.process()` only to generate events for setup.
70100
- Avoid calling read models from command tests.
71-
- Tests should follow a behaviour driven testing style
101+
- Tests should follow a behaviour-driven style.
102+
103+
Directory mapping notes:
104+
105+
- Most source paths map directly into `tests/`
106+
- Before creating a new test file, inspect nearby tests and follow the local naming convention already in use.
72107

73108
Helpful test utilities already used in the repo:
74109

75110
- `faker` for test data
111+
- `jest-date-mock` for date-sensitive tests
112+
- `tests/helpers.ts` for shared test helpers
113+
- `tests/data/` for external-data fixtures
76114

77115
## Working norms for agents
78116

@@ -82,9 +120,10 @@ Helpful test utilities already used in the repo:
82120
- Preserve the command/read-model separation when adding features.
83121
- Avoid speculative refactors unless they are necessary for the task.
84122
- Do not overwrite unrelated local changes.
123+
- Check `Makefile`, nearby tests, and existing module patterns before introducing a new command or workflow.
85124

86125
## Useful references
87126

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
127+
- `README.md` for local setup, login flow, and operational context
128+
- `CLAUDE.md` for deeper repository architecture guidance
129+
- `Makefile` for the canonical development, verification, and helper commands

tests/commands/memberNumbers/link-number-to-email.test.ts renamed to tests/commands/member-numbers/link-number-to-email.test.ts

File renamed without changes.

tests/commands/memberNumbers/mark-member-rejoined-with-new-number.test.ts renamed to tests/commands/member-numbers/mark-member-rejoined-with-new-number.test.ts

File renamed without changes.

tests/queries/troubletickets/construct-view-model.test.ts renamed to tests/queries/trouble-tickets/construct-view-model.test.ts

File renamed without changes.

0 commit comments

Comments
 (0)