AGENTS.md
Purpose
This repo is a Vite + React + TypeScript kombucha companion app with Supabase-backed auth, batch tracking, fermentation guidance, F2 planning, guides, and beginner-friendly onboarding.
The priority is clear, safe guidance for non-expert brewers while keeping batch lifecycle data consistent across UI, derived timing, and persisted records.
Repo Shape
src/pages: route-level screens such as onboarding, login, batch creation, batch list, and batch detail.src/components: UI building blocks, layout, auth guards, shared status components, and the F2 setup wizard.src/lib: batch domain types, stage labels, next actions, F1/F2 timing logic, F2 planning, and F2 persistence helpers.src/contexts: auth and user preference state;UserContextalso mirrors some settings tolocalStorage.src/content: static guide content.src/integrations/supabase: client setup and generated database types.supabase/migrations: schema history for batches, reminders, timeline data, F2 setup, recipes, bottles, guides, and assistant data.
Core Product Rules
- Prefer clarity over cleverness.
- Keep guided flows explicit, especially in
src/pages/NewBatch.tsx,src/pages/BatchDetail.tsx, andsrc/components/f2/F2SetupWizard.tsx. - Do not present fermentation timing or carbonation advice as certainty; this app uses estimates.
- Preserve existing batch history, timeline events, reminders, bottle plans, and recipe traceability unless the task explicitly requires a migration.
- Do not silently change stage progression, timing thresholds, carbonation risk logic, or next-action text without tracing all consumers.
- When brewing rules are unclear, inspect the current helpers and schema before adding new assumptions.
Working Style
- Inspect relevant route files, domain helpers, and Supabase usage before editing.
- Reuse existing types from
src/lib/*.tsandsrc/integrations/supabase/types.tsinstead of redefining domain shapes. - Keep business logic in
src/libwhen practical; keep pages and components focused on presentation and orchestration. - Keep changes tight to the requested task. Do not refactor unrelated UI or schema areas casually.
- If work touches more than 3 files, stage transitions, persistence, or multi-step flows, write a short plan before editing.
- If work touches persisted data, identify both the frontend write path and the affected Supabase tables first.
Actual Data Flow To Respect
- Auth and user state flow through
AuthProviderandUserProvider;UserContextalways mirrors preferences tolocalStorageand syncs supported preference fields toprofileswhen authenticated. - New batches are created from
src/pages/NewBatch.tsxand inserted intokombucha_batches. - Batch detail reads from
kombucha_batches,batch_reminders,batch_stage_events, andbatch_logs, then derives timing UI withsrc/lib/batch-timing.ts. - F2 setup starts in
src/components/f2/F2SetupWizard.tsx, planning lives insrc/lib/f2-planner.ts, and persistence lives insrc/lib/f2-persistence.ts. - Starting F2 does not only update
kombucha_batches; it also creates or updatesbatch_f2_setups,batch_f2_bottle_groups,batch_bottles,batch_bottle_ingredients,batch_stage_events, andbatch_logs. - Shared stage labels and default next actions live in
src/lib/batches.ts; do not fork those rules in components.
Brewing And Lifecycle Rules
- The current batch stage model is:
f1_active,f1_check_window,f1_extended,f2_setup,f2_active,refrigerate_now,chilled_ready,completed,archived,discarded. - If you add or change a stage, update all dependent UI and persistence paths, including stage badges, progress displays, next actions, timeline text, F2 actions, and any Supabase enum usage.
- F1 timing estimates are derived in
src/lib/batch-timing.tsfrom brew date, room temperature, target preference, and starter ratio. Keep the explanation text aligned with the actual calculation. - F2 planning depends on bottle size, headspace, flavour additions, carbonation target, and ambient temperature. Changes here can affect both safety messaging and persisted bottle plans.
- Recipe traceability matters. Preset recipes, user recipes, recipe snapshots, bottle groups, and bottle ingredient rows should stay compatible with existing saved setups.
- When changing a batch stage from the UI, preserve timeline/history context by checking whether
batch_stage_eventsandbatch_logsalso need updates.
UX Rules
- This app is aimed at beginners first.
- Prefer step-by-step flows and clear review states over dense expert forms.
- Use calm, practical language. Good copy explains what the user should do next.
- Surface current stage, current risk, timing window, and next action clearly.
- Do not remove helpful context from overview cards, timeline entries, reminders, or F2 review summaries without a good reason.
Data Safety Rules
- Avoid destructive schema or data changes unless explicitly requested.
- Prefer additive migrations in
supabase/migrationsover breaking rewrites. - Keep
src/integrations/supabase/types.tsaligned with schema changes. - Be careful with backwards compatibility for saved batches, saved F2 setups, recipe snapshots, and profile preferences.
Validation
After code changes, run the commands this repo supports:
- Typecheck:
npx tsc -b - Lint:
npm run lint - Tests:
npm run test - If the change affects the production bundle or routing/build behavior, also run:
npm run build
Then summarize:
- Which files changed
- What was implemented
- Any follow-up risks or recommended next steps
Copy Architecture Rules
- Keep meaningful user-facing copy in feature-specific copy modules under
src/copy/when practical. - Prefer feature-level files such as
src/copy/f1-new-batch.ts,src/copy/f2-setup.ts, orsrc/copy/home.tsover one global copy file. - Extract and wire page titles, section headings, helper text, field labels, placeholders, warnings, empty states, CTA labels, review copy, and user-facing toast messages when working in a feature.
- Keep dynamic user-facing strings in typed copy helpers/functions instead of assembling them inline in components.
- Do not rewrite existing copy during extraction unless the task explicitly asks for copy changes.
- Very small local fragments such as tiny units or punctuation glue may remain inline when extraction would reduce clarity.
- New multi-step flows and major page work should follow the copy-module structure by default.
Response Expectations
- Start by stating which files or areas you will inspect.
- For non-trivial work, share a short plan before editing.
- After implementation, report concrete outcomes.
- Flag uncertainty explicitly instead of guessing, especially around brewing guidance or schema intent.
Priorities For This Repo
Prioritize correctness in this order:
- Data integrity
- Batch lifecycle consistency
- User clarity
- Maintainability
- Visual polish
Execution Plans
Use an execution plan as described in PLANS.md for any non-trivial task, especially work involving:
- More than 3 files
- Batch lifecycle or stage logic
- Supabase persistence or migrations
- F2 setup, bottle planning, or recipe persistence
- Multi-step features or refactors
When a plan is needed:
- Create or update a dedicated markdown plan file. Use
plans/<date>-<name>.mdif theplans/directory exists; otherwise create that directory first. - Follow
PLANS.mdexactly - Keep the plan current as work progresses
- Implement milestone by milestone
- Run validation after each milestone before moving on
- Do not ask for "next steps" between milestones unless a true product decision is missing
Things To Avoid
- Do not introduce broad redesigns unless requested.
- Do not rename core brewing concepts or stage names casually.
- Do not invent new fermentation or carbonation rules when the repo already has helpers for them.
- Do not change persistence behavior without checking the write path, read path, and generated types.
- Do not remove timeline, reminder, next-action, or bottle-plan context that the current flows rely on.