# Door framework A door is a self-contained game/program launched from the **D**oor Games menu. ## Contract (`types.ts`) ```ts interface DoorModule { id: string; // stable; also the migration namespace ("/001_init.sql") name: string; // menu name description: string; // menu blurb, keep under ~45 chars minSecurity?: number; // users.security_level needed to see it migrationsDir?: string;// path.join(__dirname, 'migrations') init?(): Promise;// once at server start, after migrations (start timers here) run(s: Session): Promise; // one caller's visit; return to go back to the BBS } ``` - `doorMenu.ts` lists `registry.ts` entries and runs one. A non-`Disconnected` error thrown from `run` is caught and logged, and the caller goes back to the menu instead of being hung up on. - While a caller is in a door, `s.activity` is the door name (shown in Who's Online). ## Adding a door 1. `src/doors//index.ts` exporting a `DoorModule`. 2. Optional `src/doors//migrations/NNN_name.sql`. Prefix tables with a short door tag (e.g. `sl_`). 3. Add one import line to `registry.ts`. 4. Add `src/doors//CLAUDE.md` describing the door's design and file map. 5. Keep game rules in pure modules with `*.test.ts` next to them; `npm test` picks them up. Imports allowed from a door: `../../session/*`, `../../ui/*`, `../../db`, `../../nodes`, `../../users/userRepo`. Nothing else from core, and nothing from other doors.