Inferensys

Prompt

Drift Remediation Plan Generation Prompt

A practical prompt playbook for generating step-by-step remediation plans from confirmed configuration drift findings in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the exact conditions, required inputs, and user context for generating a safe, ordered remediation runbook from confirmed configuration drift findings.

This prompt is designed for platform engineers and SREs who have already completed drift detection and now face the critical task of planning a safe remediation. It is not a detection tool; it assumes you have a structured, accurate list of drifted resources, their desired versus actual states, and their dependencies. The job-to-be-done is transforming that raw drift report into an executable, ordered runbook that minimizes risk. The ideal user is an operator who understands the infrastructure but needs assistance sequencing complex, multi-resource changes where a naive, alphabetical fix order could cause an outage.

Use this prompt when you have a validated drift report from a tool like terraform plan, a Kubernetes manifest diff, or a custom reconciliation script. The input must include resource identifiers, property-level diffs, and explicit dependency relationships. Do not use this prompt if you are still investigating the root cause of drift, if the drift findings are incomplete or unverified, or if you are dealing with a live incident requiring immediate, manual intervention. This prompt is for planned maintenance windows, not active firefighting. It is also unsuitable for generating a single kubectl apply command; its value is in orchestrating a sequence of operations with pre-checks, validation gates, and rollback steps for each stage.

The output is a structured remediation runbook, not a script. You should wire this into a human approval workflow where the generated plan is reviewed before any automated execution. The prompt's primary failure mode is generating a plan that is logically ordered but violates an implicit dependency not captured in the input. To mitigate this, always provide a complete dependency graph in the [INPUT] and use the [CONSTRAINTS] field to specify immutable ordering rules, such as 'never restart a database before its read replicas.' After generating the plan, the next step is a human review against architectural diagrams, followed by a dry-run execution in a staging environment if available.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Drift Remediation Plan Generation Prompt works and where it introduces unacceptable risk.

01

Good Fit: Confirmed Drift with Known Root Cause

Use when: A drift detection tool has already identified specific resources, their diff, and a root cause analysis is complete. Guardrail: The prompt requires a structured drift report as input; never feed raw, unverified logs directly into remediation planning.

02

Bad Fit: Ambiguous or Unconfirmed Drift

Avoid when: The drift signal is noisy, the root cause is unknown, or the detection itself is suspect. Guardrail: Gate this prompt behind a confirmation step. Generating a remediation plan from false positives can automate the destruction of correctly running infrastructure.

03

Required Input: Structured Drift Report

What to watch: The prompt cannot reason effectively from unstructured alerts or raw diff output. Guardrail: The input must include resource IDs, property-level diffs, current vs. desired state, and a severity classification. A pre-processing step to normalize detection tool output is mandatory.

04

Operational Risk: Automated Destructive Changes

What to watch: A generated plan may include resource recreation or data-destructive actions. Guardrail: The output must be treated as a draft runbook. A human must approve any step flagged as destructive or recreate before it is passed to an execution agent.

05

Operational Risk: Dependency Ordering Failures

What to watch: Remediating resources in the wrong order (e.g., database before application) can cause cascading outages. Guardrail: The prompt must be evaluated on its ability to produce a topologically sorted plan. A post-generation validation script should check for dependency violations before the plan is shown to an operator.

06

Bad Fit: Real-Time Incident Response

Avoid when: An active incident requires immediate mitigation, not a full remediation plan. Guardrail: This prompt is for post-incident cleanup or planned maintenance windows. For active incidents, use a triage prompt to identify the immediate fix, and run this plan later to permanently reconcile state.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template with square-bracket placeholders for generating a step-by-step drift remediation plan from confirmed drift findings.

This prompt template generates an ordered remediation runbook from a set of confirmed drift findings. It is designed for platform engineers who need a safe, verifiable plan before executing changes. The template expects structured drift data as input and produces a plan with pre-checks, ordered steps, rollback instructions, and validation gates. Use this prompt when you have already detected and confirmed drift; do not use it for initial drift detection or root cause analysis.

text
You are a platform engineering remediation planner. Your task is to generate a step-by-step remediation runbook from a set of confirmed infrastructure drift findings.

## INPUT DRIFT FINDINGS
[DRIFT_FINDINGS]

## ENVIRONMENT CONTEXT
[ENVIRONMENT_CONTEXT]

