AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Emergency Fund Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/emergency-fund-calculator/index.ts. The tool multiplies monthly essential expenses by a target month count to calculate fundNeeded, and divides current savings by monthly expenses to estimate monthsCovered, with a zero-expense guard.
Primary source files
- src/tools/emergency-fund-calculator/index.ts defines meta, EmergencyFundResult, and calcEmergencyFund.
- src/tools/emergency-fund-calculator/index.test.ts covers fund target, months covered, fully funded state, zero expenses, and alternate month targets.
- src/tools/emergency-fund-calculator/Body.astro owns browser inputs and display.
- src/tools/emergency-fund-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
- Compute fundNeeded as monthlyExpenses times monthsTarget.
- Compute monthsCovered as currentSavings divided by monthlyExpenses only when monthlyExpenses is positive.
- Return monthsCovered zero when monthlyExpenses is zero to avoid division by zero.
- Keep target months user-controlled in the UI.
- Do not state that one target is universally sufficient.
- Keep rounding and currency display outside pure logic.
- If debt, income stability, or household size modifiers are added, test them as explicit options.
Testing
Test fundNeeded, monthsCovered, fully funded state, zero expenses, zero current savings, alternate target months, decimal expenses, and display rounding if changed.
PR checklist
- npm test passes for emergency-fund-calculator.
- Pure calculation stays independent from UI formatting.
- Browser-local behavior is preserved.
- Copy does not present calculator output as personalized financial advice.