agentleFS
nusmodificationsnusmodifications/nusmods/website/AGENTS.md

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
  1. Distinctive:

    Keep the bundle lean: check the size of new dependencies and code-split page-specific ones.

    line 40
  2. Very specific:

    Use React Testing Library for new component tests.

    line 52
  3. Very specific:

    Use src/test-utils/ for helpers (Redux store setup, fixtures).

    line 55
  4. Very specific:

    Run snapshot updates with pnpm test -u <filter>, and only when the UI change is intentional.

    line 56
  5. Very specific:

    After editing src/data/venues.json, the optimiser copy is synced by the pre-commit hook or by pnpm prepare:optimiser.

    line 62

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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/, not src/js/ as README.md's tree says. Imports resolve from src/ 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 the export/ service (pnpm start:export, webpack.config.timetable-only.js).
  • src/views/<feature>/: page components (timetable, modules, planner, optimiser, venues, today, mpe, …). Shared UI in src/views/components, hooks in src/views/hooks.
  • src/actions, src/reducers, src/selectors: Redux. Persistence config is in src/storage/persistReducer.ts; persisted reducers declare their own migrate/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.ts declares build-time globals (NUSMODS_ENV, DATA_API_BASE_URL, OPTIMISER_API_URL, …) injected by Webpack's DefinePlugin and Vitest define.
  • 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.scss next to Component.tsx and start it with @import '~styles/utils/modules-entry.scss';. Prefer SCSS variables; use CSS custom properties only for colours that change in dark mode.
  • .svg imports become React components (SVGR). Append ?url to get a URL string instead.
  • Fetch data through Redux: return requestAction(key, type, axiosOptions) from actions/requests, and have reducers listen for TYPE + SUCCESS (from types/reducers). Read request status with the isSuccess/isFailure selectors.
  • 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 in src/serverless/ (handler.ts, nus-auth.ts SAML SSO, mpe.ts). api/optimiser/ is Go; see its own AGENTS.md.
  • api/tsconfig.json compiles these as CommonJS with baseUrl: ../src. Anything reachable from api/ (including src/config, src/types, src/serverless) must be require()-able: use lodash, not lodash-es, and avoid other ESM-only packages there.
  • Vercel only bundles src/serverless/*.xml and src/data/*.json as extra files for functions (vercel.json). If a function needs another data file, add it to includeFiles.
  • On Vercel, /api/* paths that don't match a function are rewritten to https://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 with pnpm test:integration.
  • Use src/test-utils/ for helpers (Redux store setup, fixtures). Module fixtures are in src/__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.md at 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.ts and src/serverless/{mpe,nus-auth}.ts. See commit ac18828a for an example.
  • After editing src/data/venues.json, the optimiser copy is synced by the pre-commit hook or by pnpm prepare:optimiser.

Gotchas

  • nusmoderator here is the published npm 3.0.0, not packages/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-calendar is linked from the workspace.
  • pnpm lint:styles --fix is experimental. If you run it, revert any changes it makes to themes.scss.
  • The timetable supports 7 days (Sunday was added recently). Don't hard-code 5 or 6 weekdays.

Download now (ZIP)

  • 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.

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.