## CONSTRAINTS
[CONSTRAINTS]

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "plan_id": "string",
  "generated_at": "ISO8601 timestamp",
  "summary": "One-paragraph summary of the remediation scope and risk level",
  "pre_checks": [
    {
      "check_id": "string",
      "description": "What to verify before starting remediation",
      "command_or_query": "The exact command or API call to run",
      "expected_result": "What a passing check looks like",
      "blocking": true_or_false
    }
  ],
  "remediation_steps": [
    {
      "step_number": integer,
      "resource_id": "The affected resource identifier",
      "drift_description": "What drifted",
      "action": "The specific remediation action",
      "command_or_manifest": "The exact command, API call, or manifest change",
      "expected_outcome": "What success looks like after this step",
      "depends_on_step_numbers": [integers_or_empty_array],
      "blast_radius": "What other resources or services may be affected",
      "rollback_action": "How to undo this step if it fails"
    }
  ],
  "validation_gates": [
    {
      "gate_id": "string",
      "after_step_numbers": [integers],
      "description": "What to validate",
      "command_or_query": "The exact validation command",
      "pass_criteria": "What passing validation looks like",
      "on_failure": "halt_or_rollback_or_continue"
    }
  ],
  "rollback_plan": {
    "trigger_conditions": ["List of conditions that trigger full rollback"],
    "ordered_rollback_steps": [
      {
        "step_number": integer,
        "reverses_remediation_step": integer,
        "action": "The rollback action",
        "command": "The exact rollback command"
      }
    ]
  },
  "risk_assessment": {
    "overall_risk_level": "low_or_medium_or_high_or_critical",
    "risks": ["List of specific risks"],
    "mitigations": ["List of mitigations for each risk"]
  }
}

## RULES
1. Order remediation steps by dependency: resources that others depend on must be remediated first.
2. Do not schedule parallel remediation of resources that share a dependency.
3. Every step must include a rollback action. If rollback is impossible, flag it in the risk assessment.
4. Pre-checks must run before any remediation step. Blocking pre-checks must pass before proceeding.
5. Validation gates must be placed after every step that changes stateful infrastructure.
6. If a drift finding involves a secret or credential, include a verification step that does not expose the secret value.
7. Mark any step that requires human approval with a note in the action field.
8. If the blast radius includes production traffic, set the risk level to at least "high".

## EXAMPLE OUTPUT
[EXAMPLE_OUTPUT]

Adapt this template by replacing the square-bracket placeholders with your specific data. [DRIFT_FINDINGS] should contain the structured output from your drift detection step—typically a JSON array of resources, property diffs, and severity classifications. [ENVIRONMENT_CONTEXT] should describe the target environment, including whether it serves production traffic, its deployment tooling, and any maintenance windows. [CONSTRAINTS] should list operational constraints such as allowed change windows, approval requirements, and resources that must not be modified. [EXAMPLE_OUTPUT] should contain one or two representative examples of correct output to guide the model's format and level of detail. Before deploying this prompt, validate that the output JSON conforms to the schema and that step ordering respects real dependency relationships in your infrastructure graph.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Drift Remediation Plan Generation Prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to verify the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[DRIFT_FINDINGS]

Structured list of confirmed drift items requiring remediation

{"findings": [{"resource_id": "aws_s3_bucket.logs", "drifted_field": "versioning.enabled", "expected": true, "actual": false, "severity": "HIGH"}]}

Must be valid JSON array. Each finding requires resource_id, drifted_field, expected, actual, and severity fields. Severity must be one of CRITICAL, HIGH, MEDIUM, LOW. Empty array should trigger a no-op response.

[ENVIRONMENT_CONTEXT]

Target environment metadata including name, account, region, and access constraints

{"environment": "production", "account_id": "123456789012", "region": "us-east-1", "change_window": "2025-01-15T02:00:00Z/2025-01-15T04:00:00Z"}

Must include environment name and region. Change window is optional but recommended for scheduling. Validate region against known provider regions. Account ID must match expected pattern.

[INFRASTRUCTURE_STATE]

Current IaC source of truth, typically Terraform state, CloudFormation stack, or Pulumi export

{"source": "terraform", "state_hash": "abc123", "resources": [...]}

Must include source type and state payload. State hash enables cache validation. Validate that resource IDs in DRIFT_FINDINGS exist in this state. Missing resources indicate stale findings and should abort generation.

[DEPENDENCY_GRAPH]

Map of resource dependencies showing creation and deletion ordering constraints

{"aws_s3_bucket.logs": {"depends_on": ["aws_kms_key.logs_key"], "depended_by": ["aws_iam_role.log_writer"]}}

Optional but strongly recommended for safe ordering. If omitted, the prompt must instruct the model to infer dependencies from resource types and references. Validate that all resource IDs in DRIFT_FINDINGS appear as keys.

[REMEDIATION_POLICIES]

Organizational policies governing remediation behavior: allowed actions, approval gates, and forbidden operations

{"require_approval_for": ["DESTROY", "CRITICAL"], "forbidden_actions": ["manual_console_changes"], "max_parallel_remediations": 3}

