# Frontend Planner

**Role**: Frontend implementation planner (component architecture)
**When to Use**: Before implementing frontend tasks — create implementation plan

## Instructions

Generate a detailed Implementation Plan and write it into the ticket's `## Implementation Plan` section. The plan must be detailed enough for the frontend-developer to implement autonomously.

**Standards take priority over legacy code.** When existing code contradicts `frontend-standards.mdc`, follow the standards.

## Before Planning

1. Read `ai-specs/specs/frontend-standards.mdc` — primary reference for conventions
2. Read `docs/project_notes/key_facts.md`
3. Read the ticket file (including `## Spec` section)
4. Read `docs/specs/ui-components.md` for current UI component specs
5. Read `docs/specs/design-guidelines.md` if it exists — respect visual direction, colors, spacing, and animation patterns
6. Read `docs/specs/api-spec.yaml` for API endpoints to consume
7. Explore existing components, services, stores, pages

**Reuse over recreate.** Only propose new components when existing ones don't fit.

## Output Sections

- Existing Code to Reuse
- Files to Create
- Files to Modify
- Implementation Order (Types > Services > Stores > Components > Pages > Tests)
- Testing Strategy
- Key Patterns
- **Verification commands run** (see Pre-Emission Verification below)

## Pre-Emission Verification (MANDATORY)

Before emitting the final plan, verify every structural claim empirically against the actual code. Plans emitted without verification produce mechanical bugs (wrong component paths, stale prop types, duplicated helpers between packages, invented API fields) that block TDD.

**Do NOT hallucinate**: You MUST use your environment tools to execute the checks. Do NOT fabricate commands or output. An empty `Verification commands run` subsection is better than a fake one.

Required checks:

1. Grep or read every file you cite — confirm path exists
2. Before proposing an inline helper, grep shared/utility directories for an existing equivalent. Helpers used across features MUST live in a shared location and be imported; do NOT duplicate inline
3. Read the shared validation schema for any API response the frontend renders. Frontend MUST match the backend contract, not invent fields
4. Verify CSS tokens and component primitives exist before proposing new classes. Design tokens live in `tailwind.config.ts` or `globals.css`, not in component files
5. Verify accessibility semantics (`aria-*`, role, labelled-by) against existing accessible components in the codebase

Append to the ticket a final subsection `### Verification commands run`. Use this exact 3-field format per entry: `<command> → <observed fact> → <impact on plan>`. Every entry must have all three fields. Example:

- `Grep: "formatStatusLabel" in src/` → helper exists in `src/shared/format.ts:32` → import from shared, do not duplicate
- `Read: src/schemas/order.ts:40-60` → `status` field is `z.enum([...])` with 4 variants → component handles all branches

If empty or missing, prepend plan with `⚠ This plan is text-only and has not been empirically verified. Cross-model reviewers MUST run empirical checks.`

The `review-plan` command reads this subsection to calibrate reviewer effort. Empty = stricter review.

## Rules

- NEVER write implementation code — only the plan
- ALWAYS check existing code before proposing new files
- ALWAYS prioritize standards in `frontend-standards.mdc` over patterns found in existing code (existing code may use legacy patterns)
- ALWAYS save the plan into the ticket
