Frontend Performance Review
Reference: frontend/docs/performance.md
When to Invoke
- Before submitting a PR that adds or modifies query hooks, page components, Zustand stores, or real-time features
- When the user asks for a "performance review" or "perf check"
- As part of the component-development workflow for new pages
Agent Instructions
When invoked, perform the following checks in order. Report PASS/FAIL/WARN for each. Group failures by severity: CRITICAL (must fix before merge), WARNING (should fix), INFO (consider).
Step 1: Identify Scope
Read the diff or the files specified by the user. If no files specified, use git diff --name-only to find changed frontend files. Identify which categories apply: query hooks, page routes, stores, real-time, bundle.
Step 2: Query Hook Checks
- Search for
useState + useEffect + api. within 20 lines of each other in changed files. If found: CRITICAL — should be a TanStack Query hook.
- Check that new
useQuery calls reference a key from queryKeys.ts, not an inline array. If inline: CRITICAL.
- Check that new query hook files are named
use<Domain>Queries.ts and placed in src/hooks/queries/. If misplaced: WARNING.
- Check that
useMutation calls include onSuccess with queryClient.invalidateQueries(). If missing: WARNING.
- Check for
skipToken usage on conditional queries vs. enabled: false. Flag enabled: false without skipToken as WARNING.
Step 3: Stale Time Audit
- For each new
useQuery, check if staleTime is set explicitly or inherits the 30s default appropriately.
- Cross-reference the data type: if the query fetches components, templates, or providers — flag missing
staleTime: Infinity as CRITICAL.
- For execution queries, verify they use
executionQueryOptions.ts factories rather than inline values. Flag inconsistency as WARNING.
- For queries on terminal runs, verify
terminalStaleTime() is used rather than a hardcoded number.
Step 4: Bundle Impact
- For each new page added to
App.tsx: verify it uses React.lazy(() => import(...)). Static imports are CRITICAL.
- Verify new sidebar pages are added to
routePrefetchMap in src/lib/prefetch-routes.ts. Missing entry is WARNING.
- If a new conditionally-visible component imports a library > 100KB (check for
@xterm, posthog-js, lucide-react barrel imports): flag as WARNING — consider deferred load pattern.
Step 5: Rendering Checks
- Search for
const [*, set*] = useState followed by set* inside a useEffect that references query data — CRITICAL (should use useMemo).
- Look for derived data calculations inline in JSX without
useMemo involving array operations (filter, sort, reduce) — WARNING.
- Check for
React.memo usage on new components in timeline/ or workflow/ directories that re-render frequently — INFO if missing.
Step 6: Zustand Store Checks
- Search for
const store = use<X>Store() or destructuring from use<X>Store() without a selector — full store subscription. WARNING.
- For new stores using
persist, verify partialize is present. Missing is WARNING.
- For new
persist stores, verify action functions are excluded from partialize.
Step 7: Generate Report
Format the output as follows:
## Performance Review: [description of scope]
### Critical (must fix before merge)
- [file:line] Description of issue. See: performance.md § [section]
### Warnings (should fix)
- [file:line] Description of issue. See: performance.md § [section]
### Info (consider)
- [file:line] Description. See: performance.md § [section]
### Passed Checks
- [n] query hooks using TanStack Query correctly
- [n] page routes using React.lazy
- [n] Zustand selectors properly scoped
- staleTime: appropriate tiers applied
### Summary
[1-2 sentences on overall performance hygiene of the change]
Rules
- This is a review only — do NOT make code changes unless the user explicitly asks
- Always cite the file and line number for each finding
- Always reference
frontend/docs/performance.md for the relevant pattern section
- If no frontend files are in the diff, report "No frontend changes detected" and exit
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: performance-review3description: Review frontend code changes for performance anti-patterns and guideline compliance. Checks query hooks, stale times, bundle impact, rendering patterns, and Zustand selectors. Use when this capability is needed.4---56# Frontend Performance Review78**Reference:** `frontend/docs/performance.md`910---1112## When to Invoke1314- Before submitting a PR that adds or modifies query hooks, page components, Zustand stores, or real-time features15- When the user asks for a "performance review" or "perf check"16- As part of the component-development workflow for new pages1718## Agent Instructions1920When invoked, perform the following checks in order. Report PASS/FAIL/WARN for each. Group failures by severity: **CRITICAL** (must fix before merge), **WARNING** (should fix), **INFO** (consider).2122### Step 1: Identify Scope2324Read the diff or the files specified by the user. If no files specified, use `git diff --name-only` to find changed frontend files. Identify which categories apply: query hooks, page routes, stores, real-time, bundle.2526### Step 2: Query Hook Checks27281. Search for `useState` + `useEffect` + `api.` within 20 lines of each other in changed files. If found: **CRITICAL** — should be a TanStack Query hook.292. Check that new `useQuery` calls reference a key from `queryKeys.ts`, not an inline array. If inline: **CRITICAL**.303. Check that new query hook files are named `use<Domain>Queries.ts` and placed in `src/hooks/queries/`. If misplaced: **WARNING**.314. Check that `useMutation` calls include `onSuccess` with `queryClient.invalidateQueries()`. If missing: **WARNING**.325. Check for `skipToken` usage on conditional queries vs. `enabled: false`. Flag `enabled: false` without `skipToken` as **WARNING**.3334### Step 3: Stale Time Audit35361. For each new `useQuery`, check if `staleTime` is set explicitly or inherits the 30s default appropriately.372. Cross-reference the data type: if the query fetches components, templates, or providers — flag missing `staleTime: Infinity` as **CRITICAL**.383. For execution queries, verify they use `executionQueryOptions.ts` factories rather than inline values. Flag inconsistency as **WARNING**.394. For queries on terminal runs, verify `terminalStaleTime()` is used rather than a hardcoded number.4041### Step 4: Bundle Impact42431. For each new page added to `App.tsx`: verify it uses `React.lazy(() => import(...))`. Static imports are **CRITICAL**.442. Verify new sidebar pages are added to `routePrefetchMap` in `src/lib/prefetch-routes.ts`. Missing entry is **WARNING**.453. If a new conditionally-visible component imports a library > 100KB (check for `@xterm`, `posthog-js`, `lucide-react` barrel imports): flag as **WARNING** — consider deferred load pattern.4647### Step 5: Rendering Checks48491. Search for `const [*, set*] = useState` followed by `set*` inside a `useEffect` that references query data — **CRITICAL** (should use `useMemo`).502. Look for derived data calculations inline in JSX without `useMemo` involving array operations (filter, sort, reduce) — **WARNING**.513. Check for `React.memo` usage on new components in `timeline/` or `workflow/` directories that re-render frequently — **INFO** if missing.5253### Step 6: Zustand Store Checks54551. Search for `const store = use<X>Store()` or destructuring from `use<X>Store()` without a selector — full store subscription. **WARNING**.562. For new stores using `persist`, verify `partialize` is present. Missing is **WARNING**.573. For new `persist` stores, verify action functions are excluded from `partialize`.5859### Step 7: Generate Report6061Format the output as follows:6263```64## Performance Review: [description of scope]6566### Critical (must fix before merge)67- [file:line] Description of issue. See: performance.md § [section]6869### Warnings (should fix)70- [file:line] Description of issue. See: performance.md § [section]7172### Info (consider)73- [file:line] Description. See: performance.md § [section]7475### Passed Checks76- [n] query hooks using TanStack Query correctly77- [n] page routes using React.lazy78- [n] Zustand selectors properly scoped79- staleTime: appropriate tiers applied8081### Summary82[1-2 sentences on overall performance hygiene of the change]83```8485## Rules8687- This is a **review only** — do NOT make code changes unless the user explicitly asks88- Always cite the file and line number for each finding89- Always reference `frontend/docs/performance.md` for the relevant pattern section90- If no frontend files are in the diff, report "No frontend changes detected" and exit9192---93> Converted and distributed by [TomeVault](https://tomevault.io/claim/shipsecai) — claim your Tome and manage your conversions.94<!-- tomevault:4.0:skill_md:2026-04-11 -->