Must include allowed actions list or forbidden actions list. If both are empty, prompt should default to conservative mode requiring human approval for all changes. Validate that action names match known remediation action types.

[OBSERVABILITY_HOOKS]

Endpoints or identifiers for logging, metrics, and notification channels used during remediation

{"log_group": "/remediation/production", "alert_topic_arn": "arn:aws:sns:...", "metrics_namespace": "DriftRemediation"}

Optional. If provided, the plan should include logging and notification steps. Validate ARN formats and log group naming conventions. Missing hooks should produce a plan that notes observability gaps.

[PREVIOUS_REMEDIATION_HISTORY]

Record of prior remediation attempts for the same or similar drift findings

[{"finding_id": "drift-001", "attempted_at": "2025-01-10", "action": "terraform_apply", "result": "PARTIAL_SUCCESS", "notes": "Versioning enabled but lifecycle policy failed"}]

Optional. When present, the plan must reference prior failures and adjust approach. Validate timestamps are ISO 8601. Result must be one of SUCCESS, PARTIAL_SUCCESS, FAILED, ROLLED_BACK. Stale history older than 30 days should be flagged.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Drift Remediation Plan Generation Prompt into an application or operational workflow.

This prompt is designed to be the final step in a drift detection pipeline, not a standalone chat interaction. It expects a structured drift report as input and produces a machine-readable remediation plan. The implementation harness must validate the input drift report against a known schema before invoking the model, because malformed or incomplete drift data will produce an unreliable plan. In production, this prompt should be triggered automatically after a drift detection run completes and passes a severity threshold, or manually by an on-call engineer reviewing a triaged alert.

Wire the prompt into a workflow engine or orchestration layer that first fetches the drift report from your detection system (e.g., a drift detection Lambda output, a Terraform plan JSON file, or a database record). Validate the input against a strict schema that includes required fields: resource_id, resource_type, drifted_properties, expected_state, actual_state, and severity. Reject inputs missing these fields before they reach the model. After invoking the model, parse the output against the expected remediation plan schema (ordered steps with step_id, action, target_resource, pre_check, rollback_action, and validation_gate). If parsing fails, retry once with a repair prompt that includes the raw output and the schema. Log both the input drift report and the generated plan for auditability. For high-severity drift involving stateful resources (databases, persistent volumes, IAM roles), route the generated plan to a human approval queue before any automated execution.

Model choice matters here: use a model with strong reasoning and structured output capabilities, such as Claude 3.5 Sonnet or GPT-4o, with the response_format or tool-calling API set to enforce JSON output. Avoid smaller or older models that may reorder dependent steps incorrectly. The primary evaluation criteria for this prompt are dependency ordering correctness and rollback completeness. Build an eval harness that tests the prompt against a golden dataset of drift scenarios with known correct remediation sequences. Flag any output where a resource is modified before its dependencies are healthy, or where a destructive action lacks a corresponding rollback step. Do not use this prompt for real-time automated remediation without human-in-the-loop approval for any resource tagged with severity: critical or risk: high.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the generated remediation plan. Use this contract to parse, validate, and gate the model output before executing any remediation step.

Field or ElementType or FormatRequiredValidation Rule

remediation_plan_id

string (uuid)

Must match UUID v4 regex. Reject on parse failure.

generated_at

string (ISO 8601 UTC)

Must parse as valid ISO 8601 datetime in UTC. Reject if older than 24 hours from current time.

drift_finding_ids

array of strings

Each element must be a non-empty string matching the source drift report finding IDs. Array must not be empty.

remediation_steps

array of objects

Array must contain at least 1 step. Each step object must pass the step schema validation below.

remediation_steps[].order

integer

Must be a positive integer starting at 1 and incrementing by 1. No gaps or duplicates allowed.

remediation_steps[].resource_id

string

Must match a resource ID present in the source drift findings. Reject if resource not found in input context.

remediation_steps[].action

string (enum)

Must be one of: terraform_apply, manual_console, script_execute, helm_upgrade, kubectl_apply, iam_update, secret_rotation, rollback_only, human_approval_required.

remediation_steps[].pre_checks

array of strings

If present, each string must be a non-empty, actionable check (e.g., 'Verify backup completed for [resource_id]'). Null allowed.

PRACTICAL GUARDRAILS

Common Failure Modes

Drift remediation plans fail when ordering is unsafe, rollback paths are missing, or validation gates are skipped. These are the most common production failure modes and how to prevent them.

01

Unsafe Dependency Ordering

What to watch: The plan reconfigures a database before its dependent services are drained, or modifies a network policy before validating downstream connectivity. This causes cascading outages during execution. Guardrail: Require the prompt to output a dependency graph and enforce a strict topological sort. Validate that no resource is modified before its consumers are verified healthy.

