AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools PX REM Converter Agent Guide

Agent guide for CSS px, rem, and em conversion with base font validation and structured result objects.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools PX REM Converter in the alexandrai-tools project.

Project overview

This guide covers src/tools/px-rem-converter/index.ts. The tool trims string input, treats empty input as a successful no-op, parses a numeric value, validates that the base font size is finite and positive, supports px-to-rem, rem-to-px, and px-to-em modes, and returns formatted output rounded to six significant figures.

Primary source files

  • src/tools/px-rem-converter/index.ts defines meta, ConvertMode, ConvertResult, and convert.
  • src/tools/px-rem-converter/index.test.ts covers px-to-rem, rem-to-px, px-to-em, default base 16, custom base, empty input, non-numeric input, zero base, and zero value.
  • src/tools/px-rem-converter/Body.astro owns browser controls.
  • src/tools/px-rem-converter/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

  • Trim input before parsing.
  • Return ok true with empty output and empty error for empty input.
  • Return ok false with an error for non-finite numeric input.
  • Require base font size to be finite and greater than zero.
  • Default base font size is 16.
  • Round numeric output through toPrecision(6) and parseFloat before appending units.
  • Keep result shape as ok, output, and error unless all callers update together.

Testing

Test each conversion mode, default base, custom base, decimal input, zero value, empty input, invalid input, zero base, negative base, non-finite base, output unit suffixes, and rounding noise cases.

PR checklist

  • npm test passes for px-rem-converter.
  • Unit constants, lookup tables, and rounding rules are covered by tests.
  • Same-unit and invalid-input behavior remain documented.
  • UI labels, metadata, and pure conversion logic stay in sync.