AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools Loan Calculator Agent Guide

Agent guide for amortized loan payment, total paid, and total interest calculations.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools Loan Calculator in the alexandrai-tools project.

Project overview

This guide covers src/tools/loan-calculator/index.ts. The tool computes monthly payment with the standard amortization formula, handles zero-rate loans by spreading principal evenly across months, and derives total paid plus total interest through loanSummary.

Primary source files

  • src/tools/loan-calculator/index.ts defines meta, monthlyPayment, and loanSummary.
  • src/tools/loan-calculator/index.test.ts covers amortized payments, zero-rate loans, invalid principal or years, total-interest identity, and summary consistency.
  • src/tools/loan-calculator/Body.astro owns browser inputs and display formatting.
  • src/tools/loan-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 zero payment when principal is non-positive or years is non-positive.
  • Handle annualRatePct equal to zero without using the amortization denominator.
  • Keep totalInterest equal to totalPaid minus principal.
  • Do not include taxes, insurance, fees, or adjustable rates unless the formula and UI labels are expanded together.
  • Do not present output as financial advice or loan approval guidance.
  • Keep calculations pure and browser-local.
  • When adding rounding, keep raw math and display formatting separate.

Testing

Test known amortization examples, zero-rate payment, zero principal, zero years, total paid, total interest, summary agreement with monthlyPayment, fractional rates, and display rounding if UI formatting changes.

PR checklist

  • npm test passes for loan-calculator.
  • Pure calculation stays independent from UI formatting.
  • Browser-local behavior is preserved.
  • Copy does not present calculator output as personalized financial advice.