differential-audit

Compare two implementations of the same computation across languages, versions, or replications.

1.5k|3.0k|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/pedrohcgs/claude-code-my-workflow --skill differential-audit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: differential-audit
Source: https://github.com/pedrohcgs/claude-code-my-workflow/tree/main/.claude/skills/differential-audit
Command: npx skills add https://github.com/pedrohcgs/claude-code-my-workflow --skill differential-audit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When you port code between R, Python, or Stata, reimplement a method, or upgrade a package, a green "numbers match" check often means nothing — tolerances drift, comparators silently skip mismatches, and both sides can share the same bug. This Skill turns implementation comparison into a rigorous audit where agreement is actually informative.

Core Features & Use Cases

  • Frozen comparison contract: Fix data hashes, versions, seeds, options, and binding tolerance classes (EXACT, scalar numeric, matrix, stochastic) before inspecting any output.
  • Comparator self-testing: Seed deliberate faults — wrong values, missing results, misaligned rows — to prove the comparison harness fails loudly instead of silently passing.
  • Full-channel divergence tracking: Compare estimates, standard errors, warnings, error statuses, labels, and ordering; give every divergence a stable ID, smallest witness case, and a defect/intentional/unresolved classification.
  • Use Case: You ported an R econometrics package to Python. Use this Skill to build a cross-language parity gate with known-truth cases, randomized designs, and independent adversarial fixtures before claiming the port matches.

Quick Start

Use the differential-audit skill to design a parity audit comparing my Python port against the original R implementation.

Frequently Asked Questions about differential-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I verify an R to Python code port produces identical results?

Freeze data hashes, package versions, seeds, and tolerances first, then compare every output channel — estimates, standard errors, warnings, and error statuses — not just headline numbers. Test the comparator itself by feeding it known-wrong values to confirm it fails rather than skips.

What tolerance should I use when comparing numeric outputs across languages?

Classify outputs into binding tolerance classes: EXACT for names, counts, and statuses; stated absolute and relative tolerances for scalar numerics; and prespecified error-rate criteria for stochastic outputs. Never widen a tolerance silently — record it as an approved divergence with a reason.

Why does my comparison test pass even when the implementations differ?

Comparators often silently skip results they cannot reconcile, turning every green result into noise. Vaccinate the harness by feeding it a wrong value, a missing result, a misaligned row, and an empty result — it must fail on each, not skip.

Can matching outputs prove my reimplementation is correct?

No. Agreement only proves both implementations satisfy the same prespecified contract; both can be wrong in the same way, especially if one was written by reading the other. State explicitly that the audit establishes conformance, not correctness of the method.

What test cases should a replication or parity audit include?

Include analytically solvable known-truth cases, dirty-data problems like missing values and near-collinearity, compound cases combining several problems, published examples, and randomized valid designs. Have an independent reviewer add unseen fixtures to avoid testing only the implementer's mental model.