terraform-best-practices by terramate-io/agent-skills
npx skills add https://github.com/terramate-io/agent-skills --skill terraform-best-practices由 Terramate 维护的 Terraform 和基础设施即代码综合优化指南。包含 10 个类别共 37 条规则,按影响优先级排序,以指导自动化重构和代码生成。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 组织与工作流 | 关键 | org- |
| 2 | 状态管理 | 关键 | state- |
| 3 | 安全最佳实践 | 关键 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
security- |
| 4 | 模块设计 | 高 | module- |
| 5 | 资源组织 | 中高 | resource- |
| 6 | 变量与输出模式 | 中 | variable-、output- |
| 7 | 语言最佳实践 | 中 | language- |
| 8 | 提供者配置 | 中 | provider- |
| 9 | 性能优化 | 低中 | perf- |
| 10 | 测试与验证 | 低 | test- |
org-version-control - 所有 Terraform 代码都应进行版本控制org-workspaces - 每个配置的每个环境使用一个工作区org-access-control - 控制谁可以更改哪些基础设施org-change-workflow - 基础设施变更的正式流程org-audit-logging - 跟踪所有基础设施变更state-remote-backend - 始终使用远程状态后端state-locking - 启用状态锁定以防止损坏state-import - 将现有基础设施导入 Terraformsecurity-no-hardcoded-secrets - 切勿在代码中硬编码密钥security-credentials - 使用适当的凭据管理(OIDC、Vault、IAM 角色)security-iam-least-privilege - 遵循最小权限原则module-single-responsibility - 每个逻辑组件对应一个模块module-naming - 使用一致的命名约定(terraform--)module-versioning - 对所有模块引用进行版本控制module-composition - 像构建块一样组合模块module-registry - 使用现有的社区/共享模块resource-naming - 使用一致的命名约定resource-tagging - 标记所有资源以进行成本跟踪resource-lifecycle - 使用生命周期块(prevent_destroy、ignore_changes)resource-count-vs-foreach - 优先使用 for_each 而非 countresource-immutable - 优先使用不可变基础设施模式variable-types - 使用特定类型、正向命名、可为空variable-validation - 添加验证规则以进行早期错误检测variable-sensitive - 将密钥标记为敏感,不设置默认值variable-descriptions - 使用描述文档化所有变量output-descriptions - 使用描述文档化所有输出output-no-secrets - 切勿直接输出密钥language-no-heredoc-json - 使用 jsonencode/yamlencode,而非 HEREDOClanguage-locals - 使用 locals 命名复杂表达式language-linting - 运行 terraform fmt 和 tflintlanguage-data-sources - 使用数据源而非硬编码language-dynamic-blocks - 使用动态块实现 DRY 代码provider-version-constraints - 固定提供者版本perf-parallelism - 为大型部署调整并行度perf-debug - 启用调试日志以进行故障排除test-strategies - 测试金字塔(验证、lint、plan、集成)test-policy-as-code - 实施策略检查(OPA、Checkov、tfsec)阅读单个规则文件以获取详细解释和代码示例:
rules/state-remote-backend.md
rules/security-no-hardcoded-secrets.md
rules/module-versioning.md
每个规则文件包含:
获取包含所有扩展规则的完整指南:AGENTS.md
每周安装次数
77
代码仓库
GitHub 星标数
30
首次出现
2026 年 2 月 1 日
安全审计
已安装于
codex71
opencode71
gemini-cli70
github-copilot70
amp69
kimi-cli69
Comprehensive optimization guide for Terraform and Infrastructure as Code, maintained by Terramate. Contains 37 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Organization & Workflow | CRITICAL | org- |
| 2 | State Management | CRITICAL | state- |
| 3 | Security Best Practices | CRITICAL | security- |
| 4 | Module Design | HIGH | module- |
| 5 | Resource Organization | MEDIUM-HIGH | resource- |
| 6 | Variable & Output Patterns | MEDIUM | variable-, output- |
| 7 | Language Best Practices | MEDIUM | language- |
| 8 | Provider Configuration | MEDIUM | provider- |
| 9 | Performance Optimization | LOW-MEDIUM | perf- |
| 10 | Testing & Validation | LOW | test- |
org-version-control - All Terraform code in version controlorg-workspaces - One workspace per environment per configurationorg-access-control - Control who can change what infrastructureorg-change-workflow - Formal process for infrastructure changesorg-audit-logging - Track all infrastructure changesstate-remote-backend - Always use remote state backendsstate-locking - Enable state locking to prevent corruptionstate-import - Import existing infrastructure into Terraformsecurity-no-hardcoded-secrets - Never hardcode secrets in codesecurity-credentials - Use proper credential management (OIDC, Vault, IAM roles)security-iam-least-privilege - Follow least privilege principlemodule-single-responsibility - One module per logical componentmodule-naming - Use consistent naming conventions (terraform--)module-versioning - Version all module referencesmodule-composition - Compose modules like building blocksmodule-registry - Use existing community/shared modulesresource-naming - Use consistent naming conventionsresource-tagging - Tag all resources for cost trackingresource-lifecycle - Use lifecycle blocks (prevent_destroy, ignore_changes)resource-count-vs-foreach - Prefer for_each over countresource-immutable - Prefer immutable infrastructure patternsvariable-types - Use specific types, positive naming, nullablevariable-validation - Add validation rules for early error detectionvariable-sensitive - Mark secrets as sensitive, no defaultsvariable-descriptions - Document all variables with descriptionsoutput-descriptions - Document all outputs with descriptionsoutput-no-secrets - Never output secrets directlylanguage-no-heredoc-json - Use jsonencode/yamlencode, not HEREDOClanguage-locals - Use locals to name complex expressionslanguage-linting - Run terraform fmt and tflintlanguage-data-sources - Use data sources instead of hardcodinglanguage-dynamic-blocks - Use dynamic blocks for DRY codeprovider-version-constraints - Pin provider versionsperf-parallelism - Tune parallelism for large deploymentsperf-debug - Enable debug logging for troubleshootingtest-strategies - Testing pyramid (validate, lint, plan, integration)test-policy-as-code - Implement policy checks (OPA, Checkov, tfsec)Read individual rule files for detailed explanations and code examples:
rules/state-remote-backend.md
rules/security-no-hardcoded-secrets.md
rules/module-versioning.md
Each rule file contains:
For the complete guide with all rules expanded: AGENTS.md
Weekly Installs
77
Repository
GitHub Stars
30
First Seen
Feb 1, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
codex71
opencode71
gemini-cli70
github-copilot70
amp69
kimi-cli69
Python测试专家技能:pytest单元测试、TDD测试驱动开发与集成测试最佳实践
117 周安装
Components.build 规范:构建现代化、可组合、无障碍 React UI 组件库的完整指南
115 周安装
Better Auth集成指南:Next.js身份验证处理器配置与Cookie处理方案
117 周安装
Google Drive 集成工具:命令行读写、搜索、文件管理,支持 OAuth 身份验证
116 周安装
NetSuite ERP集成指南:使用Membrane CLI管理客户、订单与财务
70 周安装
微信公众号文章创作助手 - 智能AI写作工具,一键生成专业公众号文案
115 周安装