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

cfn-lint

$ cfn-lint 官方出品 低风险
Amazon Web Services · 云原生与基础设施 · MIT-0 · macos / linux / windows

cfn-lint 在本地依据 AWS CloudFormation 官方资源规范与内置规则校验 YAML/JSON 模板,无需 AWS 凭证。通过 -f json 输出,Agent 可直接获取精确的文件、行号、列号与规则 ID 以自动修复模板。

FCRS-1.0 综合评分
94 /100
极佳 (Excellent)
中置信度 (源码/文档)
零摩擦安装命令
brew install cfn-lint
CLI vs MCP 选型建议 优先选 CLI

本地毫秒级运行且支持 -f json;相比调用 AWS MCP 服务端更快且无额外 Token 开销。

Agent 友好度体检单

✓ 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 23 / 25

原生支持 -f json(--format json)与 SARIF,提供位掩码退出码区分严重级别,完全非交互。

  • Native -f json / --format json diagnostic array
  • Bitmask exit codes distinguishing errors, warnings, and informational findings
安全与权限边界 25 / 25

纯只读静态分析器,常规检查无需任何 AWS 凭证或网络请求。

  • 100% read-only local execution with zero IAM credentials
安装与运行摩擦 13 / 15

可通过 Homebrew、pip 与 uvx 在 macOS、Linux、Windows 安装;pip 方式依赖 Python 运行时。

  • Cross-platform Python package with Homebrew and uvx support
能力覆盖与边际价值 14 / 15

在执行耗时的 cloudformation deploy 前即可在本地捕获规范、内部函数与区域兼容错误。

  • Bundled AWS CloudFormation specs eliminate API round-trips
维护与来源背书 10 / 10

AWS 官方 aws-cloudformation/cfn-lint 仓库以 MIT-0 协议高频更新资源规范。

  • Official AWS-maintained repo with MIT-0 license
文档与可验证性 9 / 10

规则目录与 --help 参数文档完整,易于核验。

  • Comprehensive rule index and CLI flags in repo docs

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

鉴权方式
无需鉴权
凭证存储位置

无需 AWS 凭证;基于本地内置的 AWS CloudFormation 资源规范运行。

潜在副作用
只读查询
费用与配额提示

AWS 官方 MIT-0 开源工具,完全免费且离线可用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# cfn-lint Agent Rules
- Always pass `-f json` when validating CloudFormation templates for automated parsing.
- Use `-r <region>` when templates target regions other than `us-east-1`.
- Treat exit code `2` (errors) as blocking; inspect warnings (`4`) per `.cfnlintrc`.

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 格式校验 CloudFormation 模板
cfn-lint template.yaml -f json

离线校验模板并返回包含行号与规则 ID 的结构化 JSON 诊断结果。

按指定 AWS 区域校验模板兼容性
cfn-lint 'templates/**/*.yaml' -r us-east-1 us-west-2 -f json

针对指定 AWS 区域核对资源类型与属性规范是否可用。

核心优势

  • + -f json 结构化输出精确标注文件、行号、列号与规则编号。
  • + 无需 AWS 凭证即可离线校验官方资源 Schema。
  • + 位掩码退出码便于 Agent 区分阻塞错误与一般告警。

注意事项与踩坑点

  • ! 基于 Python 运行时,冷启动略慢于静态 Go 二进制。
  • ! 包含自定义 Macro/Transform 的模板可能需要配合 --ignore-checks 调整。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI