AlexandrAI AGENTS.md
agents-md

AlexandrAI Tools QR Code Generator Agent Guide

Agent guide for local SVG QR code generation in alexandrai-tools.

AGENTS.md

Guidance for coding agents working on AlexandrAI Tools QR Code Generator in the alexandrai-tools project.

Project overview

This guide covers src/tools/qr-code-generator/index.ts. The tool wraps the qrcode package and returns an SVG string for non-empty text. It trims input for emptiness, supports an optional margin, and leaves rendering and download concerns to the Astro body component.

Primary source files

  • src/tools/qr-code-generator/index.ts defines meta and qrSvg.
  • src/tools/qr-code-generator/index.test.ts covers SVG output, empty input, whitespace input, and custom margin.
  • src/tools/qr-code-generator/Body.astro owns the browser form, preview, and download behavior.
  • src/tools/qr-code-generator/i18n.ts owns localized page copy.
  • src/lib/tools.ts auto-discovers metadata for routing.

Setup commands

npm install npm test npm run typecheck npm run build npm run dev

Change rules

  • Return an empty string for empty or whitespace-only input.
  • Keep QR generation local and avoid network calls for rendering or preview.
  • Use SVG output unless the UI and download flow are deliberately expanded for PNG or canvas.
  • Keep margin default stable so existing screenshots and tests remain predictable.
  • Sanitize or safely render returned SVG in the UI; do not insert arbitrary user text as HTML outside the QR library output.
  • Do not publish QR examples that encode private links, credentials, or personal contact data.
  • When adding error correction or color options, update tests and UI constraints together.

Testing

Test empty input, whitespace input, ordinary text, long text, custom margin, SVG output shape, error handling from the QR library, and any future color or error-correction controls.

PR checklist

  • npm test passes for qr-code-generator.
  • Empty input produces no stale QR preview.
  • SVG rendering path does not expose unsafe HTML insertion.
  • Generated content stays local to the browser.