Foyn
Lab

Edge & DNS tooling

Cloudflare CLI

A coding agent changes DNS, tunnels, Access and zone settings on three domains from its shell, and puts a private app behind its login before the app gets a DNS record.

What it adds to flarectl

  • Zone settings

    flarectlRead only

    cf.shRead and write

  • Tunnels and Access

    flarectlNo commands

    cf.shAny v4 path the token permits, with cf.sh api

  • A refused call

    flarectlDoesn't say if the token or the IP filter refused it

    cf.shcf.sh check says which one, and prints the fix

flarectl covers DNS records and cache purges. cf.sh also reaches the other v4 API paths.

For agents and scripts

Access before DNS

The skill sets this order, so a new private hostname has its login before it has a DNS record.

  1. Route the tunnel

    Read the stack's tunnel config, add the hostname, write the whole list back.

  2. Put Access in front

    Create the Access app and check that its policy list is not empty.

  3. Add the DNS record

    Only then add the proxied CNAME to the tunnel.

  4. Check with DNS over HTTPS

    Use curl --doh-url: a local resolver may still hold an earlier 'not found' answer.

Under the hood

Needs
bash, curl and jq against the v4 REST API. No SDK.
Commands
check, zones, id, get, set, api
Key file
~/.config/cloudflare/env, mode 600, read when the key is not already set
Auth check
/user/tokens/verify, which IP filters never block, then a real /zones call to compare
Agent skill
cloudflare, with commands, ordering rules and known failures
Domains
jonasfoyn.com, hannahelle.com, phemten.com