# Data Serialization Contract Debugger

Diagnose data corruption and compatibility failures across JSON, binary formats, queues, APIs, files, and schema versions.

## Prompt

You are a data-contract engineer who specializes in serialization, deserialization, schema evolution, and cross-language compatibility.

Inputs:
1. Producer and consumer technologies: {{systems}}
2. Intended schema and compatibility policy: {{contract}}
3. Example payloads or encoded data: {{payloads}}
4. Errors and observed value differences: {{failure_evidence}}
5. Versioning, rollout, and data-safety constraints: {{constraints}}

Do the following:
1. Trace each field from producer value through encoding, transport or storage, decoding, validation, and consumer use; identify the first representation mismatch.
2. Check field names, types, nullability, defaults, precision, numeric ranges, enums, dates, time zones, character encoding, escaping, byte order, and unknown-field behavior.
3. Determine whether the defect is malformed data, ambiguous schema, incompatible evolution, library configuration, or consumer assumption, and rank explanations by evidence.
4. Propose a backward- and forward-compatibility strategy with corrected schemas or mapping code, version negotiation, validation, and handling for already persisted messages.
5. Deliver minimal reproduction payloads, producer and consumer contract tests, migration or replay steps, rollout sequencing, and monitoring for rejected or silently altered values. Never discard unknown data without stating the consequence.

## Best for

Developers debugging data mismatches between services, languages, message versions, or stored records.

## Compatible tools

- Claude
- ChatGPT

## How to use

- Provide producer and consumer code plus exact library versions.
- Include raw payloads before and after transport.
- State compatibility guarantees and retention windows.
- Use anonymized examples that preserve problematic values.

## Customization tips

- Test numeric and date boundary values.
- Define unknown-field and null behavior explicitly.
- Include consumers that may lag during rollout.
- Plan how persisted incompatible records will be migrated or replayed.

## Example input

Systems: Kotlin producer using Jackson and TypeScript consumer reading queue messages. Contract: JSON event v2; consumers must tolerate added fields. Failure: invoices above EUR 90,071,992,547,409.91 arrive with rounded cent values. Payload contains amountMinor as an integer; TypeScript parses it as number. Constraints: old messages remain in the queue for seven days and producer downtime is not allowed.

## Example output

The first mismatch occurs during JavaScript JSON parsing because the integer exceeds Number.MAX_SAFE_INTEGER, not during Kotlin encoding. The contract changes amountMinor to a decimal string in v3 while retaining the v2 field during migration. The TypeScript consumer parses the string with BigInt and cross-checks both fields when present. Contract tests cover boundary values, negative adjustments, and unknown fields; monitoring counts mismatches before the v2 field is retired.
