Skip to main content

Engineering conventions

These are the standing rules for working in the ContentsVision repo. They live in full in the repo's CLAUDE.md; this page summarizes them so the whole team shares the same expectations. They apply to everyone, including AI assistants working in the codebase.

Pull from stage before you start and before you commit​

Several people work in the repo at once. Run git pull origin stage before starting any work and again as the last step before committing. stage is the integration branch; never merge it into main unless asked. If a pull brings in changes, re-run the tests before committing; if it brings in conflicts, stop and say what collided rather than guessing at files you did not write.

Local testing is always signed in​

Adjust Square sign-in cannot work on localhost, so local ContentsVision always signs the user in through the local auth bypass (APP_ENV=local plus LOCAL_AUTH_USER_EMAIL, set once per machine in ~/.contentsvision/local.env). Check that /api/auth/me returns 200 before handing over a local link, and never let the bypass work outside APP_ENV=local. See local development.

Run the tests after every change​

The hard rule, repeated because it matters: run ./run_tests.sh after any change, and keep it green before considering the work done. A change with no test is incomplete. Show real failing output; never claim green when it is red. Full detail in testing.

Keep the handbook, the Help Center, and the changelogs in sync​

Every change updates what describes it, in the same commit:

  • This handbook (docs/docs/) whenever a change touches anything it describes (an env var, a dependency, an external service, the pipeline, the data model, an endpoint, billing, auth, a default, a deployment step, a convention). Removing something removes its rows here too. The code is the source of truth.
  • The Help Center (frontend/src/content/help/*.ts) for any change a user would see or do differently, with screenshots regenerated by the screenshot job, never captured by hand. A new user-facing capability gets a new article.
  • The changelogs: frontend/src/content/changelog/internal.md (the admin-only Updates page) for every commit that changes the app, and customer.md (the Changelog page every user sees) for anything a user would notice, in plain language, two lines and one change per entry. Entries start ## YYYY-MM-DD - [New|Improved|Fixed] Title, newest first, never backdated.

Releasing stage to main​

Merging stage into main is a release. Before it: list the changes in plain English and ask which belong in the customer changelog (never assume all of them), and run the live ContentsEstimation wire check with CE_LIVE_REQUIRED=1 so a contract mismatch fails instead of skipping. See checking the wire for real.

Writing style: no em dashes​

Never use em dashes anywhere: UI copy, code comments, commit messages, chat. Use a period, comma, colon, or parentheses instead. (This handbook follows the same rule.)

Frontend UI conventions​

Use the existing design system in frontend/src/app/globals.css rather than hand-rolling Tailwind for common controls. Skim globals.css first, and add a new component class there rather than inlining styles. Never use emojis for icons: use SVG icons. Use palette classes (slate-*, brand-*, success-*, white, ...) rather than literal hex colours: the palette switches with the dark theme, a hex value does not (pair one with a dark: variant if you truly need it).

ElementUseNot
Inputs.as-input (or .as-input-sm)raw <input className="border ...">
Selectsthe shared <StyledSelect> componenta native <select> (breaks the visual language)
Buttons.btn-primary / .btn-secondary / .btn-danger (+ .btn-sm, .press)ad-hoc button styles
Surfaces.card, .stat-cardbespoke panels
Labels.filter-label, .col-header, .eyebrowone-off label styles
Pagingthe shared <Pagination> componenta hand-rolled Prev/Next row

.as-select exists only as a legacy fallback and should be migrated to StyledSelect.

<Pagination> (frontend/src/components/Pagination.tsx) is Previous, numbered pages, and Next as one tight group, with an optional summary line pushed to the far left. Pages are zero-based in the props and the callback. It collapses long runs to 1 ... 5 6 7 ... 12, and drops to 1 ... 6 ... 12 below sm where there is no room for the neighbours. Only the insured media grid uses it today; the inventory table and Guided Review still have their own controls.

Motion​

Every user action should have a subtle animation; stillness reads as broken. Anything that mounts, unmounts, expands, collapses, or moves must animate in and out.

  • Use Framer Motion for conditionally rendered elements: wrap in <AnimatePresence> and give explicit initial, animate, and exit. Do not use a bare {cond && <div/>} for visible elements (the exit will not animate).
  • The CSS keyframe utilities (.animate-slide-down, .animate-fade-in, etc.) only animate the enter side; use them for things that mount once and stay.
  • Use the shared motion tokens, the same set ContentsEstimation ships: in Framer Motion, ease: EASE and DUR.fast / DUR.base / DUR.slow (0.14 / 0.22 / 0.32s) from src/lib/motion.ts, and spring for pops; in CSS, var(--ease-standard) with var(--dur-fast) / var(--dur-base) / var(--dur-slow) (or the ease-standard and duration-fast utilities). Do not type a curve such as easeOut or [0.4, 0, 0.2, 1]; a test fails the build on one.
  • Add .press to clickable elements for tactile feedback.
  • Re-key a list's container on sort/filter/pagination changes so rows re-mount and re-trigger their enter animation.

Add new keyframes under the "Motion primitives" section of globals.css, not as ad-hoc inline @keyframes.

Help Center articles​

The in-app Help Center (distinct from this handbook) has its own house style:

  • Short, verb-first headings; one task per heading; terse steps and bullets.
  • Every article starts from the home Dashboard and tells the reader how to navigate to where the article begins.
  • Concise to the point that removing one more word would break the sentence.
  • Use many screenshots, one under each step a reader might get stuck on.
  • Explain every feature in the flow; if it is not explained, it does not exist to the user.
  • When the reader might have more questions, point them to [email protected].
  • Screenshots come from the screenshot job (1440x900 viewport, device scale 2), never from ad-hoc captures. They render at full column width and are never stretched, so a 1x crop shows small; the test suite rejects new low-resolution screenshots.
  • Step-by-step task articles should get a playable guide ("Walk me through it"). Target real elements with data-guide="..." attributes and never rename one without updating its guides. See Help Center and playable guides.

Handoff prompts​

Never save a handoff prompt or "paste this into the next session" text to a file. Put it directly in the chat reply, inside a single fenced code block, so it can be copied. Do not split it across sections or create files for it.

Why these exist​

The conventions keep the product coherent: one visual language, motion that signals state, copy in one voice, and a test suite that stays trustworthy. They also let any contributor (or any AI session) pick up work without re-litigating style. When in doubt, match the surrounding code's idiom, comment density, and naming.