Inferensys

Prompt

Manual Change vs IaC Reconciliation Prompt

A practical prompt playbook for reconciling manual emergency changes with Infrastructure-as-Code definitions after an incident. Produces a structured reconciliation report that identifies which changes need to be codified, reverted, or accepted as permanent exceptions.
Developer doing prompt engineering on laptop, prompt variations visible on screen, casual coding session.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise post-incident scenario, required inputs, and boundary conditions for the Manual Change vs IaC Reconciliation Prompt.

This prompt is designed for the specific moment after an incident is resolved but before the next deployment cycle begins. The primary job-to-be-done is to close the gap between what an on-call engineer did under duress to restore service and what the canonical Infrastructure-as-Code (IaC) repository declares as the desired state. The ideal user is a platform engineer or SRE who has access to three critical artifacts: a manual change log (even if it's a rough timeline from a chat channel), the current IaC source files (Terraform, CloudFormation, Pulumi, etc.), and a snapshot of the live infrastructure state. The prompt's value lies in transforming a messy, high-pressure human process into a structured, auditable reconciliation report that can be reviewed, actioned, and archived for compliance.

You should not use this prompt during an active incident. It is a post-mortem analysis tool, not a real-time response aid. It is also inappropriate when the manual change log is entirely absent; the prompt requires at least a partial list of actions to begin reconciliation. If you only have a live state and IaC source without any record of what was changed manually, use a standard drift detection prompt instead. This prompt is specifically for classifying and dispositioning known manual interventions. Furthermore, do not use it for routine, planned changes that were simply executed out-of-band; it is tuned for emergency changes made under duress, where documentation may be incomplete, inconsistent, or captured in unstructured communication logs. The prompt's instructions to handle 'incomplete documentation' and 'changes made under duress' are key differentiators from a standard configuration audit.

Before invoking this prompt, assemble the three inputs into a clear, text-based format. The manual change log can be a raw copy-paste from Slack, PagerDuty notes, or a ticket. The IaC source should be the relevant file contents, not just file paths. The live state should be a structured export from your cloud provider or infrastructure tool. The prompt's output is a structured report classifying each manual change as codify, revert, or exception. Your next step is to feed this report into a remediation planning workflow, such as a set of Jira tickets for codify items and a rollback runbook for revert items. Always require a human to approve the final classification before any automated remediation is triggered, as the model may misinterpret the intent behind a manual change made during a high-stress event.

PRACTICAL GUARDRAILS

Use Case Fit

The Manual Change vs IaC Reconciliation Prompt is designed for post-incident analysis where emergency changes were applied directly to infrastructure. It is not a real-time drift detector or a replacement for state management tools.

01

Good Fit: Post-Incident Reconciliation

Use when: an incident required manual changes to production infrastructure and you need to systematically reconcile those changes with Terraform, CloudFormation, or Pulumi definitions. Guardrail: Provide the prompt with both the IaC source and a structured log of manual changes (timestamps, commands, resource IDs) to produce a complete reconciliation report.

02

Bad Fit: Real-Time Drift Detection

Avoid when: you need continuous monitoring of infrastructure state against IaC. This prompt is designed for point-in-time reconciliation after known manual intervention, not for ongoing drift detection. Guardrail: Use dedicated drift detection tools (e.g., Terraform drift detection, AWS Config) for continuous monitoring and reserve this prompt for structured post-incident analysis.

03

Required Inputs: Change Evidence

What to watch: the prompt cannot reconcile changes it cannot see. Incomplete or vague descriptions of manual changes produce unreliable reports. Guardrail: Provide the prompt with concrete change evidence: audit logs, shell history, runbook entries, or incident chat transcripts. Flag any changes where documentation is incomplete so the report can mark them as unverified.

04

Operational Risk: Changes Made Under Duress

Risk: manual changes made during incidents are often poorly documented, applied under time pressure, and may include workarounds that should not be codified. Guardrail: The prompt output must distinguish between changes to codify, changes to revert, and changes to accept as permanent exceptions with explicit justification. Require human review before any IaC commit.

05

Operational Risk: Incomplete Resource Coverage

Risk: the prompt may miss resources that were changed but not documented, or resources that were indirectly affected by a manual change. Guardrail: Cross-reference the reconciliation report with a live-state snapshot to catch undocumented changes. Add a 'coverage confidence' field to the output schema indicating how complete the change inventory is.

06

Bad Fit: Greenfield IaC Generation

Avoid when: you want to generate new IaC from scratch based on manual changes. This prompt reconciles existing IaC with manual changes, not generates new infrastructure definitions. Guardrail: For greenfield IaC generation from live state, use a separate prompt designed for resource import and code generation, then validate the output against the original manual changes.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for reconciling manual emergency changes with Infrastructure-as-Code definitions after an incident.

This template is designed to be copied directly into your AI harness, prompt library, or orchestration layer. It accepts structured inputs describing the incident context, the IaC source of truth, and the manual changes made under duress. The model is instructed to produce a reconciliation report that classifies each manual change as needing codification, reversion, or acceptance as a permanent exception. All placeholders use square-bracket notation and must be replaced with real data before execution.

code
You are an infrastructure reconciliation analyst. Your task is to compare a set of manual emergency changes against the current Infrastructure-as-Code (IaC) definitions and produce a structured reconciliation report.

## INPUTS

### IaC Source of Truth
[IAC_DEFINITIONS]

### Manual Changes Log
[MANUAL_CHANGES]

### Incident Context
[INCIDENT_CONTEXT]

### Constraints
[CONSTRAINTS]

## OUTPUT SCHEMA

Return a JSON object with the following structure:

{
  "reconciliation_id": "string",
  "generated_at": "ISO8601 timestamp",
  "summary": {
    "total_manual_changes": "integer",
    "changes_to_codify": "integer",
    "changes_to_revert": "integer",
    "permanent_exceptions": "integer",
    "unresolved": "integer"
  },
  "findings": [
    {
      "finding_id": "string",
      "manual_change_description": "string",
      "related_iac_resource": "string or null",
      "classification": "codify | revert | permanent_exception | unresolved",
      "rationale": "string explaining the classification with reference to incident context and constraints",
      "remediation_steps": ["string"],
      "risk_if_not_remediated": "low | medium | high | critical",
      "evidence_sources": ["string references to specific lines or resources in IAC_DEFINITIONS or MANUAL_CHANGES"]
    }
  ],
  "unresolved_items": [
    {
      "finding_id": "string",
      "reason": "string explaining why classification is blocked",
      "information_needed": "string describing what additional data would resolve this"
    }
  ]
}

## CLASSIFICATION RULES

- **codify**: The manual change addresses a legitimate gap in the IaC definitions and should be added to the source of truth. The change is safe, intentional, and aligns with infrastructure patterns.
- **revert**: The manual change was a temporary fix that should be rolled back once the IaC is updated or the incident is resolved. The change introduces drift, security risk, or inconsistency.
- **permanent_exception**: The manual change cannot be codified due to technical limitations, organizational policy, or resource constraints, but it is intentional and must be documented as an accepted exception with a review cadence.
- **unresolved**: Insufficient information exists to classify the change. Specify what additional data is needed.

## RULES

- Ground every classification in specific evidence from [IAC_DEFINITIONS] and [MANUAL_CHANGES].
- If a manual change was made under duress with incomplete documentation, flag it as unresolved rather than guessing.
- For changes classified as permanent_exception, include a recommended review date no more than 90 days out.
- If [CONSTRAINTS] specifies compliance frameworks, check each finding against those requirements.
- Do not invent changes, resources, or incident details not present in the inputs.
- If the manual changes log contains contradictory or ambiguous entries, note the ambiguity in the rationale.

Adaptation guidance: Replace [IAC_DEFINITIONS] with the full text of your Terraform, CloudFormation, Pulumi, or other IaC files. Replace [MANUAL_CHANGES] with a structured log of changes made during the incident—ideally sourced from audit trails, runbooks, or chat transcripts. Replace [INCIDENT_CONTEXT] with a brief description of the incident, its severity, and any time pressure that affected decision-making. Replace [CONSTRAINTS] with organizational policies, compliance frameworks, or architectural rules that must be respected. For high-risk production environments, always route the output through a human review step before any remediation action is taken.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Manual Change vs IaC Reconciliation Prompt. Each placeholder must be populated before the prompt is assembled and sent. Validation notes describe how to check input quality before execution.

PlaceholderPurposeExampleValidation Notes

[IA_CURRENT_STATE]

Current IaC definition from source of truth (Terraform, CloudFormation, Pulumi)

terraform show -json output or main.tf file content

Parse check: valid HCL/JSON/YAML syntax. Schema check: must contain resource blocks. Null not allowed.

[RUNTIME_STATE]

Live resource state extracted from cloud provider or infrastructure API

aws ec2 describe-instances JSON or kubectl get all -o yaml

Parse check: valid JSON/YAML. Must include resource identifiers and property values. Timestamp check: snapshot must be less than 1 hour old.

[INCIDENT_TIMELINE]

Timeline of manual changes made during the incident, including timestamps and actor identity

CloudTrail events, audit logs, or incident chat log with timestamps

Schema check: must include timestamp, actor, action, and target resource per entry. Null allowed if no incident occurred.

[CHANGE_WINDOW_START]

ISO 8601 timestamp marking the start of the reconciliation window

2025-01-15T14:30:00Z

Format check: valid ISO 8601. Must be before [CHANGE_WINDOW_END]. Null not allowed.

[CHANGE_WINDOW_END]

ISO 8601 timestamp marking the end of the reconciliation window

2025-01-15T16:00:00Z

Format check: valid ISO 8601. Must be after [CHANGE_WINDOW_START]. Null not allowed.

[EXCEPTION_POLICY]

Documented exceptions or approved manual-override policies for this environment

Production emergency change policy v2.3 or 'no exceptions documented'

Citation check: if policy document referenced, must include source link or text. Null allowed if no formal policy exists.

[OUTPUT_SCHEMA]

Expected structure for the reconciliation report output

JSON schema with fields: resource_id, drift_type, action, justification, risk_level

Schema check: must be valid JSON Schema. Must include required fields: resource_id, drift_type, action. Null not allowed.

[CONSTRAINTS]

Operational constraints for remediation recommendations

No destructive actions without approval. Prefer codify over revert for security hardening changes.

Content check: must be non-empty string. Should reference approval gates, allowed actions, and environment restrictions. Null not allowed.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Manual Change vs IaC Reconciliation Prompt into a production incident response workflow.

This prompt is designed to sit inside a post-incident reconciliation workflow, not as a real-time response tool. The ideal harness runs after an incident has been declared resolved and the immediate pressure is off. The workflow should gather three inputs before invoking the prompt: the IaC source of truth (e.g., Terraform state, CloudFormation template, or Pulumi stack export), a structured log of manual changes made during the incident (extracted from runbooks, chat transcripts, or audit logs), and the incident timeline with severity classification. The prompt expects these as [IAC_DEFINITION], [MANUAL_CHANGE_LOG], and [INCIDENT_CONTEXT] respectively. Do not feed raw, unprocessed chat logs directly into the prompt—pre-process them into a structured change log with timestamps, actor, resource ID, action taken, and justification if available.

The implementation should include a pre-processing step that normalizes manual change records into a consistent schema before prompt assembly. Each manual change record should contain: resource_id, change_type (create, modify, delete, restart, scale), property_path, old_value, new_value, timestamp, actor, and justification. This normalization prevents the model from misinterpreting free-form incident notes. After the prompt returns its reconciliation report, a post-processing validator should check that every resource referenced in the report exists in the IaC definition and that no IaC resources were silently omitted. The validator should also flag any reconciliation recommendation that suggests destructive actions (e.g., terraform destroy on a production database) for mandatory human review before execution.

Model choice matters here. Use a model with strong structured reasoning capabilities and a large context window—GPT-4o or Claude 3.5 Sonnet are appropriate starting points. Set temperature=0 to maximize deterministic output for the reconciliation classification. The prompt should be wrapped in a retry loop with a maximum of two retries if the output fails schema validation. Log every invocation with the incident ID, prompt version, model used, and a hash of the input change log for auditability. The reconciliation report should be stored alongside the incident record, not as the sole source of truth. Always require a human platform engineer to review and approve the report before any remediation actions are taken. The highest-risk failure mode is the model recommending reversion of a manual change that was actually a necessary security hardening step applied under duress—human review is the only reliable guard against this.

For teams running in regulated environments, add an evidence-grounding step before prompt invocation. Each manual change record should be linked to a source artifact: an audit log entry, a chat message permalink, or a runbook execution timestamp. The prompt's [INCIDENT_CONTEXT] should include a severity classification and any compliance framework tags (SOC 2, HIPAA, PCI) that constrain remediation options. After the reconciliation report is generated, run a compliance-aware post-check that flags any recommendation which would violate a regulatory control—for example, reverting an encryption enablement change or removing an access restriction. These flagged items should be escalated to a compliance reviewer in addition to the platform engineer. Do not use this prompt for real-time drift detection during an active incident; it is a post-incident analysis tool and will produce unreliable results under time pressure with incomplete information.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, types, and validation rules for the reconciliation report. Use this contract to parse, validate, and store the model output before surfacing it to a human or triggering downstream automation.

Field or ElementType or FormatRequiredValidation Rule

report_id

string (UUID v4)

Must parse as valid UUID v4. Reject if missing or malformed.

generated_at

string (ISO 8601 UTC)

Must parse as valid ISO 8601 timestamp in UTC. Reject if in the future or unparseable.

reconciliation_scope

object

Must contain 'environment' (string) and 'iac_source' (string). Both fields required and non-empty.

findings

array of objects

Must be a non-null array. Empty array is valid (no drift). Each item must match the finding_object schema.

finding_object.resource_id

string

Non-empty string. Must match pattern for cloud resource ARN or Terraform address. Reject if blank.

finding_object.drift_type

string (enum)

Must be one of: 'manual_change', 'iac_only', 'value_mismatch', 'orphaned_resource'. Reject unknown values.

finding_object.severity

string (enum)

Must be one of: 'critical', 'high', 'medium', 'low', 'info'. Reject unknown values.

finding_object.remediation_action

string (enum)

Must be one of: 'codify', 'revert', 'accept_exception', 'import_to_iac', 'destroy'. Reject unknown values.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when reconciling manual changes against Infrastructure-as-Code, and how to guard against it.

01

Incomplete Change Documentation

Risk: Manual changes made during an incident are often poorly documented or entirely undocumented, leading the model to hallucinate a plausible but incorrect reason for the change. Guardrail: Require the prompt to explicitly list any changes with 'UNKNOWN' rationale when documentation is missing, and flag these for mandatory human review before codification.

02

False Equivalence Between State and Intent

Risk: The model assumes the current live state is the correct desired state, proposing to codify a temporary hotfix or a security-compromising change as the new permanent baseline. Guardrail: Include a [DESIRED_STATE_SOURCE] input that explicitly prioritizes the IaC definition as the source of truth, forcing the model to treat live deviations as anomalies to be investigated, not blindly accepted.

03

Sensitive Data Exposure in Diffs

Risk: Reconciliation reports can inadvertently include secrets, API keys, or PII that were manually injected into environment variables or configs during an emergency. Guardrail: Implement a pre-processing step that scans and redacts values matching known secret patterns before they reach the prompt, and add a [CONSTRAINTS] tag explicitly forbidding the output of secret values.

04

Misclassification of Intentional Drift

Risk: The model flags legitimate, intentional differences (e.g., a higher instance count in production) as drift requiring remediation, creating noise and eroding trust in the report. Guardrail: Provide an [ACCEPTED_EXCEPTIONS] list in the prompt input, defining resources and properties that are allowed to diverge, and instruct the model to classify these as 'Accepted Exception' rather than 'Drift'.

05

Ordering Dependencies in Remediation Plan

Risk: The generated remediation plan proposes a sequence of Terraform applies or CLI commands that would fail due to undeclared dependencies between resources. Guardrail: Instruct the model to output a dependency-aware, ordered list in the [OUTPUT_SCHEMA], and validate the plan with a terraform plan dry-run in a sandboxed CI pipeline before presenting it to the operator.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality and safety of the reconciliation report before deploying the Manual Change vs IaC Reconciliation Prompt to production. Each criterion should be tested against a golden dataset of known drift scenarios.

CriterionPass StandardFailure SignalTest Method

Change Identification Recall

All manual changes documented in the incident timeline are present in the report's change inventory.

A documented manual change (e.g., a firewall rule added during an outage) is missing from the report.

Run prompt against a golden incident record with a known set of 10 manual changes. Assert that all 10 appear in the output.

Change Identification Precision

No reported change is a false positive; every listed change corresponds to a real manual intervention.

The report flags a resource difference that was actually caused by an automated process (e.g., auto-scaling) as a manual change.

Run prompt against a 'steady-state' environment with zero manual changes. Assert the change inventory list is empty.

IaC Source Grounding

Every change is mapped to the correct, specific IaC resource path (e.g., module.webserver.aws_security_group.rule) or explicitly flagged as 'No IaC Target Found'.

A change is mapped to a generic or incorrect resource path, or the grounding citation is hallucinated.

Parse the output JSON. For each change, verify the iac_resource_path field exists in the actual IaC source files using a script.

Reconciliation Action Correctness

The recommended action (Codify, Revert, or Accept Exception) is logically consistent with the change type, incident context, and security posture.

A temporary emergency firewall 'allow 0.0.0.0/0' rule is recommended for 'Codify' without a security warning or justification.

Use an LLM-as-Judge with a detailed rubric to evaluate the action for 5 pre-classified edge cases. Assert 100% agreement with the expected action.

Handling of Incomplete Documentation

Changes made under duress with incomplete documentation are flagged with an 'Uncertainty: High' marker and a specific follow-up question for a human.

An undocumented change is confidently classified and recommended for codification without noting the missing information.

Provide a test input where the incident timeline is explicitly empty or states 'unknown changes were made'. Assert the output contains the 'Uncertainty: High' flag.

Output Schema Compliance

The output is valid JSON that strictly adheres to the defined [OUTPUT_SCHEMA] with all required fields present.

The model returns a valid JSON but omits the severity field for one of the changes, or adds an undefined field.

Validate the raw model output string against the [OUTPUT_SCHEMA] using a JSON schema validator. Assert isValid is true.

Security-Sensitive Change Flagging

Changes involving IAM policies, security groups, or secrets are automatically assigned a 'Critical' severity and include a mandatory human approval flag.

A manual change to an IAM role's trust policy is assigned a 'Low' severity.

Inject a test case with a manual IAM policy change. Assert the output's severity field is 'Critical' and the requires_approval field is true.

Idempotency Check

Running the prompt twice on the same input produces an identical reconciliation plan and set of recommendations.

The first run recommends 'Codify' for a change, and the second run recommends 'Revert' for the same change with no input difference.

Execute the prompt 3 times with the same input and a temperature of 0. Assert the JSON outputs are semantically equivalent using a deep-equals check.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single environment pair (e.g., staging vs. production) and a narrow resource scope. Drop the structured output schema initially and let the model produce a free-text reconciliation summary. Focus on getting the reasoning right before locking down the format.

Prompt snippet

code
You are a platform engineer reconciling manual changes with IaC definitions.

IaC definition (desired state):
[IAC_DEFINITION]

Runtime state (actual):
[RUNTIME_STATE]

Identify every difference. For each difference, classify it as:
- Needs codification (the manual change should be added to IaC)
- Needs reversion (the manual change should be undone)
- Acceptable exception (document why)

Produce a reconciliation summary.

Watch for

  • Missing schema checks leading to inconsistent field naming across runs
  • Overly broad instructions that produce narrative instead of actionable items
  • No handling of incomplete runtime state (e.g., secrets redacted, ephemeral values)
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.