Agent-first CLI for Peru's tax authority. CPE emission (UBL 2.1 + XAdES + SOAP), SIRE filing, GRE shipping notices, REST OAuth APIs, RHE/F616 — all under one binary.
$ bun add -g @crafter/sunat-cli
# Install globally
$ bun add -g @crafter/sunat-cli
# Introspect schema (agents self-serve)
$ sunat-cli schema cpe-factura --output json
{ "command": "cpe factura emit", "fields": {...} }
# Always dry-run first
$ sunat-cli cpe factura preview --params @factura.json
{ "dryRun": true, "hash": "sha256:...", "validacion": {"ok": true} }
# Ship it — UBL 2.1 + XAdES + SOAP, end-to-end
$ sunat-cli cpe factura emit --params @factura.json --yes
✓ Aceptado · CDR 0000 · F001-1234Capabilities
UBL 2.1 + XAdES-BES + SOAP directo a SUNAT. End-to-end verified against beta.
$ sunat-cli cpe factura emit \
--params '{"serie":"F001",...}' --yesREST API + JWT. Tracker idempotente, retries con backoff.
$ sunat-cli cpe gre emit \
--params @guia.json --yesPropuesta de ventas/compras, ticket polling, descarga ZIP, importar via TUS 1.0.0.
$ sunat-cli sire rvie propuesta \
--periodo 202504 --yesBoletas <S/700 batched, comunicación de baja con ticket polling.
$ sunat-cli cpe resumen send \
--fecha 2026-04-29 --yesBrowser login without CAPTCHA. RHE in batch, F616 mensual read headless from the declaration API.
$ sunat-cli f616 declare --json '{"periodo":"2026-03"}'Store cert passwords and clave SOL in the macOS/Linux keychain. Hidden prompt keeps secrets out of shell history and env vars.
$ sunat-cli keychain set CPE_CERT_PASSWORD
# prompts without echoManage several RUC from one machine. Set a profile per emisor, switch with one command.
$ sunat-cli cpe profile use acmeAgents self-serve field definitions at runtime. 25+ schemas exposed.
$ sunat-cli schema cpe-factura
# Returns JSON schema of all fieldsREST OAuth2 client_credentials. Padrón sync incremental, lookup local sub-ms.
$ sunat-cli api consulta \
--tipo 01 --serie F001 --numero 123Scrape diario, cache local, fallback a fecha hábil previa.
$ sunat-cli tipo-cambio --fecha hoy
# {compra: 3.752, venta: 3.758}Architecture
The F616 declaration form is a single-page app over a JSON API. Instead of driving the DOM on every run, the CLI opens a browser once to capture a session token (the IdCache), then closes it.
From there, f616 periodo and f616 oficios read the API directly, headless, for the lifetime of that token. No CAPTCHA to solve, no form fields to fight.
Coverage
Per-domain breakdown of how much of each SUNAT surface is wrapped, validated against the beta endpoint, and exposed as an agent-callable command. Green = shipped & verified. Yellow = partial. Orange/Red = shaped or needs production credentials.
Roadmap
Design philosophy
Following Justin Poehnelt's "Rewrite Your CLI for AI Agents" principles and the agentskills.io specification. The agent is not a trusted operator.