money-math-invariants
Lint checklist for money fields in a billing subsystem.
Skill by signalo-rust
Chalk Labs
Need help deploying money-math-invariants?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/signalo-rust-money-math-invariants-9bf355
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, writing, finance
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/money-math-invariants
What's inside
- Skill name
money-math-invariants- Description
- Lint checklist for money fields in a billing subsystem. Activates on any edit to payment/billing modules, shared billing types, or pricing/checkout UI. Verifies 6 money-math invariants that a typecheck does not catch.
- License
- MIT
- Instructions
- 185 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Money Math Invariants
This skill codifies **6 money-math invariants** whose violation produces bugs like "profit shows $498,669", "'—' in the payment history", or "the AI tells the user they paid $9.90 instead of $990".
Each invariant is a **class of bug** that a typecheck does not catch, because the violation happens at a seam: name ↔ unit, Prisma ↔ JSON, frontend ↔ backend, seed ↔ schema.
> The convention below uses a currency suffix to encode the unit in the field name: `*Dollars` holds a major unit, `*Cents` holds a minor unit (1/100). Substitute your own currency, but keep the principle — **the name must not lie about the unit.**
## When to activate
Any edit to a file in one of these zones:
- payment / checkout service modules
- admin billing / billing-adjustment services
- LLM/agent data-source files that surface billing context
- shared billing/pricing type packages
- admin billing pages, organization/user detail pages
- account billing settings pages, public pricing page
- database seed scripts and one-off migration/update scripts
## The 6 invariants
### Invariant 1: "Field name = unit of its contents"
**Rule:** if a field is named `*Dollars` it stores dollars; if `*Cents` it stores cents. **The name must not lie about the unit.**
**Example violation:**
```ts
// schema.prisma
model Plan {
priceMonthlyDollars Int // ← name says "Dollars", but it stored 499000 (cents) for $4990
}
```
**Check:** for every `*Dollars` field — contents × 1.0 = dollars (not × 0.01 = cents divided by 100).
**How to verify:** a runtime test with sample values + a grep for `*Cents` in any DTO that flows to the UI.
### Invariant 2: "Decimal does not go into JSON directly"
**Rule:** the Prisma `Decimal` type is a `Prisma.Decimal` object (a Decimal.js wrapper). When serialized to JSON it becomes `{d:[4990],e:3,s:1}` or a string `"4990"`, **not a number**. The frontend expects a number → gets garbage.
**Example violation:**
```ts
// billing.service.ts
return {
amountDollars: p.amount, // ← Decimal object, not number. Frontend receives {d:[4990]...}
};
```
**Correct:**
```ts
return {
amountDollars: p.amount.toNumber(), // ← number
};
```
**Check:** for every `prisma.X.findMany().select(...)` where the select contains a money field — the DTO map must call `.toNumber()` on it.
**Grep:**
```bash
# Find Decimal money fields without .toNumber():
grep -rn "amount\b\|priceMonthlyDollars\b\|unitPriceDollars\b\|amountDollars\b" \
src --include="*.ts" | grep -v ".spec.ts" | grep -v ".toNumber()"
```
### Invariant 3: "No `/100` in the UI layer"
**Rule:** the frontend never divides by 100. The cents↔dollars conversion happens **only at the API boundary** (Prisma read/write in the backend). The UI receives dollars as a ready `number`.
**Example violation:**
```tsx
// organizations/[id]/page.tsx
Math.round(s.plan.priceMonthlyDollars / 100) // ← /100 in UI, divides twice
```
**Correct:**
```tsx
s.plan.priceMonthlyDollars // ← already dollars, no /100
```
**Check:** `grep -rn "/ 100\|/100\b" web/ --include="*.tsx" --include="*.ts" | grep -v ".next"` — results must not contain money-related variables (`amount`, `price`, `cost`, `*Dollars`, `*Cents`).
**Exception:** percentages (`discount / 100 * 100`) are OK.
### Invariant 4: "Frontend ↔ backend DTO names match"
**Rule:** the field name in the backend DTO interface = the field name in the frontend type. If the backend sends `amount`, the frontend must read `amount` (not `amountDollars`).
**Example violation:**
```ts
// backend: SerialisedPayment.amount: number
// frontend: BillingPortalState.payments[].amountDollars: number
// → frontend reads amountDollars → undefined → "—" in UI
```
**Check:** for every admin/account/public endpoint, diff the type in shared-types VS the type in the frontend API client VS the interface in the backend service.
A name mismatch is a BLOCKER, not cosmetic. Prefer converging on one name on either side (ideally `*Dollars` for money, with the unit in the name).
### Invariant 5: "Seed scripts use the same units as the schema"
**Rule:** values in seed and one-off migration scripts must match the current type in the schema. After a rename `Int (cents) → Decimal (dollars)`, seed values change `99000 → 990`.
**Example violation:**
```ts
// seed.ts (after the migration but without updating seed)
{ slug: "personal-start", priceMonthlyDollars: 99000 } // ← now this is $99,000, not $990
```
**Correct:**
```ts
{ slug: "personal-start", priceMonthlyDollars: 990 } // ← dollars, as in schema
```
**Check:** on any money-field rename in schema — `grep -rn "<fieldName>" prisma/` and walk every occurrence.
**Especially dangerous:** seed scripts are often **outside tsconfig** → typecheck does not see them. They only fail on `db:seed` against a clean DB, usually weeks after the schema change.
### Invariant 6: "LLM context = real units"From signalo-rust/agent-guardrails, MIT.
More from signalo-rust/agent-guardrails
- 0.497score
anti-bug-prevention
signalo-rust
Production deploy safety pipeline.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
api-contract-audit
signalo-rust
Inventory every API endpoint that surfaces a field to clients BEFORE dropping, renaming, or semantically changing it.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
brainstorm-first
signalo-rust
Before starting any non-trivial task (>0.5 day, new feature, new UI page, new integration, refactor spanning >5 files), it is mandatory to ask the requester…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
docker-push-verify
signalo-rust
After `docker buildx build --push`, always verify the image actually landed on the upstream registry.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
eval-harness
signalo-rust
Formal eval-driven development (EDD) framework.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
output-coverage-assertion
signalo-rust
BEFORE claiming "full coverage" / "covers all N minutes" / "X highlights across the whole recording", assert the min/max timeSec of the real output against…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
reviewer-gate
signalo-rust
Run the machine review gate over the current repo — map changed files to the specialist reviewers they require, scan the diff for hardcoded secrets and…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
content-hash-cache-pattern
signalo-rust
Cache expensive file processing results via SHA-256 content hashes — path-independent, auto-invalidating, service layer separation.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
clean-build-verification
signalo-rust
Before committing changes that touch workspace deps, DB schema, or >500 LOC — verify a real clean build.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
search-first
signalo-rust
Research-before-coding workflow.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
regex-vs-llm-structured-text
signalo-rust
Decision framework for parsing structured text — regex covers 95-98% cheaply and deterministically, and an LLM handles only the low-confidence edge cases.
SkillCFreshness: C★ 1Claude Code +9 - 0.494score
verification-loop
signalo-rust
Run a practical quality gate before closing work — typecheck, sync/consistency check, and task-specific validation.
SkillCFreshness: C★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 11, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/signalo-rust/agent-guardrails
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from signalo-rust
- 0.497score
anti-bug-prevention
signalo-rust
Production deploy safety pipeline.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
api-contract-audit
signalo-rust
Inventory every API endpoint that surfaces a field to clients BEFORE dropping, renaming, or semantically changing it.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
brainstorm-first
signalo-rust
Before starting any non-trivial task (>0.5 day, new feature, new UI page, new integration, refactor spanning >5 files), it is mandatory to ask the requester…
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
content-hash-cache-pattern
signalo-rust
Cache expensive file processing results via SHA-256 content hashes — path-independent, auto-invalidating, service layer separation.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
docker-push-verify
signalo-rust
After `docker buildx build --push`, always verify the image actually landed on the upstream registry.
SkillCFreshness: C★ 1Claude Code +9 - 0.497score
eval-harness
signalo-rust
Formal eval-driven development (EDD) framework.
SkillCFreshness: C★ 1Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get money-math-invariants running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
money-math-invariants skill. Agent Mart. https://agentmart.dev/skills/signalo-rust-money-math-invariants-9bf355 (last updated 2026-10-24)