Skills Directory精选自 GitHub 的开源 Skills

terraform-style-guidecommit 4451cecSKILL.md · 代码规范

Terraform 风格指南

按照 HashiCorp 官方风格约定和最佳实践生成与维护 Terraform HCL 代码。

npx skills add hashicorp/agent-skills --skill terraform-style-guide
权限
  • read-repo
  • write-files
  • shell
  • network
兼容工具
Claude Code, Codex
GitHub
911
来源
官方 · HashiCorp
状态
扫描通过
许可证
MPL-2.0

核心规则

每个变量都必须有 type 和 description,每个输出都必须有 description。

执行阶段

  1. 阶段 01按顺序生成

    先写 provider 和版本约束,再写数据源,按依赖顺序建资源,最后为关键属性添加输出,可配置值都用变量。

  2. 阶段 02组织文件

    拆分为 terraform.tf、providers.tf、main.tf、variables.tf、outputs.tf、locals.tf,变量和输出按字母排序。

  3. 阶段 03格式与命名

    两空格缩进并对齐等号,元参数在前、lifecycle 在后;名称用小写下划线的单数名词,多实例优先 for_each 而非 count。

  4. 阶段 04安全与版本

    显式固定版本,敏感值标记 sensitive,不硬编码凭据,按 SECURITY.md 启用加密;不提交 state 文件,提交 .terraform.lock.hcl。

  5. 阶段 05校验

    提交前运行 terraform fmt -recursive 和 terraform validate,可再用 tflint、checkov 或 tfsec,并对照审查清单。

权限说明(据 SKILL.md 整理)

能力是否需要说明
文件写入需要生成和修改 Terraform 配置文件(.tf)。
命令执行部分需要仅运行 terraform fmt、terraform validate 以及 tflint、checkov、tfsec 等检查工具。
网络外发不需要技能未要求访问网络,也不执行 plan 或 apply。

SKILL.md 头部信息(YAML)

SKILL.md 头部信息(YAML)commit 4451cec
---
name: terraform-style-guide
description: Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.
metadata:
  lifecycle-status: active
---

相关技能

规则扫描无法覆盖所有风险,安装前请阅读此技能的 SKILL.md,确认权限后再使用。