AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Body Fat Calculator in the alexandrai-tools project.
Project overview
This guide covers src/tools/body-fat-calculator/index.ts. The tool estimates body fat percentage with the US Navy circumference formulas, supports metric and imperial inputs, requires hip measurement for female calculations, and optionally calculates lean mass when body weight is provided.
Primary source files
- src/tools/body-fat-calculator/index.ts defines meta, Sex, BodyFatResult, bodyFatNavyMetric, and bodyFatNavyImperial.
- src/tools/body-fat-calculator/index.test.ts covers plausible male and female estimates, lean mass, missing hip error, waist sensitivity, and imperial conversion parity.
- src/tools/body-fat-calculator/Body.astro owns browser inputs.
- src/tools/body-fat-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
- Keep metric as the source formula and imperial as a conversion wrapper.
- Require hip measurement for female calculations.
- Only compute leanMassKg when body weight is positive and provided.
- Round body fat percentage and lean mass to one decimal place.
- Do not present circumference estimates as a diagnostic measurement.
- Handle invalid measurement combinations deliberately if validation is added.
- Keep all entered body measurements browser-local.
Testing
Test male estimates, female estimates, required hip input, lean mass with weight, null lean mass without weight, larger waist behavior, metric-imperial parity, and invalid logarithm inputs if validation changes.
PR checklist
- npm test passes for body-fat-calculator.
- Pure calculation stays separate from display formatting.
- Copy presents outputs as estimates, not medical advice.
- Health or fitness input remains browser-local.