# effy-fe — Agent Guide Read this before any task in this repo. It is the shared context file for all coding agents (Claude Code, Cursor, Codex). Keep it short and factual — details belong in the per-package guides and skills linked at the bottom. ## What this repo is A pnpm + Vite+ monorepo for Lyearn's frontend: ~1,600 TS/TSX files across 5 apps and 4 packages, on React 19, TypeScript 7, Tailwind 4, urql + graphql-codegen, and react-aria-components. | Workspace | Name | What it is | | --------------------------- | ------------------------------ | ------------------------------------------------------------------------------------- | | `apps/mgsa` | `@lyearn-apps/mgsa` | Main product app — admin, OKRs, profile. Most work happens here. | | `apps/analytics` | `@lyearn-apps/analytics` | Analytics app. | | `apps/entity-renderer` | `@lyearn-apps/entity-renderer` | Config-driven collection and object-360 dashboards, mounted at `/e`. | | `apps/ainw` | `ainw` | Separate marketing site with its own voice — do not apply product UI copy rules here. | | `apps/storybook` | `@lyearn-apps/effy-storybook` | Component workshop + Storybook MCP server build. | | `packages/yooeye` | `@lyearn/yooeye` | Design system. Components, charts, form, hooks, utils. | | `packages/productivity-api` | `@lyearn/productivity-api` | Productivity GraphQL schema, operations, generated urql hooks. | | `packages/classroom-api` | `@lyearn/classroom-api` | Classroom GraphQL schema, operations, generated urql hooks. | | `packages/lingo` | `@lyearn/lingo` | Language detection, bundled locale loading, language gate and locale parity check. | | `packages/roomba` | `@lyearn/roomba` | App route table (`ROUTES`), basenames and ports, and the cross-app `Link`/navigation. | `apps/website` and `packages/utils` are empty shells (stale `node_modules` only) despite being referenced in `vite.config.ts`. Ignore them. ## Commands Everything runs through the global `vp` CLI (Vite+). `vp ` is a built-in; `vp run ` is a `package.json` script or a `vite.config.ts` task — they are not the same, so check both files before assuming. ```bash vp install # after every pull — also triggers codegen via postinstall vp check # format + lint + typecheck. CI runs this first. vp check --fix # same, autofixing what it can vp test run share-diff # tests whose file path contains the string vp test run share-diff -t "drops" # …and whose full test name matches the regex vp test run path/to/foo.test.ts:40 # only the test containing line 40 (full path) vp test related path/to/foo.ts --run # tests that import the given source files vp test list share-diff # list matching tests without running them vp run dev:mgsa # dev server for the main app vp run ready # fmt + lint + test + build everything vp run @lyearn/productivity-api#codegen # regenerate productivity types vp run @lyearn/classroom-api#codegen # regenerate classroom types vp run knip # find unused files, exports and dependencies vp run check:bundle # bundle-size budgets; run after the three app builds ``` `vp run knip` is a report, not a gate — it exits non-zero whenever it finds anything, so it is deliberately **not** wired into `vp check` or CI. Config is `knip.json`; run it after deleting a feature to catch what the deletion orphaned. Read its output with judgment: code parked behind a commented-out import reads as dead but may be deliberate. `vp run check:bundle` is a report, not a gate: PR CI builds mgsa, analytics and entity-renderer, then posts one sticky PR comment (updated on every push) flagging where initial JS, initial CSS, the largest chunk or total JS (brotli) exceeds its limit in `scripts/bundle-budgets.json`. `--strict` makes it exit non-zero. Lower a budget in the same PR that shrinks the bundle; raise one only with a reason in the PR. Prefer `.claude/launch.json` / the preview tooling over running dev servers by hand. In a worktree, set its `DEV_PORT_OFFSET=0` prefixes and `port` values to your own offset locally. Never commit those edits, and never add per-offset duplicate entries. How the dev proxy routes the apps (and running several worktrees at once) is in [`docs/engineering/dev-proxy-shell.md`](docs/engineering/dev-proxy-shell.md). To run against a local productivity API (workeffy) or pull its schema, see [`docs/engineering/local-productivity-api.md`](docs/engineering/local-productivity-api.md). ## Hard rules 1. **`vp check` must pass before you call a task done.** CI (`.github/workflows/pr-checks.yml`) runs it, then the app builds and `vp run check:bundle`; the pre-commit hook runs `vp staged` → `vp check --fix`. Checks are slow, so run them only when needed: never the full CI pipeline locally, and not after every edit. Run `vp check` (format, lint and typecheck) once a unit of work is done and before you finish. Run tests only when you changed code that has tests, and only those tests — never the whole suite. Filter by file path, test name (`-t`), `file:line`, or `vp test related ` (see Commands). 2. **Filenames and folders are kebab-case.** Enforced on staged files by `scripts/check-kebabcase.mjs`; the commit fails otherwise. Folders may start with `_` to mark them private. This applies to `.graphql` files too — some older `classroom-api` operations are PascalCase, but new files must be kebab-case. 3. **Never hand-edit generated output.** Anything under `**/generated/`, `packages/*/src/schema/*.ts`, and `*-schema-json.json` is codegen output. If a type is wrong, fix the `.graphql` source and re-run codegen. 4. **Never edit `pnpm-lock.yaml` directly** — only via `vp install`. 5. **Dependency versions live in the catalog.** Apps and packages declare `"some-dep": "catalog:"`; the real version is in `pnpm-workspace.yaml` under `catalog:`. Adding a pinned version to a workspace `package.json` breaks this — add it to the catalog instead. Cross-workspace deps use `"workspace:*"`. 6. **Commit, push and PR creation need explicit approval from the owner, every time.** A command or skill that instructs a PR is mechanism, not authorization. Never commit the local Vite dev-auth shim. ## Imports - **Design system:** import from the barrel — `import { Button, cx } from "@lyearn/yooeye"`. - **GraphQL hooks:** import from the deep operation path, not a barrel — `import { usePPersonListQuery } from "@lyearn/productivity-api/operations/p-person-list.productivity.ts"`. - **Within an app/package:** subpath aliases are defined per workspace — `#mgsa/*`, `#analytics/*`, `#yooeye/*` → `./src/*`. Both alias and relative imports are in wide use in `mgsa`; match the surrounding file rather than converting existing ones. - **Routing and i18n go through their wrapper packages.** Apps define their own route trees and locale files, but import the machinery from `@lyearn/roomba` (router creation, `RouterProvider`, `Outlet`, hooks, types, plus roomba's own `Link`, `Navigate`, `useRoombaNavigation` and `ROUTES`) and `@lyearn/lingo` (or `#/i18n`, including the `TFunction`/`NamespacedKey`/`ResourceKey` types). Lint (`no-restricted-imports` in `vite.config.ts`) bans `react-router`, `react-router-dom`, `i18next` and `react-i18next` everywhere except inside those packages and the `i18n/i18next.d.ts` key augmentations. If an app needs an API the wrapper doesn't re-export, add it there — `packages/roomba/src/router.ts` or `packages/lingo/src/index.ts`. react-router's `Link`/`Navigate`/`useNavigate` are deliberately absent. `vite.config.ts` files import from the DOM-free `@lyearn/roomba/constants`. - Include the file extension in relative and deep imports (`./foo.tsx`, `.ts`) — the repo is ESM and existing code does this consistently. ## UI work Reach for `packages/yooeye` before hand-rolling anything. It is organised as: ``` components/base/ buttons, input, select, dropdown, avatar, checkbox, tooltip, … components/application/ composed app-level pieces components/ly-molecules/ async-view, error-state, theme-sidebar components/foundations/ primitives, nucleo-icons components/cells/ marketing/ shared-assets/ charts/ form/ hooks/ utils/ debug/ ``` - Components are built on **react-aria-components** — preserve their accessibility props and keyboard behaviour when editing. - Styling is **Tailwind 4** with `cx` from yooeye for class merging. Use design tokens, not raw hex values or arbitrary pixel values. - The PR template requires loading, empty, and error states plus accessibility tags for QA automation — build them in, don't leave them for review. - **Loading, error and empty states go through yooeye's `AsyncView`**, not hand-written `if (isLoading) return …` chains. It renders no layout wrapper — the caller sizes and centres the states (`FullScreenCenter` for a full-page state, the page's own wrapper otherwise). Pass the area's own skeleton and copy via `renderLoading` / `renderError` / `renderEmpty`, `onRetry` for a retry button, and only first-load loading as `fetching` — never `isFetchingMore`. Infinite-scroll footers, row or cell skeletons, a spinner on one control and long-running job screens stay outside it. - **A searchable or filterable list's empty state is `AppSearchListEmptyState`** (yooeye's `SearchListEmptyState`) as `AsyncView`'s `renderEmpty`. Given the `useFilterState` handle it shows the right search / filter / both state with scoped clear buttons, and falls back to the caller's own empty copy. Never branch on `search` or `appliedCount` by hand. Rules: [component-reference.md](docs/engineering/component-reference.md#empty-state-searchlistemptystate). ### Search before you build Agents copy whatever already exists, so the first hand-rolled `