AGENTS.md
Guidance for coding agents working on AlexandrAI Tools Credit Card Validator in the alexandrai-tools project.
Project overview
This guide covers src/tools/credit-card-validator/index.ts. The tool strips non-digits, validates card numbers with the Luhn checksum, and detects common card networks from issuer identification prefixes. The implementation is local-only and should not store, log, or transmit user-entered card numbers.
Primary source files
- src/tools/credit-card-validator/index.ts defines meta, private digit normalization, luhnValid, and cardType.
- src/tools/credit-card-validator/index.test.ts covers valid and invalid checksum cases, separators, and common network prefixes.
- src/tools/credit-card-validator/Body.astro owns the browser input and result UI.
- src/tools/credit-card-validator/i18n.ts owns localized warnings and page copy.
- src/lib/tools.ts registers metadata for route discovery.
Setup commands
npm install npm test npm run typecheck npm run build npm run dev
Change rules
- Keep digit normalization local and deterministic; spaces and dashes should not break validation.
- Reject fewer than two digits before running a checksum result.
- Do not treat Luhn success as authorization, account existence, or payment validity.
- Keep network detection prefix-based and return Unknown when no rule matches.
- Do not add analytics, logging, telemetry, or network calls that could capture card input.
- Avoid publishing complete card-like sample numbers in public guides; keep detailed fixtures inside local tests only.
- When adding networks, update prefix rules, tests, UI labels, and localized copy together.
Testing
Test valid checksum, invalid checksum, separators, empty input, too-short input, Visa, Mastercard legacy and newer ranges, Amex, Discover, Unknown, and non-digit noise. If masking is added in the UI, test display masking separately from pure logic.
PR checklist
- npm test passes for credit-card-validator.
- No card input is persisted or transmitted.
- Network detection does not override checksum validity.
- Public docs avoid complete card-number examples.