Standard engineering practices for this project. Any more specific instruction file overrides these rules.
- Vite
- React with Wouter
- TypeScript
- Vitest with React Testing Library
- pnpm
docs/architecture/architecture.md is an overview
of the codebase layers, build pipeline, runtime data flow, engine state shape, and
test structure. Read it first when orienting to a new area of the codebase.
docs/architecture/guides/adding-commands.md is
the step-by-step guide for implementing a new engine command: registry, handler
signature, action shapes, state helpers, dispatch routing, visual-mode support, and
the test harness.
Three scripts manage the lesson/module scaffolding and the curriculum doc. Run them
from the project root (projects/vim-course/).
pnpm add-module -- --number=<N> --slug=<slug> --title="<title>"— create a new module directory with stub intro and review lessons, and register it inordering.ts. Automatically syncs the curriculum doc.pnpm add-lesson -- --module=<N> --title="<title>" [--type=<learn|practice>]— add a new lesson to an existing module (inserted before the review lesson) and register it inordering.ts. Automatically syncs the curriculum doc.pnpm sync-curriculum-doc— regeneratedocs/curriculum/curriculum-outline.mdfromordering.tsand the lesson files. Use--checkto verify without writing (runs in CI).pnpm check-review-commands— verify that each module's review lesson lists every command from its lessons'introducesfrontmatter, and that the capstone cheatsheet matches the reviews. Use--checkto exit 1 on drift (CI).pnpm sync-command-reference— rebuild the capstone command reference (08-capstone/lesson-01.md) from the module review lessons.
add-module and add-lesson call sync-curriculum-doc automatically, so you do
not need to run it separately after using them.
- The app is a single-page React application.
index.htmlis the entry point;src/main.tsxmounts the React tree. React Router handles client-side routing (src/App.tsx). - Lesson data is pre-built by
scripts/build-lesson-data.tsinto static JSON files underpublic/data/. The client fetches them at runtime viauseLessonData. src/stores/courseChrome.tsis a module-level store (withuseSyncExternalStore) for app-global chrome state (drawer, modals). It could become React Context but works as-is.
- Use named exports for components, hooks, and utilities. Do not use default exports.
- Name a file after the thing it exports:
Button.tsx, notindex.tsx.index.{ts,tsx}is reserved for barrel files that only re-export from siblings; any file with real logic must not be namedindex. - Colocate related files under the component name:
Button.module.css,Button.test.tsx. Neverindex.module.cssorindex.test.tsx. - Delete dead code your change leaves behind: no unused imports, unreferenced exports, or commented-out blocks.
- Add a comment only when the code is not self-explanatory. Clear naming and structure come first.
- Do not use emojis or ASCII symbols in UI. Use the icon components in
src/components/base/Icon/. Import from@/components/base/Icon. Do not use raw SVG files or inline SVG in component files. If you need an icon not in this set, add it toIcon.tsxfollowing the existing pattern (acceptsclassName?, setsaria-hiddenandfocusable="false"), then ask the user to confirm.
- Use CSS modules (
.module.css) for all component and page styles. - Never use inline styles or
!important. - Keep colors accessible with sufficient contrast.
- Use logical properties, not physical ones, so styles work in RTL locales:
padding-inline,margin-block,border-inline-start,inset-inline-start,text-align: start | end,float: inline-start. Physical values stay correct only fortransform,box-shadowoffsets, and viewport-tied geometry. - Use mobile-first
min-widthmedia queries. The only allowed breakpoints are600px,768px,1024px,1440px, and2560px. The 320px baseline needs no query. Do not introduce other breakpoint values. - Use px for breakpoints, media queries, and border radius values. Use rem for all other sizing, including font-size, spacing, and layout dimensions.
- All font sizes, spacing, radii, and transition timings must use a CSS custom property
from
src/styles/global.css. No hardcoded literals in component CSS files. - Terminal grid spacing is measured in monospace character cells: use
chfor terminal gutters, side insets, and other horizontal spacing that aligns with buffer columns.
Any UI element that is only meaningful to keyboard users — shortcut trigger buttons, shortcut settings toggles, kbd hint chips, shortcut hint text — must be hidden on touch devices and shown only on pointer devices that support hover. Use the same condition everywhere:
.keyboard-only {
display: none;
}
@media (width >= 768px) and (hover: hover) {
.keyboard-only {
display: <appropriate display value>;
}
}The hover: hover condition excludes touchscreens (phones and tablets) regardless
of screen size. The width >= 768px floor prevents showing keyboard hints in very
narrow pointer-device windows. Never use a width-only breakpoint for this pattern.
- Implementation changes must include tests, except CSS changes.
- Vitest with React Testing Library.
- A test file mirrors the unit under test:
Button.test.tsxforButton.tsx. Neverindex.test.tsx. - Test user-observable behavior and accessibility, not implementation details. Prefer
getByRole/findByRolewith accessible names, anduserEventfor interaction flows. - For modal and drawer tests: wrap disappearance assertions in
waitFor(waitFor(() => expect(screen.queryByRole(...)).toBeNull())). Never check disappearance with a bare synchronousqueryByafter an async action.
- Use semantic HTML first, then add ARIA only where semantics are not enough.
- Every meaningful image needs alt text; decorative images use an empty alt attribute.
- Custom interactive regions must be focusable, keyboard-operable, and expose an accessible name.
- Use American English spelling and grammar.
- Run the narrowest relevant test file first. Before finishing larger changes, run
pnpm testandpnpm buildwhen the touched area justifies it. - Run
pnpm lint:styleswhenever a.cssfile is created or modified.
docs/curriculum/commands.md is the inventory of
every key and ex command the simulated terminal accepts, its messages, and its
silent no-ops. Consult it before authoring a lesson, and update it in the same
change that adds or removes a command.
docs/curriculum/lesson-authoring.md is
the reference for all lesson-authoring rules: config options, start modes,
checklist test fields, command-filter options, and seed conventions.