Amakuru.net

A CLI for Cloudflare email routing, because the dashboard does not scale

Batch create, update, export, and purge Cloudflare email routing rules from CSV or JSON files. Built with Typer, Rich, and uv.

Cloudflare’s free email routing is genuinely useful — point an MX record at them and you can forward anything@yourdomain wherever you like. The web dashboard is fine for a handful of rules, but the moment you have one address per service (amazon@, github@, bank@, …) and want to manage them as a list, the dashboard becomes the wrong tool. cloudflare-email-routing-cli is the CLI I wrote to fix that.

Export, edit, batch-update

The most useful primitive turned out to be rules export, which dumps current rules to CSV or JSON. Combined with rules batch-update, that gives a real workflow: export → edit → batch-update.

There’s no --overwrite flag on batch-create on purpose. An “overwrite” mode would silently mutate existing rules during a create, which is the kind of operation that should be a separate command rather than a flag tucked under one that says “create”.

Domain wins over zone ID

Authentication and zone targeting both support multiple paths: an API token or the legacy API key + email; a zone ID or a domain name. When both are set, the domain wins — the zone ID is re-resolved from the domain via the API, with a warning logged. Surprises around which zone was actually edited are how production gets nuked, and the more human-readable input is harder to misread.

uv, Typer, Rich

I default to the same Python stack for almost every CLI now: uv for environment management, Typer for the command surface, Rich for tables and progress, Loguru for logs. Defaulting to a known stack keeps time-to-first-working-command short enough that I actually start the project.

Was it worth it?

The dashboard is now somewhere I visit to confirm what just got changed, while the CLI handles every batch operation.

dmorel69/cloudflare-email-routing-cli — Python, Typer, Rich