numerical-care
Skill98 starsChanged 2 months agoMITView on GitHub
Handle numbers like they bite — float equality, currency arithmetic, rounding, allocations that must sum exactly, division by zero, overflow, unit mismatches. Use when writing or reviewing any arithmetic beyond a counter — money, tax, discounts, splits, percentages, averages, rates, coordinates, durations, unit conversion, aggregations, or comparisons of computed values.
In this repository38 other files it gives its agents.
- ambiguity-commitSkill
- api-surface-careSkill
- calibrated-recommendationSkill
- codebase-orientationSkill
- concurrency-reasoningSkill
- config-and-flagsSkill
- context-checkpointSkill
- cross-platform-careSkill
- data-loss-guardSkill
- data-migration-safetySkill
- dependency-changesSkill
- docs-as-contractSkill
- edge-case-sweepSkill
- environment-firstSkill
- error-message-qualitySkill
- escalate-vs-decideSkill
- estimation-and-scopingSkill
- explain-at-the-right-levelSkill
- generalize-the-correctionSkill
- git-hygieneSkill
- incident-diagnosisSkill
- leave-no-messSkill
- llm-app-codeSkill
- performance-investigationSkill
- perf-sanitySkill
- question-vs-taskSkill
- resource-lifecycleSkill
- reviewing-a-changeSkill
- root-cause-debuggingSkill
- security-reflexesSkill
- stop-thrashingSkill
- subagent-fanoutSkill
- surgical-refactoringSkill
- task-decompositionSkill
- test-designSkill
- untrusted-content-guardSkill
- verify-ui-visuallySkill
- workmanshipSkill
The file
Files
numerical-care
Numeric bugs pass every casual test and then misprice an order. Weak numerical work writes the formula and tests it with 10 and 20. Strong numerical work names the hazard on every arithmetic line and tests with the value that would expose it.
Standing hazards
- Never compare floats with
==.0.1 + 0.2 != 0.3. Compare within an epsilon scaled to the magnitude, or restructure to avoid the comparison. Tests assert almost-equal, not equal. - Money is integer minor units or Decimal — never binary floats. Match what the codebase already uses (find its existing money type before adding one); if it uses floats for money, flag that in the report rather than extending it.
- Rounding is a policy, not a default. Half-up, banker's, floor for "never overcharge" — pick deliberately, name it in a comment, and round once at the boundary (display or storage), not mid-calculation where errors compound.
- Allocations must sum exactly. Splitting a total across N parts, tax across line items, percentages that should total 100: compute the parts, then assign the remainder deliberately to a named part. Assert
sum(parts) == totalin a test. - Every
/needs a zero plan. Average of an empty list, percentage of a zero total, rate over a zero-length window: state what the result is (0, null, error) and handle it. Check integer vs true division where the language distinguishes them. - Representation limits: silent 32-bit wrap, IDs and timestamps beyond 2^53 in a double (keep big IDs as strings), precision loss on casts between types.
- Units travel with the value. ms vs s, cents vs dollars, bytes vs MB, degrees vs radians, percent vs fraction (
0.15or15?), percentage points vs percent change. Name variables with their unit (timeout_ms,rate_pct) wherever ambiguity is possible; convert at the boundary, never mid-formula. - Aggregations over floats depend on order and method. Summing many floats naively drifts; use the platform's compensated sum when it matters, and don't compare results produced by different aggregation orders.
- Time arithmetic is not integer arithmetic. A day is not 86400 s across DST; months vary; use the platform's date library for calendar math and monotonic durations for elapsed time.
Procedure
- Grep the diff for
/,*,-,+,==,<=,>=,round,floor,ceil,parseFloat,toFixedand check each hit against the list above. - For each arithmetic line ask: what value makes this wrong — zero, negative, huge, 0.1, or parts that sum to 100.01? Run that value, in a test or a one-off call, and compare against an expected value computed independently (by hand or by a different method), not against the code's own output.
- Report the rounding policy and units chosen, and any float-money or unit ambiguity found in existing code that you did not fix.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