02

Missing Rollback Steps

What to watch: The plan provides forward-only steps with no reversal procedure. If step 3 of 7 fails, the operator is left in an unknown intermediate state with no documented path back to safety. Guardrail: Require every remediation step to include an explicit, testable rollback action. Add an eval check that counts rollback steps and flags any step missing one.

03

Validation Gate Omission

What to watch: The plan applies changes without inserting health checks, smoke tests, or metric thresholds between steps. A silent failure in step 2 propagates undetected through the remaining steps. Guardrail: Mandate a validation gate after every state-changing operation. The output schema must include a validation field per step with a specific check command or query.

04

Stale Context Drift

What to watch: The remediation plan was generated from a drift report that is now hours old. In the interim, another operator or automation changed the same resources, making the plan dangerous to execute. Guardrail: Require a freshness check as the first step of every plan. Re-run the drift detection and abort if the current state no longer matches the plan's assumptions.

05

Secrets Exposure in Plan Output

What to watch: The generated plan includes connection strings, API keys, or certificate material inline in the remediation steps. This leaks secrets into runbooks, ticketing systems, and chat logs. Guardrail: Add a pre-output redaction pass. The prompt must instruct the model to reference secret locations by vault path or variable name only, never inline values. Validate output with a regex secret scanner.

06

Blast Radius Underestimation

What to watch: The plan treats a shared resource like a VPC or IAM role as a single-tenant change. The remediation affects multiple workloads, but the plan only validates one. Guardrail: Require a blast-radius section in the plan output listing all affected resources, services, and environments. If the blast radius exceeds a threshold, the plan must be split or require explicit human approval.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality and safety of a generated Drift Remediation Plan before it is shown to an operator or executed by an automated system.

CriterionPass StandardFailure SignalTest Method

Safe Ordering of Dependencies

Resources are ordered so that dependencies (e.g., a network before a compute instance) are remediated first.

A compute resource is listed before its network or IAM role dependency.

Parse the ordered step list and validate against a known dependency graph for the target resource types.

Pre-Check Completeness

Every remediation step that mutates state is preceded by a verification pre-check (e.g., 'Verify resource X exists').

A 'delete' or 'update' step is listed without a preceding 'get' or 'describe' verification step.

Scan the plan for action verbs (DELETE, UPDATE, PATCH) and assert a non-mutating check precedes each one.

Rollback Step Inclusion

Every mutating step includes a corresponding, explicit rollback step or a reference to a rollback script.

A step that changes a security group rule has no 'revert to previous rule' step.

Check each mutating step for a sibling step with a 'rollback' or 'revert' label in its description.

Validation Gate Definition

The plan includes a specific, testable validation command (e.g., curl, aws cli command) after each logical block.

A block of steps ends with a vague instruction like 'check if it worked' without a concrete command.

Use a regex to check for the presence of executable CLI commands or API calls in the 'Validation' sections of the plan.

Blast Radius Containment

The plan targets only the specific resources identified in the [DRIFT_REPORT] and avoids unnecessary changes to stable resources.

The plan includes a step to restart a production load balancer when only a tag on an unused security group drifted.

Diff the list of target resource ARNs in the plan against the ARNs in the [DRIFT_REPORT] input; they must match exactly.

Idempotency Flagging

Steps that are not safe to re-run are explicitly flagged with a warning (e.g., 'DO NOT RE-RUN if step 3 succeeded').

A script block that creates a resource is presented without any warning about re-running it.

Search the plan for resource creation commands and assert a warning string is present in the preceding comment or description.

Secrets Handling

The plan never includes plaintext secrets; it references secret store paths or environment variables.

A step contains a hardcoded password or API key string.

Scan the output with a secrets detection regex (e.g., AWS key patterns, generic high-entropy strings) and assert zero matches.

Human Approval Gate

High-risk actions (e.g., destroying a database, modifying IAM) are wrapped in an explicit 'HUMAN_APPROVAL_REQUIRED' gate.

A step to run 'terraform destroy' on a stateful resource has no approval gate.

Check the plan for a list of high-risk actions and assert each is wrapped in a conditional block that checks for a human approval flag.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a single drift finding. Remove the multi-resource ordering constraints and focus on generating a plan for one resource at a time. Use a lightweight output schema with only steps, pre_checks, and rollback fields.

code
Generate a remediation plan for this single drift finding:
[DRIFT_FINDING]

Return JSON with:
- steps: ordered list of remediation actions
- pre_checks: what to verify before starting
- rollback: how to undo each step

Watch for

  • Plans that assume tool access you haven't wired yet
  • Ordering that ignores dependencies when you scale to multiple resources
  • Missing rollback steps for destructive actions like resource recreation
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.