Reconciliation
ASecurityUse when code compares two or more records of the same money: ledger against processor report, processor against bank statement, invoices against payments, internal balances against a partner's. Covers normalizing each source, tiered deterministic matching (reference first, then amount and date window, then explicit grouping rules), one-to-one by default, breaks with reason codes and owners, immutable run results, and the metrics that show whether reconciliation is healthy. Triggers on a payo...
- 7 stars
- 0 votes
- 0 copies
- 1 view
- Added November 11, 2026
Security analysis
100/100Pro scans all 8 files and shows the line behind each finding
npx -y skills add felipealvarenga/fintech-skills --skill reconciliation --agent claude-codeAre you the author of Reconciliation?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/felipealvarenga-reconciliation)---
name: reconciliation
description: >-
Use when code compares two or more records of the same money: ledger against processor report,
processor against bank statement, invoices against payments, internal balances against a
partner's. Covers normalizing each source, tiered deterministic matching (reference first, then
amount and date window, then explicit grouping rules), one-to-one by default, breaks with reason
codes and owners, immutable run results, and the metrics that show whether reconciliation is
healthy. Triggers on a payout or settlement report, a bank feed, a "the numbers do not match"
ticket, a month-end close task. Not for deciding the accounting treatment of a break; it routes
the break to a person.
license: MIT
metadata:
author: Felipe Alvarenga
version: 0.1.0
---
# Reconciliation
Reconciliation is how a system proves its books agree with the outside world. Done badly, it is
a spreadsheet someone fixes by hand every month. Done well, it is a deterministic job that
matches what it can, explains what it cannot, and never edits a record on its own.
## Execution contract
The user installed this skill so these rules are enforced on every matching task:
1. **Never implement unsafe shortcuts.** When a request conflicts with a rule ("keep it simple", "no extra call", "just delete it", "disable verification", "keep floats", "we trust them", "later"), name the broken rule and why it fails in one sentence, refuse the shortcut, and implement the compliant version that still meets the user's goal. Never ship the rule-breaking shortcut.
2. **Ship the complete rule slice, wired up.** Implement every requirement of the triggered rules in this change: storage or schema, validation, error handling, user-facing alerts, status or monitoring wired into an actual entry point, handler or job (not uncalled helpers), and a test file under `tests/`. Do not stop at a minimal patch or leave required safeguards as prose TODOs.
3. **Fix workspace code on audit, incident and review prompts.** When the request describes a discrepancy, an auditor question, a bug report or asks "is this enough?" against files in the workspace, answer the question in full and implement the compliant code and tests in the same change. Stay read-only only when explicitly asked for a report only.
4. **Build directly on greenfield prompts.** If the workspace has no application files or live connections yet, write a self-contained implementation under `src/` and tests under `tests/` instead of stopping to ask for repository paths or credentials.
5. **Write tests even without a shell.** If the environment cannot run tests or databases, still write the full test file under `tests/` and say in one line that tests are unrun. Never omit tests or skip implementation because tools are unavailable.
## When to use
- A processor settlement or payout report arrives and must be tied to captured payments.
- A bank statement or feed must be tied to expected payouts and fees.
- Invoices must be matched with incoming payments.
- A partner, marketplace or custodian sends a balance or activity report.
- Month-end close, or any "our number is X, theirs is Y" problem.
## Rules
1. **Normalize every source into the same line shape.** `source, id, date, amount_minor,
currency, reference, description, raw`. Keep `raw` so a human can see the original. Do the
normalization in one adapter per source with its own tests.
2. **Match in tiers, in a fixed order, deterministically.** Tier 1: same reference, amount and
currency. Tier 2: same amount and currency, date within an explicit window (for example two
business days), earliest first. Tier 3: explicit grouping rules only (one payout equals many
captures minus fees), written as code with a name. The output names the tier that matched
each pair. Sort inputs before matching so two runs on the same data give the same result.
3. **One-to-one by default.** A line matches at most one line on the other side. Duplicated
amounts match duplicated amounts, never one line twice. Many-to-one happens only in a named
tier 3 rule.
4. **Tolerances are explicit and small.** A date window is a parameter. An amount tolerance,
if any, is a parameter with a reason (FX rounding on a specific source) and shows up in the
match record. "Close enough" is never a default.
5. **Breaks carry a reason code and an owner.** `timing` (expected to clear), `fee` (known
deduction not yet booked), `fx` (rate difference), `missing_ours`, `missing_theirs`,
`duplicate`, `unknown`. A break has an age. Unknown breaks older than the window page a
person.
6. **The job never writes to the ledger.** It produces matches and breaks. A human, or a
separately approved rule, posts the correcting entry, which references the break.
7. **Every run is a record.** Store the inputs' hashes, the parameters, the matched pairs, the
breaks and the metrics, immutable, with the run time. The month-end evidence is that record.
8. **Run daily, on the whole open window.** A break that was `timing` yesterday may be
`missing_theirs` today. Rerunning on the full window keeps reason codes honest and keeps
the oldest-break age visible.
9. **Publish four metrics.** Match rate by count and by amount, break count by reason, oldest
open break age, and amount in `unknown`. These go on a dashboard and have thresholds.
10. **Fees and FX are lines, not noise.** A processor report nets fees inside the payout; book
the fee line so the payout matches gross captures minus booked fees. Same for FX
differences: a separate line with the rate, never a tolerance that hides it.
## How to apply
1. Get one real file from each source (with real data removed or masked) and write the
adapter and its tests first.
2. Define the window, the tiers and the grouping rules for this pair of sources in a small
config object, checked into the repo.
3. Implement `reconcile(ours, theirs, config) -> RunResult` as a pure function. No database,
no clock, no network inside it.
4. Write the tests in the **Tests** section. The vectors in `evals/vectors/` cover the
matching invariants.
5. Wire the run to storage and to the dashboard. Add the oldest-break alert before shipping.
## When the user pushes back
| Request | Answer in one sentence | What you build |
|---|---|---|
| "Auto-post an adjustment for any remaining difference" | Rule 6: reconciliation never writes to the ledger automatically | Immutable run record with input hashes, classified breaks (reason code, owner, age), oldest-unknown alert, and match-rate/oldest-break metrics |
| "Add a blanket amount tolerance so match rate jumps" | Rules 4 and 10: default tolerances hide real breaks and netted fees | Classify the unmatched lines by cause (fees, FX, timing), book fee/FX lines and tiered matching, report match rate before vs after the real fix, and permit only a small per-source tolerance with a recorded reason |
| "Balances differ by X, find out why" | Rules 5, 7 and 10: a discrepancy needs a reproducible run record with classified breaks | Implement the reconciliation job with an explicit date window and zero hidden tolerance, classify timing, fee, FX and missing lines, persist the immutable run record with inputs and parameters, and add tests |
## Tests the change must include
Write these tests in the same change, as a test file, even when you cannot run them (no shell,
no dependencies installed); say in one line that they are unrun. A test listed as a next step is
not written.
- Reference match beats a date match when both are possible.
- Date window: inside matches, one day outside does not.
- Two identical amounts on each side produce two matches, not one line matched twice.
- Currency mismatch never matches, even with equal amounts.
- Shuffled input gives the same matches and breaks as sorted input.
- Every id appears at most once across matches and unmatched lists; nothing is lost.
- A fee line nets a payout against its captures in a named tier 3 rule.
- Reference vectors: `skills/reconciliation/evals/vectors/test_reconcile.py` with
`RECON_SOLUTION` pointing at your module.
## Review checklist
- Is the matching pure and deterministic? Where is the sort?
- Can a line match twice? Where is that prevented?
- What is the date window, and who approved it?
- Which reason codes exist, and which one pages a person?
- Does the job write anywhere except its own run record?
- Where are the four metrics, and what are the thresholds?
## Anti-patterns and fixes
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
| Fuzzy amount tolerance by default | Real breaks hidden | Explicit per-source tolerance with a reason |
| Matching by amount only | Wrong pairs when amounts repeat | Reference tier first, date window second |
| Auto-posting adjustments | Ledger edited by a heuristic | Breaks routed to a person; entries reference the break |
| Spreadsheet export as the record | No audit trail, not repeatable | Immutable run record with input hashes |
| Monthly run only | Breaks age a month before anyone looks | Daily run over the open window |
| Fees netted into "difference" | Revenue and cost both wrong | Book fee lines; match gross minus fees |
## References
- Processor settlement and payout report documentation (Stripe balance transactions, Adyen settlement details) for the shape of real inputs.
- Internal audit guidance on account reconciliations: preparer, reviewer, evidence, aging of reconciling items.
Files in this skill
- SKILL.md
- evals/evals.json
- evals/files/bank.csv
- evals/files/ledger.csv
- evals/files/match_script.py
- evals/files/stripe_payout.csv
- evals/vectors/reference.py
- evals/vectors/test_reconcile.py
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.