detecting-infrastructure-drift
Execute use when detecting infrastructure drift from desired state. Trigger with phrases like "check for drift", "infrastructure drift detection", "compare actual vs desired state", or "detect configuration changes". Identifies discrepancies between current infrastructure and IaC definitions using terraform plan, cloudformation drift detection, or manual comparison.
Best use case
detecting-infrastructure-drift is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Execute use when detecting infrastructure drift from desired state. Trigger with phrases like "check for drift", "infrastructure drift detection", "compare actual vs desired state", or "detect configuration changes". Identifies discrepancies between current infrastructure and IaC definitions using terraform plan, cloudformation drift detection, or manual comparison.
Teams using detecting-infrastructure-drift should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/detecting-infrastructure-drift/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How detecting-infrastructure-drift Compares
| Feature / Agent | detecting-infrastructure-drift | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Execute use when detecting infrastructure drift from desired state. Trigger with phrases like "check for drift", "infrastructure drift detection", "compare actual vs desired state", or "detect configuration changes". Identifies discrepancies between current infrastructure and IaC definitions using terraform plan, cloudformation drift detection, or manual comparison.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Detecting Infrastructure Drift ## Current State !`ls *.tf Dockerfile docker-compose.yml 2>/dev/null || echo 'No IaC files found'` !`terraform version 2>/dev/null || echo 'Terraform not installed'` ## Overview Detect discrepancies between actual cloud infrastructure state and the desired state defined in IaC (Terraform, CloudFormation, Pulumi). Run drift detection commands, analyze modified/added/deleted resources, generate drift reports with affected resources, and provide remediation steps to bring infrastructure back into compliance. ## Prerequisites - IaC configuration files up to date in the project directory - Cloud provider CLI installed and authenticated with read access to all managed resources - IaC tool installed: Terraform 1.0+, AWS CLI (for CloudFormation drift), or Pulumi - Remote state storage accessible and current (S3 backend, Terraform Cloud, Pulumi Cloud) - Read-only IAM permissions for all resource types managed by IaC ## Instructions 1. Identify the IaC tool in use by scanning for `.tf` files, `template.yaml`, or `Pulumi.yaml` 2. Initialize the IaC tool if needed: `terraform init` to download providers and configure backend 3. Run drift detection: `terraform plan -detailed-exitcode` (exit code 2 = drift detected), `aws cloudformation detect-stack-drift`, or `pulumi preview` 4. Parse the output to identify resources with drift: added (exists in cloud but not in IaC), modified (attributes changed), or deleted (in IaC but missing from cloud) 5. For each drifted resource, determine if the drift is intentional (manual hotfix) or unintentional (configuration error, unauthorized change) 6. Generate a structured drift report with resource identifiers, attribute differences, and severity classification 7. Provide remediation options per resource: `terraform apply` to enforce desired state, `terraform import` to adopt changes, or update IaC to match reality 8. Schedule recurring drift detection: configure a cron job or CI pipeline to run daily and alert on drift 9. Investigate the root cause: determine who made the manual change and implement guardrails (SCPs, IAM restrictions) to prevent recurrence ## Output - Drift detection report with resource-level detail: resource type, ID, drifted attributes, expected vs. actual values - Remediation commands: `terraform apply`, `terraform import`, or IaC code updates - CI/CD pipeline step for automated drift detection on a schedule - Alert configuration for drift detection results (Slack, email, PagerDuty) - Prevention recommendations: IAM policy restrictions, SCP guardrails, automated enforcement ## Error Handling | Error | Cause | Solution | |-------|-------|---------| | `Error acquiring state lock` | Another Terraform process is running or stale lock | Wait for the other process; use `terraform force-unlock <ID>` if the lock is stale | | `Unable to authenticate to cloud provider` | Expired or missing credentials | Refresh with `aws configure`, `gcloud auth login`, or `az login` | | `No state file found` | Backend not initialized or state file deleted | Run `terraform init` to configure the backend; restore state from backup if deleted | | `Access denied reading resource` | IAM policy missing read permissions for some resource types | Grant read-only access for all resource types managed by IaC (`ReadOnlyAccess` or specific policies) | | `State file version mismatch` | Terraform version newer than state format | Upgrade Terraform to match the state version or use `terraform state replace-provider` | ## Examples - "Run drift detection against all Terraform-managed infrastructure and generate a report of resources that have changed since last apply." - "Set up a daily GitHub Actions workflow that runs `terraform plan` and posts drift results to Slack if any resources are out of sync." - "Detect CloudFormation stack drift for the production VPC stack and provide remediation steps for any MODIFIED resources." ## Resources - Terraform drift detection: https://developer.hashicorp.com/terraform/tutorials/state/resource-drift - CloudFormation drift detection: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/detect-drift-stack.html - Pulumi drift detection: https://www.pulumi.com/docs/using-pulumi/pulumi-packages/guides/drift-detection/ - Preventing drift: https://developer.hashicorp.com/terraform/tutorials/state/refresh
Related Skills
detecting-sql-injection-vulnerabilities
Detect and analyze SQL injection vulnerabilities in application code and database queries. Use when you need to scan code for SQL injection risks, review query construction, validate input sanitization, or implement secure query patterns. Trigger with phrases like "detect SQL injection", "scan for SQLi vulnerabilities", "review database queries", or "check SQL security".
detecting-performance-regressions
Automatically detect performance regressions in CI/CD pipelines by comparing metrics against baselines. Use when validating builds or analyzing performance trends. Trigger with phrases like "detect performance regression", "compare performance metrics", or "analyze performance degradation".
detecting-memory-leaks
Detect potential memory leaks and analyze memory usage patterns in code. Use when troubleshooting performance issues related to memory growth or identifying leak sources. Trigger with phrases like "detect memory leaks", "analyze memory usage", or "find memory issues".
collecting-infrastructure-metrics
Collect comprehensive infrastructure performance metrics across compute, storage, network, containers, load balancers, and databases. Use when monitoring system performance or troubleshooting infrastructure issues. Trigger with phrases like "collect infrastructure metrics", "monitor server performance", or "track system resources".
detecting-performance-bottlenecks
Execute this skill enables AI assistant to detect and resolve performance bottlenecks in applications. it analyzes cpu, memory, i/o, and database performance to identify areas of concern. use this skill when you need to diagnose slow application performance, op... Use when optimizing performance. Trigger with phrases like 'optimize', 'performance', or 'speed up'.
generating-infrastructure-as-code
Execute use when generating infrastructure as code configurations. Trigger with phrases like "create Terraform config", "generate CloudFormation template", "write Pulumi code", or "IaC for AWS/GCP/Azure". Produces production-ready code for Terraform, CloudFormation, Pulumi, ARM templates, and CDK across multiple cloud providers.
checking-infrastructure-compliance
Execute use when you need to work with compliance checking. This skill provides compliance monitoring and validation with comprehensive guidance and automation. Trigger with phrases like "check compliance", "validate policies", or "audit compliance".
detecting-database-deadlocks
Process use when you need to work with deadlock detection. This skill provides deadlock detection and resolution with comprehensive guidance and automation. Trigger with phrases like "detect deadlocks", "resolve deadlocks", or "prevent deadlocks".
detecting-data-anomalies
Process identify anomalies and outliers in datasets using machine learning algorithms. Use when analyzing data for unusual patterns, outliers, or unexpected deviations from normal behavior. Trigger with phrases like "detect anomalies", "find outliers", or "identify unusual patterns".
model-drift-detector
Model Drift Detector - Auto-activating skill for ML Deployment. Triggers on: model drift detector, model drift detector Part of the ML Deployment skill category.
schema-optimization-orchestrator
Multi-phase schema optimization workflow orchestrator. Creates session directories, spawns phase agents sequentially, validates outputs, aggregates results. Trigger: "run schema optimization", "optimize schema workflow", "execute schema phases"
test-skill
Test skill for E2E validation. Trigger with "run test skill" or "execute test". Use this skill when testing skill activation and tool permissions.