nusmods / website
AGENTS.md690 starsChanged 6 years agoMITView on GitHub
The nusmods.com SPA: React 18, Redux 4 and React Router 5, bundled by a custom Webpack config (webpack/), plus its Vercel serverless functions. CI runs with TZ=Asia/Singapore. If a date or time test fails locally, rerun it with that timezone set.
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 40
Keep the bundle lean: check the size of new dependencies and code-split page-specific ones.
- Very specific: line 52
Use React Testing Library for new component tests.
- Very specific: line 55
Use src/test-utils/ for helpers (Redux store setup, fixtures).
- Very specific: line 56
Run snapshot updates with pnpm test -u <filter>, and only when the UI change is intentional.
- Very specific: line 62
After editing src/data/venues.json, the optimiser copy is synced by the pre-commit hook or by pnpm prepare:optimiser.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
website/
The nusmods.com SPA: React 18, Redux 4 and React Router 5, bundled by a custom Webpack config (webpack/), plus its Vercel serverless functions.
Commands
pnpm start # dev server (optimiser calls go to /api/optimiser/optimise)
pnpm start:local # dev server pointing optimiser at localhost:8020
pnpm start:optimiser # run Go optimiser test server on :8020
pnpm test # vitest unit tests (*.test.ts[x]) with coverage
pnpm test utils/modules # single file; filter is matched relative to src/
pnpm test:integration # *.integration.test.ts[x]
pnpm lint # oxlint + stylelint
pnpm typecheck
pnpm check # lint + typecheck + test
pnpm build # production build to dist/CI runs with TZ=Asia/Singapore. If a date or time test fails locally, rerun it with that timezone set.
Where things live
- Source lives directly in
src/, notsrc/js/as README.md's tree says. Imports resolve fromsrc/as the base:import { x } from 'utils/modules','actions/timetables','types/modules'. src/entry/main.tsx→App.tsx: app bootstrap.src/entry/export/: timetable-only build used by theexport/service (pnpm start:export,webpack.config.timetable-only.js).src/views/<feature>/: page components (timetable,modules,planner,optimiser,venues,today,mpe, …). Shared UI insrc/views/components, hooks insrc/views/hooks.src/actions,src/reducers,src/selectors: Redux. Persistence config is insrc/storage/persistReducer.ts; persisted reducers declare their ownmigrate/version.src/utils/: pure logic (timetable maths, module helpers, ical). Most unit tests live here; put new non-UI logic here so it can be tested without rendering.src/types/: shared types (modules.ts,timetables.ts,state.ts, …).src/types/global.d.tsdeclares build-time globals (NUSMODS_ENV,DATA_API_BASE_URL,OPTIMISER_API_URL, …) injected by Webpack's DefinePlugin and Vitestdefine.src/data/: static JSON (venues, holidays, bus stops, ModReg schedule).scripts/has generators for some of these (holidays, bus stops, venue updates).src/config/app-config.json+src/config/index.ts: runtime config.src/featureFlags.ts: CPEx toggles.
Conventions
- Styles use CSS Modules: put
Component.scssnext toComponent.tsxand start it with@import '~styles/utils/modules-entry.scss';. Prefer SCSS variables; use CSS custom properties only for colours that change in dark mode. .svgimports become React components (SVGR). Append?urlto get a URL string instead.- Fetch data through Redux: return
requestAction(key, type, axiosOptions)fromactions/requests, and have reducers listen forTYPE + SUCCESS(fromtypes/reducers). Read request status with theisSuccess/isFailureselectors. - Redux state is persisted (redux-persist) and synced across tabs (redux-state-sync).
- Keep the bundle lean: check the size of new dependencies and code-split page-specific ones.
Serverless functions (api/)
api/nus/**are thin route files; logic lives insrc/serverless/(handler.ts,nus-auth.tsSAML SSO,mpe.ts).api/optimiser/is Go; see its own AGENTS.md.api/tsconfig.jsoncompiles these as CommonJS withbaseUrl: ../src. Anything reachable fromapi/(includingsrc/config,src/types,src/serverless) must berequire()-able: uselodash, notlodash-es, and avoid other ESM-only packages there.- Vercel only bundles
src/serverless/*.xmlandsrc/data/*.jsonas extra files for functions (vercel.json). If a function needs another data file, add it toincludeFiles. - On Vercel,
/api/*paths that don't match a function are rewritten tohttps://api.nusmods.com.
Testing
- Vitest runs with globals enabled in jsdom. SCSS imports resolve to an identity proxy and SVGs to a mock component (
vitest.config.ts). - Use React Testing Library for new component tests. Many existing tests use Enzyme snapshots (
__snapshots__/). - Tests sit next to source as
*.test.ts(x); integration tests are*.integration.test.ts(x), run separately withpnpm test:integration. - Use
src/test-utils/for helpers (Redux store setup, fixtures). Module fixtures are insrc/__mocks__/modules/. - Run snapshot updates with
pnpm test -u <filter>, and only when the UI change is intentional.
Recurring data/config changes
- Semester and AY rollovers follow
MAINTENANCE.mdat the repo root. Typical files:app-config.json,src/data/modreg-schedule.json,src/data/holidays.json,views/components/notfications/Announcements.tsx(the directory name really is misspelled). - Opening or closing a CPEx round touches
src/featureFlags.ts,src/views/mpe/constants.ts(MPE_SEMESTER),src/config/index.tsandsrc/serverless/{mpe,nus-auth}.ts. See commitac18828afor an example. - After editing
src/data/venues.json, the optimiser copy is synced by the pre-commit hook or bypnpm prepare:optimiser.
Gotchas
nusmoderatorhere is the published npm 3.0.0, notpackages/nusmoderator(4.0.0 in the workspace). Changes to that package don't reach the website until it is published and the dependency is bumped.nusmods-academic-calendaris linked from the workspace.pnpm lint:styles --fixis experimental. If you run it, revert any changes it makes tothemes.scss.- The timetable supports 7 days (Sunday was added recently). Don't hard-code 5 or 6 weekdays.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- AGENTS.mdAGENTS.md
- export/AGENTS.mdAGENTS.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

