Imported from 86unj/Foundit (
foundit-ui/AGENTS.md). Install upstream withnpx skills add 86unj/Foundit --skill foundit-ui. Copyright stays with the author.
foundit-ui — Agent Instructions
Next.js (App Router) + TypeScript + Chakra UI v3 frontend for the Foundit
lost-and-found app. Package manager is pnpm; run all commands from
foundit-ui/.
Commands
pnpm typecheck # tsc --noEmit
pnpm lint # eslint .
pnpm test # vitest run
pnpm build # next build
CI runs all four — run them before pushing. lint-staged auto-formats (prettier + eslint) on every commit, so don't hand-format.
Design system — the rules that get broken most
- Never hardcode hex colors. Use the semantic tokens defined in
components/ui/provider.tsx:fg,fg.muted,fg.error,border.input,border.error,focusRing. In style objects reference tokens as{colors.focusRing}. - Form fields must compose
components/ui/field-styles.ts(fieldControlStyles,fieldLabelStyles,fieldHelperStyles,inlineFieldLabelStyles). SeeTextAreaInput.tsxfor the canonical pattern (element variables +stackedprop for label-above layout). - This is Chakra UI v3 — no v2 patterns (
extendTheme,ColorModeScript,colorSchemeprop,@chakra-ui/icons). - Theme is light-only and forced light in the provider; don't add dark-mode styling yet.
API and types
- All HTTP goes through
apiFetchfromlib/api/client.ts— never rawfetchto the backend. Pass{ auth: false }for public endpoints; authenticated requests and token refresh are handled inside the client. - Endpoint wrappers live in
lib/api/*.ts, grouped by resource. - Shared response/entity types live in
types/*.ts. Import them — never redeclare a type locally in an api or component file.
Structure
- Routes are role-based:
app/student/*andapp/security/*(guarded bymiddleware.tsvia thefoundit_rolecookie); public flows live at the top level (app/login,app/report-found/[token], …). Build paths with the helpers inutils/routes.ts, not string literals. - Shared UI in
components/(PascalCase filenames, e.g.ImageUploadGallery.tsx); form state inhooks/use*Form.ts; option lists inconstants/(CATEGORIES, campuses come from the API). - Tests in
tests/, mirroring the source tree (tests/hooks/useLoginForm.test.ts↔hooks/useLoginForm.ts), using vitest + @testing-library/react.
Workflow
- Branches:
YourName/feature-name. Commits: conventional style, e.g.feat(ui): …,fix: …, scoped to what changed. - Keep PRs scoped to
foundit-ui/unless the change genuinely needs backend edits.