mirror of
https://github.com/magnus919/agent-skills.git
synced 2026-09-11 19:47:12 +03:00
00abbf90a4
* feat(skill): add Terraform operational skill Add a single tool skill for Terraform and OpenTofu operations: module structure, state backends and locking, plan/apply workflow, drift detection, remote state, upgrade and refactor flows, and evidence-based diagnostics. Ships the agent-first tfops wrapper (JSON output, direct state-file analysis, --dry-run/--yes/--force mutation gate), a fixture-tested suite, six eval cases, dated references, and routing up to platform-engineering. Closes #243. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> * fix(skill): clarify missing-binary report in tfops doctor When the TERRAFORM env override names a binary that cannot be found, doctor now reports the env value with a (not found) marker instead of falling back to the generic default name. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
3.2 KiB
3.2 KiB
Diagnostics
Diagnose in evidence order: binary/version → config validation → backend + lock status → state serial/lineage → plan diff → apply error → boundary check. Each layer narrows the next; skipping layers produces guesswork.
First-response diagnostic (tfops)
scripts/tfops doctor --json # binary, version, config files, backend hint, optional state summary
scripts/tfops plan --state state.json --json # state-level inventory without a binary
scripts/tfops plan --json # real plan against the backend (needs binary + backend access)
doctor tells you whether the failure is environmental (no binary, no config) or state-related before you interpret any deeper error.
Failure patterns
Lock errors (Error acquiring the state lock)
- Find the holder through backend-specific inspection (the DynamoDB lock item, the cloud workspace run, the Consul session).
- Confirm no operation is genuinely running; only then
force-unlock <LOCK_ID>with the ID from the error. - Never delete the lock row blindly; never bypass locking by switching to the local backend to run a command.
Serial/lineage mismatches (Error: state file in path does not match the given serial or lineage errors)
- The local/backup state and the live state diverged. Use
state pullto see the live state, compare serials, and restore from a known-good backup after review — never overwrite a newer serial.
terraform init backend errors
- Verify backend configuration, credentials/identity, and network path.
-reconfigurere-reads the backend block; a changed backend without-migrate-state/-reconfigureis the usual trigger.
Plan/apply errors mid-run
- Read the resource-level error, not just the summary; providers give actionable messages (API errors, quota, IAM).
- A partial apply leaves state consistent but the resource may not exist: re-plan to see what remains, then apply again.
- Timeout or "context deadline exceeded": check the provider's operation timeout and the backend/network; bounded retries beat immediate blind re-apply.
Validate errors
terraform validatediagnostics point at file/line; fix config errors before planning. Tainted resources (tfopsreports them) are not a validate error — they are a plan/apply concern.
Verification boundary
| Diagnosis | Minimum evidence |
|---|---|
| Binary healthy | terraform version / tofu version exit 0 |
| Config valid | validate exit 0 with no diagnostics |
| Backend reachable | init exit 0; lock acquired and released |
| State intact | tfops state --state FILE --json parses; serial/lineage match backend |
| Root cause fixed | The originally failing operation succeeds, then a clean re-plan |
Sources
Last Updated: 2026-08-03
- Terraform troubleshooting guide: https://developer.hashicorp.com/terraform/tutorials/configuration-language/troubleshooting-workflow (accessed 2026-08-03)
- State locking and force-unlock: https://developer.hashicorp.com/terraform/language/state/locking (accessed 2026-08-03)
- Common error messages: https://developer.hashicorp.com/terraform/internals/error-messages (accessed 2026-08-03)
- OpenTofu CLI reference (diagnostics): https://opentofu.org/docs/cli/ (accessed 2026-08-03)