Skip to main content
skill CX Codex

differential-audit — Claude Code skill: comparison and setup

Audits two implementations of the same logic, tracking differences in outputs, warnings, and failures. Useful for language ports, research replication, refactors, and release checks.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add pedrohcgs/claude-code-my-workflow --skill differential-audit -a claude-code
Open on GitHub

What differential-audit does

The differential-audit skill defines a structured review for two implementations of the same behavior. Typical cases include translating an R package into Python, reproducing a research project, or checking a replacement against an older release. Before running comparisons, establish the reference implementation and freeze the code and package versions, input data, random seeds, configuration choices, expected outputs, and acceptance thresholds. An output inventory then makes omissions visible on both sides.

Comparison rules depend on the result type. Names, ordering, sample masks, counts, and status codes require exact agreement after documented normalization. Numeric results use justified absolute and relative tolerances, while vectors, matrices, and stochastic outputs need suitable checks of their own. Warnings, diagnostics, and failure behavior count too. The comparator must first face deliberately broken cases, including an incorrect value, a missing result, misaligned rows, and empty output. It must report these failures rather than silently pass them.

Each discrepancy receives a stable identifier, a minimal reproducible witness, and a classification: defect, intentional difference, reference limitation, or unresolved issue. Fixes must pass both the focused witness and the full audit again. The protocol also calls for independent reviewers to contribute unseen test designs and for scientific and implementation reviews to sign off separately.

What it helps with

  • compare an R implementation with its Python port
  • check whether a replication package reproduces expected results
  • identify regressions between old and refactored code
  • catch missing outputs and faulty comparison logic
  • document differences before approving a release

Example prompts for the agent

  • Audit the R and Python implementations against the same frozen inputs and settings, then report every mismatch.
  • Compare this release with the previous version, including output ordering, warnings, diagnostics, and failure statuses.
  • Challenge the comparator with missing results and incorrect values, then produce minimal reproducible cases for each discrepancy.

How to install differential-audit

1Skills CLI (Vercel)

npx skills add pedrohcgs/claude-code-my-workflow --skill differential-audit -a claude-code

2Manually: put the files in place

~/.claude/skills/differential-audit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/differential-audit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about differential-audit

How do I install differential-audit in Claude Code?

Run npx skills add pedrohcgs/claude-code-my-workflow --skill differential-audit -a claude-code. The skill file is located at ~/.claude/skills/differential-audit/SKILL.md.

What does differential-audit do?

It guides a contract-based comparison of two implementations, covering numeric outputs, data structure, warnings, and failures. It also requires reproducible evidence for each discrepancy.

Does matching output prove that the implementation is correct?

No. Agreement shows that both implementations conform to the frozen contract. They can still share the same defect, and the audit does not validate the method or its assumptions.

Source text

SKILL.md · MIT
---
name: differential-audit
description: Compare two implementations of the same thing — a port (R↔Python↔Stata), a reimplementation, a replication package, a refactor, or a new version against the old — so that agreement means something. Freeze inputs first, inventory every expected output, test the comparator itself, compare every channel (not just the headline number), and give each divergence a stable ID and a smallest witness. Use for cross-language parity, replication, upgrade/regression gates, or whenever "the numbers match" is about to license a claim.
allowed-tools: ["Read", "Grep", "Glob", "Bash", "Write"]
metadata:
  protocol: implementation-fidelity
---


# Make agreement mean something

Two implementations agreeing proves they satisfy a **prespecified contract**. It does not prove either is correct, and it never validates the method or its assumptions. Both can be wrong in the same way — especially when one was written by reading the other. Design the comparison so that agreement is informative and disagreement is legible.

**Rule: freeze before you compare; test the comparator before you trust it.**

## 1. State the claim and the reference

Write down: what is being compared, which side is the reference, and **what agreement would and would not establish**. "Matches the R package" is a conformance claim, not a correctness claim. Say so explicitly, so nobody later reads parity as validation.

## 2. Freeze the inputs before inspecting anything

Record and fix: data versions or hashes, code and package versions, random seeds or realized sample splits, options and defaults, the outputs to be compared, and the acceptance thresholds. Freezing *after* a first look invites tolerance drift toward whatever the run produced.

Do **not** compare defaults across systems as if only the language changed. Map the choices explicitly — a "default" is a substantive modeling decision that usually differs between implementations.

## 3. Declare tolerance classes, and make them binding

Do not carry a single fuzzy epsilon. Classify each output:
- **EXACT** — names, ordering, sample masks, counts, statuses, return/error codes, warning classes, option defaults. Byte-equal after documented normalization.
- **Scalar numeric** — deterministic estimates, standard errors, p-values, critical values. State absolute and relative tolerances and the justification.
- **Matrix/vector** — covariance matrices, influence summaries, weight vectors, plot data.
- **Stochastic** — must meet a prespecified error-rate criterion with uncertainty reported.

