AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Tip Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/tip-calculator/index.ts. The tool calculates tip from bill and tip percentage, adds it to the bill, divides by people, and returns zeros for invalid bill or people counts.
Primary source files
- src/tools/tip-calculator/index.ts defines meta, TipResult, and calcTip.
- src/tools/tip-calculator/index.test.ts covers standard tip, split bills, zero tip, zero bill, zero people, negative bill, and fractional percentages.
- src/tools/tip-calculator/Body.astro owns browser inputs and display.
- src/tools/tip-calculator/i18n.ts owns localized copy.
- src/lib/tools.ts registers metadata.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Return zeros for non-positive bill or non-positive people.
- Allow zero tip percentage.
- Allow fractional tip percentages.
- Calculate perPerson from total divided by people.
- Keep rounding and currency formatting in the UI layer.
- Do not encode regional tipping advice into the pure calculator.
- If tax, discounts, or service charges are added, label formula changes clearly.
Testing
Test standard tips, multi-person splits, zero tip, zero bill, zero people, negative bill, fractional percentages, decimal bills, and UI rounding if changed.
PR checklist
- npm test passes for tip-calculator.
- Pure calculation stays independent from UI formatting.
- Browser-local behavior is preserved.
- Copy does not present calculator output as personalized financial advice.