Correctness Review
ASecurityRead-only, line-by-line review for logic and calculation errors. Looks for wrong formulas (sign, units, cents, % versus fraction, float rounding in money, division by zero, average of averages), off-by-one, ranges, dates and time zones, inverted conditions, null, NaN, 0 or "" taken as valid, parsing, swallowed errors that return a false result, unit contracts between functions and code that contradicts its name, comment, test or docs. Each finding brings path:line, a concrete input, the expec...
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added November 17, 2026
Works with
Security analysis
100/100Pro scans all 4 files and shows the line behind each finding
npx -y skills add OmarAlex24/audit-skills --skill correctness-review --agent claude-codeAre you the author of Correctness Review?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/omaralex24-correctness-review)---
name: correctness-review
description: Read-only, line-by-line review for logic and calculation errors. Looks for wrong formulas (sign, units, cents, % versus fraction, float rounding in money, division by zero, average of averages), off-by-one, ranges, dates and time zones, inverted conditions, null, NaN, 0 or "" taken as valid, parsing, swallowed errors that return a false result, unit contracts between functions and code that contradicts its name, comment, test or docs. Each finding brings path:line, a concrete input, the expected and the actual output. Reports and stops. Use it for "check this math", "find logic bugs", "is this calculation right", "why doesn't the total add up?" or "check the rounding". Not for concurrency or retries (data-consistency), status lifecycles (implicit-state-machines), security (api-security-review), performance (perf-diagnosis) or structure (code-structure). Also triggers on Spanish requests such as "revisa la lógica", "¿este cálculo está bien?", "busca bugs en las fórmulas" or "¿por qué el total no cuadra?".
---
# Logic and calculation errors
This skill reads code line by line looking for what makes a calculation or a decision wrong with normal inputs: the formula that adds instead of subtracting, the range that leaves out the last day, the `0` treated as "no data", the `catch` that returns an empty total as if it were good. They are the bugs that pass review because the code "looks fine" and that nobody looks for when the audit is about concurrency, security or performance.
**No concrete input, no finding.** Each finding names an input (`price = 1999`, `from = 2026-03-31`, `items = []`), the output it should give and the one it gives, with the trace computed by hand line by line. "This rounding could fail" is a suspicion (Smell), not a finding.
Material: [references/signals.md](references/signals.md) (the W1 to W8 catalog and searches), [references/report-template.md](references/report-template.md) and [references/sources.md](references/sources.md).
**Provenance.** This project's Arjay McCandless videos do not cover this topic. Everything in this skill is **(added)**, established practice, or **(doc)**, checked in a language's documentation with its date in [sources.md](references/sources.md). Do not cite a video for this.
Write the report in the user's language.
## Rules
- **Read-only.** You modify nothing in the audited repo: no code, no git, no dependencies. **You never run the repo's code, scripts, tests or builds**, not even "just to see what it gives": they load configuration, open connections or write caches.
- **Your own snippet, outside the repo.** If you want to check a formula, you may run a minimal snippet **written by you** in a temporary directory outside the repo (`mktemp -d`), with the system interpreter and no dependencies. The snippet rewrites the formula by hand with the concrete input; it never imports or copies by path a module from the repo, because that is running the repo's code. Say so in the finding ("checked with my own snippet: …") and leave the method as `reading`: the evidence is still the trace over the code that was read.
- **The intent comes from something written.** A calculation is wrong if it contradicts its name, its comment, its test, the docs, a caller's contract or a written business rule. The name of a metric or of a standard term (Sharpe, median, p95, CAGR, VWAP, "last 24 h") counts as a written source: its established definition is what is correct, and you cite it in the finding (W8.4). If the only source of "correct" is your own assumption, the finding is a question.
- **Report first, apply only what the user picked** (phase 5).
- **Each topic in its own skill.** Two concurrent writes that overwrite each other, retries that duplicate and lost events belong to `data-consistency`; invalid `status` transitions or races between transitions, to `implicit-state-machines`; auth, injection, input validation as a defense and rate limiting, to `api-security-review`; slowness, N+1 and load, to `perf-diagnosis`; the same calculation duplicated several ways as a design problem, modules and layers, to `code-structure`; system design, to `architecture-review`; infrastructure config values (timeouts, replicas, limits in IaC or compose), to `infra-review`; an LLM's output used without validation, provider retries billed without being recorded and missing spending caps, to `llm-app-review`, except the cost arithmetic (tokens times price, units, rounding), which belongs here. What stays here is whether the calculation or the decision gives a wrong result. If a duplicated calculation diverges and one copy gets the total wrong, the wrong total belongs here and the duplication to `code-structure`. When a signal falls in another skill, note it under "Not covered" with the skill it goes to and do not develop it.
## Phase 0: scope and conventions
1. **Scope.** The one the user gave. In a large repo with no hint, ask which module or which flow (billing, invoicing, metrics, reports).
2. **Rules and docs.** Read AGENTS.md, CLAUDE.md, README, `docs/` and ADRs looking for the **unit conventions**: does money go in integer cents or in decimals? Times in ms or in s? Dates in UTC? Percentages as 15 or as 0.15? Which time zone does the business use for "the day"? Note them in a short table: it is the yardstick each calculation is measured against.
3. **Existing tests.** List where the tests for the logic you are going to review are. You do not run them: you read them, because a test fixes the intent (and sometimes contradicts it).
## Phase 1: map of calculations and decisions
Go through the scope with the "Quick map" searches in [signals.md](references/signals.md) and note, per file, the functions that:
- **compute**: totals, taxes, discounts, commissions, averages, rates, percentages, currency or unit conversions, scores, pagination, installments, interest;
- **decide**: threshold comparisons, eligibility, limits, time windows, date filters;
- **convert**: parsing numbers, dates and currencies from strings, JSON, CSV, query params or environment variables; output formatting;
- **cross a contract**: call another function, a service or the database with a value that has a unit or a format.
For each one, one line: inputs with their unit, output with its unit, who calls it and where "correct" comes from (name, comment, test, docs). Read the money ones and the hot path ones first; then the ones with the most callers.
## Phase 2: walk the signals
With the map, go through [signals.md](references/signals.md) function by function:
- **W1** formulas and arithmetic: sign, order of operations, units, cents, percentage versus fraction, float and rounding in money, division by zero, average of averages, overflows and integer division;
- **W2** bounds: off-by-one, inclusive or exclusive ranges, indexes, pagination, dates, end of month, leap years, time zones, daylight saving time;
- **W3** conditions: inverted, `&&` versus `||`, precedence, an `else` that covers more than it should, a `switch` with no `break` or no default case, comparisons that do not compare what they seem to;
- **W4** empty values: `null`, `undefined`, `NaN`, `0`, `""`, `[]` treated as a valid value or as "no data" when they are the other;
- **W5** parsing and conversions: `parseInt` with no radix, decimal comma, strings added as text, dates parsed in the wrong zone, truncation when converting types;
- **W6** swallowed errors and misleading defaults: a `catch` or `except` that returns `0`, `[]` or the previous value as if it were a good result, `?? 0` or `or 0` hiding a missing value;
- **W7** contracts between caller and callee: units, formats, argument order, 0-based or 1-based indexes, the sign of a discount;
- **W8** code that contradicts its name, its comment, its test or the docs.
For each candidate, **build the input** before going on: the simplest value that triggers the defect and that a real caller can pass (look for it in the callers, the schema, the tests or the docs).
## Phase 3: verify and try to rule out
For each candidate:
1. **Concrete input**: the exact values of the arguments and of the state that matters, and where it comes from that a caller can pass them (`path:line` of the caller, the schema or the input validation).
2. **Trace by hand**: line by line, with the value of each variable after each step, each one with its `path:line`. For floats, write the value that really remains, not the decimal it looks like.
3. **Expected versus actual**: what should come out, according to which written source (name, comment, test, docs, contract), and what comes out.
4. **Try to rule it out**: a validation earlier that prevents that input; a caller that always normalizes; a test that fixes that behavior on purpose; a written business rule that accepts it ("rounds down"); dead code. If what prevents it lives elsewhere and is fragile (a client-side validation only), the case drops to Smell and you name that guarantee.
5. **Label**: **Confirmed** if you read every step of the trace and the input comes from a real caller; **Likely** if a step depends on something that cannot be read in the repo (the server's time zone, the locale, the real value of an environment variable, the format a provider sends), and you name it in `unverified_step`; **Smell** if you have no concrete input or no real caller passes it today.
6. **Impact and severity**: what goes wrong, for whom, how much (a cent per line, one extra day in a window, a charge at 100% instead of 1%) and whether it can be repaired. Severity with the template's scale.
Rule out the healthy candidates in one line: "reviewed, does not happen because…" with its `path:line`. A report that shows what it ruled out is more credible.
## Phase 4: lightest fix, test, report and stop
For each finding:
- **Fix**: the smallest change that makes the calculation or the decision correct, following the phase 0 conventions (`Math.round(x * 100)` instead of moving everything to a decimal library; `<=` instead of `<`; an explicit radix in `parseInt`). If the fix changes a persisted value or a contract, say so: it is a risk.
- **Risk**: data already stored with the old calculation, historical reports that change, clients that depend on the wrong value.
- **Test**: the unit test that catches it, with the same concrete input and the expected output; the neighboring edge cases (the one before and the one after the boundary); if the value comes from outside, the test with that format.
- **Effort**: S, M or L.
Write the report with [report-template.md](references/report-template.md), end by asking what to apply, with your recommended order, and offer in one line to save the report to a file. **Then stop**, even if the request said "fix it".
## Phase 5: apply (only what the user picked)
Confirm in one line what you are going to apply. Then, one by one: write the test with the concrete input and watch it fail for the expected reason, apply the fix, watch it pass and run the project's checks (lint, typecheck, tests). Report each command with its result and name the ones you could not run. This is the only phase in which anything from the repo runs, and only with the user's permission. No commits, push or PRs unless asked.
## Common mistakes
- Reporting with no concrete input: "if `total` were negative…" with no caller that passes it is a suspicion.
- Computing the trace from memory. Every cited line was read in this session; every intermediate value is written down.
- Taking what the name says as correct and the code as wrong, or the other way around, with no other source. If the test and the code agree and the name does not, the name may be what is wrong: say so.
- Proposing a decimal library or a date redesign as the first fix.
- Running the repo's code to "see what it gives". The snippet is yours, outside the repo and importing nothing from the repo.
- Mixing topics: a race between two writes is not a calculation error even if the final balance ends up wrong; it belongs to `data-consistency`.
## Swarm mode
It turns on when the invocation brings a swarm brief (between `[swarm brief]` and `[end of brief]`), with `contract:`, `map:`, `structure:`, `output:` and `data:`. Used on its own, the skill follows the procedure above unchanged, report included. In this mode:
- **Phases:** follow phases 0 to 3 and, from phase 4, only the lightest fix, its risk, the test and the effort; you apply nothing. The brief's map replaces reading the rules and docs in phase 0, but read what the map points to (unit conventions, claims in the docs) and whatever it is missing. The concrete input, the expected and the actual output go in `sequence`, one step per element ("Input: …", "path:line: …", "Expected: … according to …; actual: …"); the test, in `test`. With no concrete input, the confidence is Smell.
- **No questions and no waiting:** what you would ask the user goes to the `questions` field; you do not stop to wait for an answer.
- **No subagents or reviewers:** the swarm does the independent verification. Make the pass that tries to rule out each finding yourself, prioritize by the map's hot paths and by the code that handles money, and declare in `not_covered` what you did not cover.
- **Data:** you do not need it. You never open connections, tunnels or scripts of your own against a database, and you do not read `.env` looking for credentials. What you would have queried goes to `requested_measurements`.
- **Your own snippet:** still allowed, but in swarm mode it goes inline (`python3 -I -c '…'` or `node -e '…'`), with a temporary directory outside the repo as the working directory and without writing any file, so as not to break the output rule below. Rewrite the formula by hand; never import anything from the repo.
- **Slice:** if the brief brings `slice:`, you only report findings whose main location (`locations[0]`) is in that slice; the membership rule is in the brief and other auditors of this same skill have the other slices. You may open files outside it only to follow a sequence that starts in your slice, and each one goes to `outside_slice` with the reason. A defect that starts outside is not yours: at most, one line in `not_covered` with its path:line. The slice section (`slice map:`) completes the global map. What the brief marks in `exclude:` belongs to no slice: you do not audit it, do not cite it as evidence and do not report anything whose main location falls there; you may open it only to understand a call that leaves the scope, and then it goes to `outside_slice` with the reason.
- **Limits:** you do not modify the audited repo and you do not read other audit runs or other auditors' folders, except what the brief gives you: contract, map, `structure:` and your folder.
- **Metric:** fill `metric` in each finding per `before-after.md` (next to the contract the brief gives), with this skill's row of its "Guide per skill" as the hint: the finding's concrete input, with what is obtained against what is expected, or how many cases of a property test fail. A metric is a command that is run again, never a count of findings, and you do not invent its result: `{not_measurable: "<why>"}` is valid.
- **Output:** a single file, `findings.json`, in the folder the brief gives (`your folder:`), with the contract's object, and that same object as your answer. In swarm mode you write no readable report and no other file: the report template is for normal mode and the swarm's plan comes from the `findings.json` files. Use the contract's vocabulary: confidence, method, severity, effort and action.
Files in this skill
- SKILL.md
- references/report-template.md
- references/signals.md
- references/sources.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.