AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Break Even Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/break-even-calculator/index.ts. The tool validates finite non-negative fixed costs, positive price per unit, and non-negative variable cost per unit, rejects zero or negative contribution margin with null, and returns units as fixed costs divided by contribution margin.
Primary source files
- src/tools/break-even-calculator/index.ts defines meta, BreakEvenResult, and calcBreakEven.
- src/tools/break-even-calculator/index.test.ts covers standard units, fractional-unit cases, zero and negative contribution margin, non-positive price, negative fixed costs, zero fixed costs, and non-finite inputs.
- src/tools/break-even-calculator/Body.astro owns browser controls.
- src/tools/break-even-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 null for non-finite inputs.
- Return null for negative fixed costs.
- Return null for price per unit less than or equal to zero.
- Return null for negative variable cost per unit.
- Compute contribution margin as pricePerUnit minus variablePerUnit.
- Return null when contribution margin is less than or equal to zero.
- Allow zero fixed costs and return zero units.
Testing
Test standard break-even, fractional results, zero fixed costs, zero contribution margin, negative contribution margin, invalid price, invalid variable cost, invalid fixed costs, non-finite inputs, and UI rounding to whole units if added.
PR checklist
- npm test passes for break-even-calculator.
- Formula, invalid-input policy, and rounding policy remain documented.
- Pure helpers stay arithmetic-only and browser-local.
- UI labels, metadata, and tests update together for behavior changes.