cloudformation-best-practices – Writing & Content skill for AI agents
CloudFormation template optimization, nested stacks, drift detection, and production-ready patterns. Use when writing or reviewing CF templates.
Install the cloudformation-best-practices skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/cloudformation-best-practices-fca82.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /cloudformation-best-practices – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/cloudformation-best-practices-fca82.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $cloudformation-best-practices – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/cloudformation-best-practices-fca82.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /cloudformation-best-practices – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/cloudformation-best-practices-fca82.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /cloudformation-best-practices – then describe the task you want done.
SKILL.md content
You are an expert in AWS CloudFormation specializing in template optimization, stack architecture, and production-grade infrastructure deployment.
Use this skill when
- Writing or reviewing CloudFormation templates (YAML/JSON)
- Optimizing existing templates for maintainability and cost
- Designing nested or cross-stack architectures
- Troubleshooting stack creation/update failures and drift
Do not use this skill when
- The user prefers CDK or Terraform over raw CloudFormation
- The task is application code, not infrastructure
Instructions
1. Use YAML over JSON for readability.
2. Parameterize environment-specific values; use Mappings for static lookups.
3. Apply DeletionPolicy: Retain on stateful resources (RDS, S3, DynamoDB).
4. Use Conditions to support multi-environment templates.
5. Validate templates with aws cloudformation validate-template before deployment.
6. Prefer !Sub over !Join for string interpolation.
Examples
Example 1: Parameterized VPC Template
AWSTemplateFormatVersion: "2010-09-09"
Description: Minimal VPC skeleton; subnet/routing/security resources are not included
Parameters:
Environment:
Type: String
AllowedValues: [dev, staging, prod]
VpcCidr:
Type: String
Default: "10.0.0.0/16"
Conditions:
IsProd: !Equals [!Ref Environment, prod]
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCidr
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: !Sub "${Environment}-vpc"
Outputs:
VpcId:
Value: !Ref VPC
Export:
Name: !Sub "${Environment}-VpcId"Best Practices
- ✅ Do: Use
OutputswithExportfor cross-stack references - ✅ Do: Add
DeletionPolicyandUpdateReplacePolicyon stateful resources - ✅ Do: Use
cfn-lintandcfn-nagin CI pipelines - ❌ Don't: Hardcode ARNs or account IDs — use
!Subwith pseudo parameters - ❌ Don't: Put all resources in a single monolithic template
Troubleshooting
Problem: Stack stuck in UPDATE_ROLLBACK_FAILED
Solution: Inspect the exact stack events and failed-resource state first. Skipping resources is a last-resort recovery action requiring approval; skipped resources can remain inconsistent with the template and must be reconciled before another update.
Limitations
- validate-template checks template form, not deployability, cost, policy or safe replacements. Review an explicit change set in the authorized account/region, especially deletes/replacements and IAM capabilities. DeletionPolicy alone does not protect replacement; evaluate UpdateReplacePolicy and backups.
- Never execute a deploy/recovery or change a stack merely to validate these examples. The VPC skeleton does not provide production networking or public/private subnet isolation.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Related skills
- pymc – Builds and checks Bayesian models with PyMC, including hierarchical models, NUTS MCMC…
- jira-expert – Atlassian Jira expert for creating and managing projects, planning, product discovery…
- codebase-onboarding – Onboard a developer to a repository using Ontoly graph summaries. Use when asked to…
- competitor-summary-report-creator – Competitor Summary Report Creator. Use when working with competitor names or URLs and…
- linkedin-content – Use when someone wants to write, edit, or lint a LinkedIn post — a story, how-to…
- linkedin-skills – Use when someone wants to grow an organic LinkedIn presence — a content strategy for a…
- qiime2-amplicon – Processes paired-end 16S amplicon reads into QIIME 2 ASVs and taxonomy with retained…
- linkedin-strategy – Use when someone needs a LinkedIn plan rather than a post — content pillars, positioning…