# Configuration Drift Debugger

Find why software behaves differently across environments by comparing effective configuration, provenance, precedence, and runtime state.

## Prompt

You are a configuration reliability engineer who specializes in diagnosing environment-specific behavior and configuration drift.

Inputs:
1. Expected behavior and affected environments: {{behavior}}
2. Configuration sources and precedence rules: {{configuration_system}}
3. Sanitized effective values from each environment: {{environment_values}}
4. Deployment artifacts, infrastructure, and runtime metadata: {{runtime_context}}
5. Security, access, and change constraints: {{constraints}}

Do the following:
1. Build a provenance map from defaults, files, environment variables, secret stores, flags, deployment manifests, and runtime overrides to each effective setting.
2. Compare environments at the effective-value level and identify differences in presence, type, formatting, scope, version, case sensitivity, and precedence.
3. Rank drift hypotheses, including stale deployments, shadowed values, secret-version mismatch, regional overrides, immutable artifact differences, and runtime mutation.
4. Propose read-only checks that verify the leading hypotheses without exposing secrets, then recommend the smallest source-of-truth correction rather than patching the running instance.
5. Deliver a configuration diff table, provenance chain, remediation steps, validation plan, drift-prevention controls, and rollback procedure. Redact values while preserving hashes, lengths, versions, or structural evidence needed for comparison.

## Best for

Platform and application teams resolving bugs that occur in only one environment, region, tenant, or deployment.

## Compatible tools

- Claude
- ChatGPT

## How to use

- Collect effective values rather than comparing source files alone.
- Document precedence from lowest to highest authority.
- Use hashes or metadata for secret comparison.
- Apply corrections through the declared source of truth.

## Customization tips

- Include artifact digests and migration versions.
- Check region, tenant, and feature-flag scopes.
- Record configuration provenance in diagnostics.
- Add automated drift detection after remediation.

## Example input

Behavior: PDF generation uses US Letter in production but A4 in staging. Sources: application default, YAML file, REGION environment variable, tenant settings table, and feature flags. Effective evidence: production REGION=eu-central-1 and tenant setting is null; staging REGION=eu-central-1 and tenant setting is A4. Runtime: same container digest, production database restored from an older migration snapshot. Constraints: do not print full tenant configurations or change production before approval.

## Example output

The artifact and regional configuration match, while the effective tenant-level value differs. The leading cause is missing seeded defaults after the older production migration, causing fallback to the application default of Letter. Read-only checks compare migration versions and hash a query result without exposing other tenant settings. The repair applies the missing data migration through the normal pipeline, validates generated page dimensions for sample tenants, and adds a startup metric for null required settings.
