Debug and automate
Write a curl config file
Move stable, non-secret options into a readable configuration file without hiding important request behavior.
10 minute lesson
Commands you run repeatedly grow options until they no longer fit on a screen, and a fifteen-option command is where mistakes hide. A curl config file makes long repeatable commands easier to review: the options live in a file, one per line, where a colleague can actually read them.
Write the file
Create smoke.curl:
# transfer policy for the API smoke check
url = "https://example.org/"
fail-with-body
show-error
silent
max-time = 10
The format rules are few. Use long option names without the leading dashes, one option per line. Options that take a value use = (or a space). Lines starting with # are comments — use them, since a config file is documentation that happens to execute.
Run it:
curl --config smoke.curl
Same transfer as typing all five options by hand, but the file describes the transfer policy clearly, lives in version control, and changes show up in diffs and code review.
Command-line options can still add a temporary override:
curl --config smoke.curl --verbose
That is the intended division of labor: stable policy in the file, situational flags on the command line.
Keep secrets elsewhere
Config files get committed, shared, and copied between machines — that is their value. So keep request-specific secrets out of them. A header = "Authorization: Bearer ..." line in a committed file is a leaked credential. Pass secrets at run time from an environment variable or a secret manager, and let the file hold only what is safe for anyone to read.
The invisible config file
Here is what surprises people: curl may load a default user config automatically, ~/.curlrc on Linux and macOS, even when you never asked. If your curl behaves differently from a colleague’s — a proxy that appears from nowhere, an unexpected user agent — check whether a .curlrc is silently adding options.
Use --disable (or -q) first when you need a reproducible command independent of personal settings:
curl -q https://example.org/
It must be the first option on the command line, or curl ignores it. For scripts you intend to share, starting with -q and an explicit --config means the command behaves the same on every machine, which is the entire point of writing the policy down.
Lesson completed