A looser tolerance may be used **only through a recorded approved divergence** with a reason. Silent widening is the most common way a parity gate stops testing anything.

## 4. Crosswalk and output inventory

Write the mapping between the two implementations, plus an inventory of every expected output with expected row/cell counts. Every declared object must have a **live comparison or an explicit out-of-scope reason**. Without an inventory, both sides can silently omit the same result and the comparison reports success.

## 5. Build cases that isolate mechanisms

Not just the happy path:
- analytically solvable or known-truth cases;
- relevant data problems (missing, unbalanced, near-collinear, extreme-but-valid weights, shuffled row order, ties);
- **compound** cases combining several problems;
- published examples;
- randomized valid designs across the supported surface, not a handful of fixtures.

Fixed fixtures are necessary but not sufficient — they test what the author already thought of.

## 6. Test the comparator itself

Before trusting a green result, feed the comparison a wrong value, a missing result, a misaligned row, and an empty result. **It must fail, not skip.** A comparator that silently passes over what it cannot reconcile turns every subsequent green into noise. (See `vaccinate`.)

## 7. Compare every declared channel

Not only the headline coefficient: estimates, uncertainty measures, sample counts, labels and ordering, diagnostics, warnings, and failure statuses. Divergent warnings and differing error behavior are real defects — they change what a user does next.

## 8. Give every divergence an ID and a smallest witness

For each difference: a stable identifier, the smallest reproducible case, and a classification — **defect / intentional difference / limitation of the reference / unresolved**. Unresolved stays red; it is not averaged away or waived. A fix must turn its witness green **and** survive a rerun of the full audit, so a local patch does not break something else.

## 9. Adversarial expansion by someone else

Fixtures written by the implementer test the implementer's mental model. Have an independent reviewer add designs **not shared in advance**, and preserve any that reveal bugs or materially increase coverage as permanent fixtures. This is the cheapest defense against a suite that passes because it was written to pass.

## 10. Close with separate reviews and an honest scope statement

End with distinct scientific and implementation sign-off, recording: checks run, open findings, accepted differences, explicit non-claims, and who approved release. State plainly that the audit establishes conformance to the frozen contract — not the truth of the method.

## Minimum checklist

1. Name the reference; state what agreement would and would not establish.
2. Freeze versions, hashes, seeds, options, outputs, tolerances.
3. Declare binding tolerance classes; record any approved divergence.
4. Crosswalk + expected-output inventory with counts.
5. Known-truth, dirty, compound, and randomized cases.
6. Seed comparator faults — it must fail, not skip.
7. Compare all channels, including warnings and failures.
8. Stable ID + smallest witness + classification per divergence; unresolved stays red.
9. Independent reviewer adds unseen designs.
10. Separate sign-offs; state the non-claims.

## Cross-references

- [`provenance-and-ground-truth.md`](../../references/provenance-and-ground-truth.md) — ranked oracles, declared precedence, the divergence taxonomy
- [`.claude/rules/replication-protocol.md`](../../rules/replication-protocol.md) — the tolerance contract

© pedrohcgs · MIT · pedrohcgs/claude-code-my-workflow

Similar skills

All skills for Testing and QA →

From the same set56

interview-me Runs a multi-turn interview and turns a half-formed research idea into a structured spec: question, hypotheses, identification, data, empirical strategy. CX Codex +1 ★ 1,671repo stars humanize Audits LaTeX, Quarto, and Markdown drafts for recognizable AI phrasing patterns. Generates a structured issue report before journal submission. CX Codex +1 ★ 1,671repo stars grant-proposal Turns an existing research spec into a structured grant proposal draft. Use it to prepare an application for NSF, NIH, ERC, or a foundation. CX Codex +1 ★ 1,671repo stars disclosure-check Pre-screens tables, figures, and logs for statistical disclosure risks before export from secure data enclaves. Catches small cell counts, dominance issues, and PII leaks. CX Codex +1 ★ 1,671repo stars diagnose Walks a failing run from a stable reproduction to a minimal example, ranked hypotheses and a fix. Built for research code. CX Codex +1 ★ 1,671repo stars devils-advocate Challenges lecture decks from a skeptical student's perspective with five to seven targeted critiques on narrative flow and cognitive load. CX Codex +1 ★ 1,671repo stars deploy This skill renders Quarto slides as HTML and syncs the output to docs/ for GitHub Pages. Use it when edited slides are ready to publish. CX Codex +1 ★ 1,671repo stars deep-audit Splits a theory, proof, paper or codebase into components, fans out independent skeptics and fixes every confirmed defect. Built for when one review pass is not enough. CX Codex +1 ★ 1,671repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor