CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

curl

$ curl 基金会 中风险
Daniel Stenberg / curl project · 浏览器与网页抓取 · curl (MIT-like) · macos / linux / windows

curl 可在任意 Shell 中通过 HTTP/HTTPS、FTP 等数十种协议传输数据。配合 -sS、-f 与 --write-out(-w),编码 Agent 能确定性地检查状态码、响应头和 JSON 载荷,且无任何交互式提示。

FCRS-1.0 综合评分
91 /100
极佳 (Excellent)
高置信度 (实测)
零摩擦安装命令
brew install curl
CLI vs MCP 选型建议 仅 CLI 可用

curl 几乎随处预装,在临时 REST 调试、请求头排查以及将响应管道送入 jq 时,比 MCP 封装更直接高效。

Agent 友好度体检单

本地探针实测证据
— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
curl 8.7.1 (x86_64-apple-darwin26.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.69.0
冷启动耗时
6 ms
退出码 (help / 非法参数)
0 / 2
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
Usage: curl [options...] <url>
 -d, --data <data>           HTTP POST data
 -f, --fail                  Fail fast with no output on HTTP errors
 -h, --help <category>       Get help for commands
 -i, --include               Include response headers in output
 -o, --output <file>         Write to file instead of stdout
 -O, --remote-name           Write output to file named as remote file
 -s, --silent                Silent mode
 -T, --upload-file <file>    Transfer local FILE to destination
 -u, --user <user:password>  Server user and password
 -A, --user-agent <name>     Send User-Agent <name> to server
 -v, --verbose               Make the operation more talkative
 -V, --version               Show version number and quit

This is not the full help, this menu is stripped into categories.
Use "--help category" to get an overview of all categories.
For all options use the manual or "--help all".

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

借助 -sS、-f、--max-time 与 --write-out(%{http_code})实现确定性非交互执行,但原始响应仍需配合 jq 做结构化过滤。

  • Supports -fsS, -w '%{http_code}', and --json (7.82+)
安全与权限边界 21 / 25

默认仅执行只读 GET/HEAD,除非显式传入 -X POST/PUT/DELETE 或 -d;使用 --netrc 和 -v 时需注意凭据泄露。

  • Default invocation performs HTTP GET without mutating remote state
安装与运行摩擦 15 / 15

在几乎所有 macOS、Linux、Windows 和容器镜像中默认预装。

  • Ubiquitous system binary with zero runtime dependencies
能力覆盖与边际价值 15 / 15

HTTP、TLS、重定向追踪与 API 冒烟测试的通用瑞士军刀。

  • Handles HTTP/1.1, HTTP/2, HTTP/3, TLS inspection, and multipart uploads
维护与来源背书 10 / 10

由 Daniel Stenberg 与 curl/curl 项目持续维护数十年。

  • Official curl/curl repository with rapid security releases
文档与可验证性 9 / 10

拥有详尽的手册页(--help all)和权威官方文档。

  • Official documentation at curl.se/docs/manpage.html

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 环境变量密钥 本地配置文件
凭证存储位置

支持 .netrc 或显式传入 -H "Authorization: Bearer $TOKEN" 请求头;默认不持久化凭据。

潜在副作用
只读查询 本地写入 远端写入
费用与配额提示

免费开源,且在 macOS、Linux 与现代 Windows 上预装。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# curl Agent Rules
- Always pass `-fsS` and `--max-time <seconds>` so progress bars stay off and hung sockets time out cleanly.
- Never print `$Authorization` headers with `-v` into shared logs; pipe JSON bodies through `jq` before reading.

Agent 高频安全命令配方

只读查询(安全推荐)

静默 GET 请求并输出 HTTP 状态码
curl -fsS -w '\nHTTP_STATUS:%{http_code}\n' https://api.github.com/zen

隐藏进度条(-sS),在 HTTP >= 400 时失败退出(-f),并通过 -w 附加状态码。

仅检查响应头信息
curl -fsSI https://example.com

发送 HEAD 请求(-I)检查重定向、缓存头与内容类型,无需下载响应体。

受控写入与预演

带超时限制发送 JSON POST 请求
curl -fsS --max-time 15 -X POST -H 'Content-Type: application/json' -d '{"ping":true}' https://httpbin.org/post

以有界超时(--max-time 15)发送 JSON 载荷,并在出错时返回非零退出码。

核心优势

  • + 几乎在所有环境中开箱即用,零安装成本。
  • + -fsS 搭配 --max-time 可消除进度条噪音并避免无限挂起。
  • + --write-out(-w)可清晰输出状态码、耗时与重定向 URL。

注意事项与踩坑点

  • ! 原生不负责格式化或裁剪 JSON,需与 jq 配合使用。
  • ! -v 调试日志会打印敏感的 Authorization 请求头,需注意脱敏。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI