frontend-design — frontend low-level design
Design the frontend for a feature: read enough of the existing UI to ground the design in
real components and patterns, then write a buildable frontend LLD. Design artifact, not
code — never edit app code, don't implement, and don't design the backend. Prefer reuse over
reinvention; cite file:line for constraints. The cross-repo contract is not written
here — you describe the API/data your UI needs to consume; the two LLDs are reconciled
into the formal contract separately.
Inputs
Your instructions name what to read — the approved HLD — and the artifact path to write.
Standalone? read the HLD and write the LLD to a path you choose (and tell the user where).
Steps
- Ground in the code (read-only). Locate the app(s)/routes this feature touches and read
what matters — routing/pages, the component library/design system, state & data-fetching
layer (store, cache/invalidation, the API client/hooks), forms/validation approach, the
existing loading/empty/error/permission UI-state patterns, accessibility conventions,
i18n, and the component/E2E test setup. Capture only what constrains the design, with
file:line evidence. (No separate map is produced — this feeds the LLD.)
- Component & state design — the component hierarchy and responsibilities, where screens
attach in routing, the state model, data-fetching + cache keys/invalidation, and the form
schema/validation (parity with backend rules).
- UI-state matrix — for each view, define every state: loading, empty, success,
partial, error/retry, permission-denied, and offline/slow-network where relevant.
- API to CONSUME — the endpoints/events and response shapes the UI expects (your side of
the contract). This is reconciled with the backend's exposed API in the contract step.
- Accessibility strategy (keyboard, focus, roles/labels, contrast — WCAG AA),
performance (bundle/render, code-splitting on heavy routes), security (XSS/CSRF,
authz in the UI, no secrets in the client), i18n, and resilience (error boundaries,
optimistic UI + rollback).
- Test plan — component + E2E coverage, including the negative UI states.
- Document tech stack decisions — see section below.
- Write the frontend LLD; flag anything that forces a backend/contract change.
- Emit the task DAG — write a
tasks.json (see section below), reusing the code you
already read. No re-reading.
Tech stack decisions
Document the technology choices that shape the frontend design. Teams choose based on their
experience and project constraints; record them so the implementer knows exactly what to
build toward. If your team already has established patterns, reference them; if not, make the
choice now (not "later"). Record them in the LLD's "Tech Stack Decisions" section:
- State Management — Which library/framework? (e.g., Redux, Zustand, Context API, Jotai,
native GetX/Provider for mobile). Store structure: normalized or denormalized?
- Data-Fetching & Caching — Which library? (e.g., React Query, SWR, Apollo, Relay, native
fetch). Cache strategy? Pagination approach (offset/limit or cursor)? Retry/backoff logic?
- Styling & Design Tokens — Approach? (e.g., Tailwind CSS, CSS Modules, styled-components,
Emotion, vanilla CSS). Where are design tokens defined? Theme system (CSS variables or JS)?
Dark mode support?
- Testing Frameworks — Unit (Jest or Vitest)? Component (React Testing Library)? E2E
(Playwright, Cypress, WebdriverIO)? API mocking (MSW, Mirage, Prism)? Coverage targets?
- Form Validation — Library & schema validator? (e.g., react-hook-form + Zod, Formik +
Yup). Validation timing (real-time, on-blur, on-submit)? Async validation strategy?
- API Client & Type Generation — Generated from OpenAPI/GraphQL schema, or hand-written?
If generated: which tool and regeneration strategy? Single source of truth for types?
- Error Tracking & Logging — Service (Sentry, LogRocket, Bugsnag) or custom/none? What
gets logged? PII scrubbing rules? Error boundary placement strategy?
- Analytics & Event Tracking — Tool (Segment, Amplitude, Mixpanel, GA) or none? Events
to track? Event naming convention? User identification? PII handling in events?
- Build & Bundling — Bundler? (Next.js, Vite, Webpack, esbuild). Code-splitting
strategy? Environment configuration? Feature flags? Deployment target (Vercel, S3+CDN)?
- Performance Metrics & Budgets — Lighthouse targets? Core Web Vitals targets (LCP, INP,
CLS)? Bundle size limits? Virtualization thresholds? Memory budgets for mobile?
- Accessibility Testing — Automated (axe, jest-axe)? Manual (keyboard, screen reader)?
WCAG level (AA or AAA)? CI gates?
- i18n & Localization — Languages supported? Library (i18next, next-i18next, react-intl)?
Date/time library (date-fns, Day.js)? RTL support? Translation workflow?
- Authentication & Authorization — Method (JWT, sessions, OAuth)? Token storage? Refresh
strategy? Permission checking (UI-side, backend, or both)? Session expiry handling?
- Platform-Specific — Web only, or multi-platform (React + React Native, Flutter)? Code
sharing strategy? Native module integration? Platform-specific styling or components?
Why: the implementer builds toward these decisions. Without them recorded, they improvise
inconsistently. They don't require team consensus yet; they're recorded here for the
implement and review steps to follow.
What the frontend LLD must cover (write all)
Context & constraints (grounded in the code, cited) · tech stack decisions · component & state design · routing ·
data-fetching + caching · forms & validation · UI-state matrix · API consumed (the
frontend's side of the contract) · accessibility · performance · security · i18n ·
resilience · test plan.
Edge cases the design must define (not leave to the implementer)
- Views with no existing loading/empty/error state to copy; long lists / virtualization.
- Concurrent edits / stale data; optimistic update failure and rollback.
- Slow or failed API calls; partial data; pagination boundaries (first/last/empty page).
- Permission-gated UI; expired session mid-flow.
- Unicode / locale / timezone / RTL; large form validation; accessibility of dynamic content.
- Bundle-size-sensitive routes; areas with no tests; heavy/legacy components.
External skill (provision — research)
If a suitable deep-research skill is installed you may delegate to it to research unfamiliar
libraries or patterns — it must return sourced findings you can cite in the LLD. Otherwise
design from the code + HLD.
Emit tasks.json (the parallel task DAG)
Write a tasks.json (to the path your instructions specify) conforming to
engine/schemas/tasks.schema.json. Build it
from the LLD you just wrote, reusing files you already read (do not re-read the codebase).
Author it in one shot, then refine once. Compose the entire tasks.json — manifest, every
tasks[] entry, and slices[] — in a single Write. Do not stub the file and grow it with
successive Edits; assemble the whole structure in memory first and emit it once. After the
one Write, run the validator (below): if it prints OK you are done; if it fails, make one
corrective Edit (or a single rewriting Write) and re-validate. If that still fails, fix and
re-validate as needed — but never build the file up incrementally.
Fields:
context_manifest.read_once = the component/state/hook files the tasks edit against;
reference = this LLD path, the (pending) contract path, and AGENTS.md/CLAUDE.md.
- One
tasks[] entry per ≤1-commit slice (e.g. types/API-client, a component + its UI states,
form+validation, a route), each with id, group_id, title, depends_on
(intra-group only), reads, writes (exact files), test, standards,
needs_human_gate (true for auth/permission, prod config, or dependency changes).
- Grouping: two tasks share a
group_id iff one depends on the other OR they write a
common file; otherwise different groups. Fill slices[], task_ids in dependency order.
- Validate before returning:
python3 engine/validate_tasks.py <tasks.json path>
must print OK.
Output
Write your LLD to the given artifact path, with the sections above, each constraint citing
file:line. The API-consumed section feeds the contract step.
Definition of done
Every section present; tech stack decisions all recorded (no "TBD" or "decide later");
UI-state matrix complete (no state omitted); API-consumed concrete enough to formalize; edge
cases specified (not "TBD"). Do not implement — this is a design artifact only.
Output contract
Return lld_path, tasks_path, and contract_notes —
a short list of the decisions/constraints that shape the contract (e.g. "data-fetching goes
through hook X — reuse it"; "needs GET /searches returning {items, nextCursor}").
1---2name: frontend-design3description: Author the frontend low-level design (LLD) for a feature — read the relevant frontend code to ground the design, then design component/state architecture, routing, the full UI-state matrix, the API it needs to consume, accessibility, performance, i18n, and tests. Writes the LLD doc; never edits app code. Front door for /frontend-design.4---56# frontend-design — frontend low-level design78Design the **frontend** for a feature: read enough of the existing UI to ground the design in9real components and patterns, then write a **buildable frontend LLD**. Design artifact, not10code — never edit app code, don't implement, and don't design the backend. Prefer reuse over11reinvention; cite `file:line` for constraints. The **cross-repo contract** is not written12here — you describe the API/data your UI needs to **consume**; the two LLDs are reconciled13into the formal contract separately.1415## Inputs16Your instructions name what to read — the approved HLD — and the artifact path to write.17Standalone? read the HLD and write the LLD to a path you choose (and tell the user where).1819## Steps201. **Ground in the code (read-only).** Locate the app(s)/routes this feature touches and read21 what matters — routing/pages, the component library/design system, state & data-fetching22 layer (store, cache/invalidation, the API client/hooks), forms/validation approach, the23 existing loading/empty/error/permission UI-state patterns, accessibility conventions,24 i18n, and the component/E2E test setup. Capture only what constrains the design, with25 `file:line` evidence. (No separate map is produced — this feeds the LLD.)262. **Component & state design** — the component hierarchy and responsibilities, where screens27 attach in routing, the state model, data-fetching + cache keys/invalidation, and the form28 schema/validation (parity with backend rules).293. **UI-state matrix** — for each view, define **every** state: loading, empty, success,30 partial, error/retry, permission-denied, and offline/slow-network where relevant.314. **API to CONSUME** — the endpoints/events and response shapes the UI expects (your side of32 the contract). This is reconciled with the backend's exposed API in the contract step.335. **Accessibility strategy** (keyboard, focus, roles/labels, contrast — WCAG AA),34 **performance** (bundle/render, code-splitting on heavy routes), **security** (XSS/CSRF,35 authz in the UI, no secrets in the client), **i18n**, and **resilience** (error boundaries,36 optimistic UI + rollback).376. **Test plan** — component + E2E coverage, including the negative UI states.387. **Document tech stack decisions** — see section below.398. **Write** the frontend LLD; flag anything that forces a backend/contract change.409. **Emit the task DAG** — write a `tasks.json` (see section below), reusing the code you41 already read. No re-reading.4243## Tech stack decisions44Document the technology choices that shape the frontend design. Teams choose based on their45experience and project constraints; record them so the implementer knows exactly what to46build toward. If your team already has established patterns, reference them; if not, make the47choice now (not "later"). Record them in the LLD's **"Tech Stack Decisions"** section:48491. **State Management** — Which library/framework? (e.g., Redux, Zustand, Context API, Jotai,50 native GetX/Provider for mobile). Store structure: normalized or denormalized?512. **Data-Fetching & Caching** — Which library? (e.g., React Query, SWR, Apollo, Relay, native52 fetch). Cache strategy? Pagination approach (offset/limit or cursor)? Retry/backoff logic?533. **Styling & Design Tokens** — Approach? (e.g., Tailwind CSS, CSS Modules, styled-components,54 Emotion, vanilla CSS). Where are design tokens defined? Theme system (CSS variables or JS)?55 Dark mode support?564. **Testing Frameworks** — Unit (Jest or Vitest)? Component (React Testing Library)? E2E57 (Playwright, Cypress, WebdriverIO)? API mocking (MSW, Mirage, Prism)? Coverage targets?585. **Form Validation** — Library & schema validator? (e.g., react-hook-form + Zod, Formik +59 Yup). Validation timing (real-time, on-blur, on-submit)? Async validation strategy?606. **API Client & Type Generation** — Generated from OpenAPI/GraphQL schema, or hand-written?61 If generated: which tool and regeneration strategy? Single source of truth for types?627. **Error Tracking & Logging** — Service (Sentry, LogRocket, Bugsnag) or custom/none? What63 gets logged? PII scrubbing rules? Error boundary placement strategy?648. **Analytics & Event Tracking** — Tool (Segment, Amplitude, Mixpanel, GA) or none? Events65 to track? Event naming convention? User identification? PII handling in events?669. **Build & Bundling** — Bundler? (Next.js, Vite, Webpack, esbuild). Code-splitting67 strategy? Environment configuration? Feature flags? Deployment target (Vercel, S3+CDN)?6810. **Performance Metrics & Budgets** — Lighthouse targets? Core Web Vitals targets (LCP, INP,69 CLS)? Bundle size limits? Virtualization thresholds? Memory budgets for mobile?7011. **Accessibility Testing** — Automated (axe, jest-axe)? Manual (keyboard, screen reader)?71 WCAG level (AA or AAA)? CI gates?7212. **i18n & Localization** — Languages supported? Library (i18next, next-i18next, react-intl)?73 Date/time library (date-fns, Day.js)? RTL support? Translation workflow?7413. **Authentication & Authorization** — Method (JWT, sessions, OAuth)? Token storage? Refresh75 strategy? Permission checking (UI-side, backend, or both)? Session expiry handling?7614. **Platform-Specific** — Web only, or multi-platform (React + React Native, Flutter)? Code77 sharing strategy? Native module integration? Platform-specific styling or components?7879**Why:** the implementer builds toward these decisions. Without them recorded, they improvise80inconsistently. They don't require team consensus yet; they're recorded here for the81implement and review steps to follow.8283## What the frontend LLD must cover (write all)84Context & constraints (grounded in the code, cited) · **tech stack decisions** · component & state design · routing ·85data-fetching + caching · forms & validation · **UI-state matrix** · API consumed (the86frontend's side of the contract) · accessibility · performance · security · i18n ·87resilience · test plan.8889## Edge cases the design must define (not leave to the implementer)90- Views with no existing loading/empty/error state to copy; long lists / virtualization.91- Concurrent edits / stale data; optimistic update failure and rollback.92- Slow or failed API calls; partial data; pagination boundaries (first/last/empty page).93- Permission-gated UI; expired session mid-flow.94- Unicode / locale / timezone / RTL; large form validation; accessibility of dynamic content.95- Bundle-size-sensitive routes; areas with no tests; heavy/legacy components.9697## External skill (provision — research)98If a suitable deep-research skill is installed you may delegate to it to research unfamiliar99libraries or patterns — it must return sourced findings you can cite in the LLD. Otherwise100design from the code + HLD.101102## Emit tasks.json (the parallel task DAG)103Write a `tasks.json` (to the path your instructions specify) conforming to104`engine/schemas/tasks.schema.json`. Build it105from the LLD you just wrote, reusing files you already read (do not re-read the codebase).106107**Author it in one shot, then refine once.** Compose the entire tasks.json — manifest, every108`tasks[]` entry, and `slices[]` — in a single `Write`. Do **not** stub the file and grow it with109successive `Edit`s; assemble the whole structure in memory first and emit it once. After the110one `Write`, run the validator (below): if it prints `OK` you are done; if it fails, make **one**111corrective `Edit` (or a single rewriting `Write`) and re-validate. If that still fails, fix and112re-validate as needed — but never build the file up incrementally.113114Fields:115- `context_manifest.read_once` = the component/state/hook files the tasks edit against;116 `reference` = this LLD path, the (pending) contract path, and `AGENTS.md`/`CLAUDE.md`.117- One `tasks[]` entry per ≤1-commit slice (e.g. types/API-client, a component + its UI states,118 form+validation, a route), each with `id`, `group_id`, `title`, `depends_on`119 (**intra-group only**), `reads`, `writes` (exact files), `test`, `standards`,120 `needs_human_gate` (true for auth/permission, prod config, or dependency changes).121- **Grouping:** two tasks share a `group_id` **iff** one depends on the other OR they write a122 common file; otherwise different groups. Fill `slices[]`, `task_ids` in dependency order.123- **Validate before returning:** `python3 engine/validate_tasks.py <tasks.json path>`124 must print `OK`.125126## Output127Write your LLD to the given artifact path, with the sections above, each constraint citing128`file:line`. The API-consumed section feeds the contract step.129130## Definition of done131Every section present; **tech stack decisions all recorded** (no "TBD" or "decide later");132UI-state matrix complete (no state omitted); API-consumed concrete enough to formalize; edge133cases specified (not "TBD"). Do not implement — this is a design artifact only.134135## Output contract136Return `lld_path`, `tasks_path`, and `contract_notes` —137a short list of the **decisions/constraints that shape the contract** (e.g. "data-fetching goes138through hook X — reuse it"; "needs `GET /searches` returning `{items, nextCursor}`").