# Note to AI editor Claude / GPT-4 / O1 / etc - If you need to see any additional files before you are sure you have enough context, ask the user to provide the file to the context before continuing. - If you would like to search for the contents to files, offer to use the run command and grep command to search for the contents. - Do not proceed to updating files until you have enough context to do so. - When working in the billing domain, prefer the renamed terminology (`contract lines`, `contracts`) and alias any remaining helper imports that include `plan`/`bundle` to the new schema names in your edits. - Default invoice template selections must flow through the `invoice_template_assignments` table. Do **not** add new usages of `invoice_templates.is_default` or `companies.invoice_template_id`; those fields are legacy-only until they are removed. # Failure Handling Philosophy - Fail fast when assumptions are violated instead of silently attempting fallbacks. - Throw exceptions with actionable, descriptive messages to surface what went wrong. - Validate assumptions as early as possible and reject inputs that do not meet strict criteria. # UI coding standards Prefer radix components over other libraries ## UI Components **IMPORTANT: All interactive elements (buttons, inputs, selects, etc.) MUST have unique `id` attributes for the reflection UI system. See Component ID Guidelines section for naming conventions.** - Use component from `packages/ui/src/components` folder - [Button](../packages/ui/src/components/Button.tsx) - [Card](../packages/ui/src/components/Card.tsx) - [Checkbox](../packages/ui/src/components/Checkbox.tsx) - [CustomSelect](../packages/ui/src/components/CustomSelect.tsx) - [CustomTabs](../packages/ui/src/components/CustomTabs.tsx) - [Dialog](../packages/ui/src/components/Dialog.tsx) - [Drawer](../packages/ui/src/components/Drawer.tsx) - [Input](../packages/ui/src/components/Input.tsx) - [Label](../packages/ui/src/components/Label.tsx) - [Switch](../packages/ui/src/components/Switch.tsx) - [SwitchWithLabel](../packages/ui/src/components/SwitchWithLabel.tsx) - [Table](../packages/ui/src/components/Table.tsx) - [TextArea](../packages/ui/src/components/TextArea.tsx) ### Theme & Dark Mode For full theming guidelines, CSS variable usage, and provider architecture, see [Theming Documentation](ui/theming.md). **Key rules:** - Use CSS variable tokens (`rgb(var(--color-text-700))`, `bg-primary-50`) — never hardcode hex/rgb values - Use `useAppTheme` from `@alga-psa/ui/hooks` — not `useTheme` from next-themes directly - Adapt dynamic entity colors with `adaptColorsForDarkMode()` from `@alga-psa/ui/lib/colorUtils` - Test all UI changes in both light and dark themes **Container backgrounds — always use CSS variables:** ```tsx // Good — adapts to dark mode via globals.css
// Bad — stays white in dark mode, text becomes invisible
``` **Selection/highlight states — always add `dark:` variants:** ```tsx // Good — readable in both themes