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

TFLint

$ tflint 社区开源 低风险
Terraform Linters · 云原生与基础设施 · MPL-2.0 · macos / linux / windows

tflint 超越了基础的 terraform validate,能够依据 AWS、Azure、GCP 等云厂商插件规则及 HCL 命名规范检查代码。它支持非交互运行、--recursive 多模块递归扫描,并通过 --format json 输出清晰的诊断结果。

FCRS-1.0 综合评分
91 /100
极佳 (Excellent)
中置信度 (源码/文档)
零摩擦安装命令
brew install tflint
CLI vs MCP 选型建议 仅 CLI 可用

原生支持 --format json 的本地 HCL 静态检查器,直接调用 CLI 比经过 MCP 中转更高效。

Agent 友好度体检单

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

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

FCRS-1.0 六维评分拆解

Agent 友好度 22 / 25

支持 --format json、--format sarif、--format compact、--no-color 与 --recursive,退出码规范。

  • Native --format json and --no-color flags
  • Headless --recursive directory traversal
安全与权限边界 24 / 25

默认纯只读静态分析;仅 tflint --init 缓存插件或显式传入 --fix 时才会写入本地文件。

  • Zero cloud credentials required; read-only default mode
安装与运行摩擦 14 / 15

静态 Go 单二进制,支持 macOS、Linux 与 Windows 的 Homebrew、Chocolatey、Docker 与发行包。

  • Single static Go binary with cross-platform packages
能力覆盖与边际价值 14 / 15

在执行 terraform plan 之前即可拦截无效实例类型、废弃语法与未使用声明。

  • Pluggable AWS/Azure/GCP rulesets catch provider-level errors offline
维护与来源背书 8 / 10

社区广泛采用的项目(terraform-linters/tflint),以 MPL-2.0 协议活跃维护。

  • Active terraform-linters/tflint repo under MPL-2.0
文档与可验证性 9 / 10

仓库内用户指南、规则目录与 .tflint.hcl 配置说明详尽。

  • Detailed user guide and rule docs in repository

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

鉴权方式
无需鉴权 环境变量密钥
凭证存储位置

核心检查无需凭证;执行 tflint --init 下载插件时可读取 GITHUB_TOKEN 以避免 GitHub 速率限制。

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

MPL-2.0 开源免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# TFLint Agent Rules
- Always pass `--format json` or `--format compact --no-color`.
- Run `tflint --init` once if `.tflint.hcl` declares external plugins.
- Do not pass `--fix` without reviewing `git diff` afterward.

Agent 高频安全命令配方

只读查询(安全推荐)

递归检查 Terraform 模块并输出 JSON
tflint --recursive --format json

扫描当前目录及所有子模块,输出结构化的 JSON 问题与错误清单。

以无颜色紧凑格式运行检查
tflint --no-color --format compact

输出精简的 file:line:col: message 诊断行,节省上下文 Token。

受控写入与预演

初始化配置的 TFLint 插件
tflint --init

将 .tflint.hcl 中声明的插件下载到本地 ~/.tflint.d/plugins 缓存。

核心优势

  • + 提供干净的 --format json 与 --format compact 输出并支持 --no-color。
  • + 无需云端 plan 即可在本地捕获厂商级资源参数错误。
  • + 支持 --recursive 一键扫描大型 Monorepo。

注意事项与踩坑点

  • ! 启用云厂商特定规则前需联网执行一次 tflint --init。
  • ! 复杂的动态 HCL 表达式偶尔需要配合配置屏蔽误报。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI