An OAuth-first Cloudflare administration CLI for inspecting and managing zones, DNS, rules, settings, lists, and account services. cfcli is designed to feel familiar to anyone who uses the GitHub CLI: commands are composable, automation-friendly, and safe by default.
- OAuth browser login with a guided scope picker and OS keychain storage.
- API-token login for headless automation with
--token-stdin. - Multiple named profiles with switch, status, verify, list, and logout commands.
- Zone, DNS record, zone setting, ruleset, Cloudflare list, and list-item commands.
- Account resource commands for load balancers, tunnels, Workers, Pages, R2, D1, Queues, Stream, Images, AI, and Access.
- Read-only health, audit, inventory, SSL, Origin CA, and cache commands.
cfcli apifor direct access to any Cloudflare API endpoint.- Human-readable and JSON output, including
--jqand templates. --dry-runfor supported writes and--forcefor destructive operations.- GitHub CLI-style help, aliases, typo suggestions, and command discovery.
- Dependency-injected ESM architecture with an extension/plugin contract and example extension.
- Node.js 26 or newer.
- A Cloudflare account and permission to authorize the Eliware OAuth client, or an API token for automation.
- Account and zone IDs for commands that need an explicit scope when defaults are not configured.
Install the published package:
npm install --global cfcliOr install from source:
git clone https://github.com/eliware/cfcli.git
cd cfcli
npm install
npm linkVerify the installation:
cfcli --version
cfcli --helpInteractive users should start the OAuth flow:
cfcli auth loginThe local web interface lets users select the scopes they need before authorizing with Cloudflare. Access and refresh credentials are stored in the operating system keychain when available. The callback page confirms success or failure and then the temporary local server shuts down.
Running cfcli auth login uses the public Eliware OAuth client built into the
CLI. The command starts a temporary local OAuth web server, opens the scope
picker, and then sends the selected authorization request to Cloudflare. The
client can request only scopes enabled in its Cloudflare registration, so the
picker's selections are limited by that registration.
You can register and manage a Cloudflare OAuth client in your own account or organization. This is useful for teams that want their own application identity or a different set of approved scopes:
- Create an OAuth application in Cloudflare.
- Enable the authorization-code response type (
Code), rather than an implicit token response. - Register
http://127.0.0.1:8765/oauth/callbackas the redirect URL. If the registration accepts multiple redirect URLs, also add ports8766through8769;cfcliuses those ports when an earlier one is busy. - Select all scopes the client is allowed to request. The scope picker can select permissions only when the Cloudflare client registration permits them.
- Start the normal login command with the client ID:
CF_OAUTH_CLIENT_ID=your-client-id cfcli auth loginThere is no separate OAuth-server command: cfcli auth login starts the
temporary server automatically. The default browser redirect remains
127.0.0.1; for remote access, the server can bind on all interfaces while
the registered redirect remains local to the browser:
CF_OAUTH_CLIENT_ID=your-client-id \
CF_OAUTH_BIND_HOST=0.0.0.0 \
CF_OAUTH_REDIRECT_HOST=127.0.0.1 \
cfcli auth loginThe client ID environment variable overrides the built-in Eliware client for
that login only. Do not commit client credentials, tokens, or .env files.
For headless automation, provide an API token through standard input:
printf '%s' "$CLOUDFLARE_API_TOKEN" | cfcli auth login --profile ci --token-stdinUse profiles to separate accounts or automation contexts:
cfcli auth list
cfcli auth status
cfcli auth switch --profile work
cfcli auth verify
cfcli auth logout --profile workAn unauthenticated command reports that the user is not logged in and directs them to cfcli auth login, matching the familiar GitHub CLI workflow.
The CLI checks npm for a newer version at most once per day. The check is
best-effort, does not delay commands, and never updates automatically. Disable
it with CF_NO_UPDATE_CHECK=1 or permanently with:
cfcli config set update-check falseEnvironment variables may be supplied directly, through a local .env, or as optional defaults in the project configuration:
CLOUDFLARE_API_TOKEN=your_api_token
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDFLARE_ZONE_ID=your_zone_idOAuth profiles are stored in the ~/.cfcli configuration directory, while secrets are stored in the OS keychain. Existing environment variables take precedence over profile values. Keep tokens, .env files, keychain exports, and generated state private; none should be committed.
Inspect zones and DNS records:
cfcli zones list
cfcli zones get --zone-id <zone_id>
cfcli dns-records list --zone-id <zone_id>
cfcli dns-records get --zone-id <zone_id> --id <record_id> --output jsonCreate or preview a DNS change:
cfcli dns-records create --zone-id <zone_id> \
--data '{"type":"A","name":"www","content":"192.0.2.1"}' \
--dry-runDestructive operations require explicit confirmation:
cfcli dns-records delete --zone-id <zone_id> --id <record_id> --forceUse JSON, jq selection, templates, or dashboard links in automation:
cfcli zones list --json
cfcli zones list --json --jq '.result[]'
cfcli api /zones --json --jq '.result[].name'
cfcli api /zones --json --template '{{.result}}'
cfcli zones get --zone-id <zone_id> --webAccess the full Cloudflare API when a built-in command is not available:
cfcli api /zones
cfcli api zones/<zone_id>/dns_records --method POST \
--data '{"type":"TXT","name":"example.com","content":"hello"}'Run <resource> --help or <resource> <command> --help for detailed command-specific help. Singular aliases such as cfcli zone, cfcli dns, cfcli rules, and cfcli list are supported.
Extensions add local commands without changing the built-in CLI. The repository includes an example extension and documents the extension manifest and handler contract:
cfcli extension list
cfcli extension install --path examples/extensions/hello
cfcli hello --name EliSee docs/extensions.md for the extension contract and docs/gh-orientation.md for the GitHub CLI familiarity guide.
Install dependencies and run the validation suite:
npm install
npm test
npm run lint
npm run test:gaps
npm run packThe test suite uses dependency injection for Cloudflare clients, filesystem access, environment loading, output, handlers, and process exits. Browser checks for the OAuth web interface are available without authenticating:
npm run test:e2e:screenshots
npm run test:e2e:lighthouse
npm run test:e2e:webScreenshots and Lighthouse reports are written under the ignored artifacts/ directory. Puppeteer is a development dependency and the local web test page can simulate the OAuth picker and callback result states.
bin/- executable CLI entry point.src/cli.mjs- dependency-injected command runtime.src/handlers/- built-in resource and authentication handlers.src/oauth-web/- standalone OAuth picker and callback pages.src/- argument, environment, API, profile, output, and extension utilities.examples/extensions/- example extension.tests/- unit and integration tests.tests/e2e/- Puppeteer and Lighthouse checks.dream.md- product vision.dream_sprints.md- roadmap.
For help, questions, or community chat:

