Skip to content
Agentmart
Submit a tool

ledger

Use when the agent encounters money-shaped identifiers (amount, price, balance, total, cost), performs arithmetic across monetary fields, or writes/reads…

Skill by mbachaud

IndexedApache-2.0★ 2
Write a review

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/mbachaud-ledger

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.

We use your email only for this newsletter. Privacy

About

Use when the agent encounters money-shaped identifiers (amount, price, balance, total, cost), performs arithmetic across monetary fields, or writes/reads money to a database. Enforces Decimal-only math.

Use cases: backend, agent-building

No 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/ledger

What's inside

Skill name
ledger
Description
Use when the agent encounters money-shaped identifiers (amount, price, balance, total, cost), performs arithmetic across monetary fields, or writes/reads money to a database. Enforces Decimal-only math.
License
Apache-2.0
Instructions
45 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# ledger — deterministic money math

## When to invoke

If you see any of:

- variable names matching `amount_*`, `price_*`, `balance_*`, `total_*`, `cost_*`, `fee_*`, `tax_*`
- arithmetic involving currency, percentages of money, or splits/allocations
- DB columns storing money (TEXT or DECIMAL)

…use the helpers in `lib/decimal_math.py`. Never use Python `float` for money.

## API

```python
from lib.decimal_math import to_decimal, to_db_amount, sum_money, pct_of, rebalance, MONEY_PLACES, ZERO
```

- `to_decimal(value)` — coerce int/str/Decimal/None to Decimal. Float goes through `str()`.
- `to_db_amount(value)` — quantize to 4 places, return TEXT for SQLite/Postgres.
- `sum_money(iterable)` — sum Decimals exactly. Rejects float with `TypeError`.
- `pct_of(total, percent)` — return percent% of total, quantized.
- `rebalance(total, weights)` — split total across weights; last bucket absorbs rounding so the sum is exact.

## Anti-patterns the guardrail catches

```python
total = 0.1 + 0.2          # FLOAT — gives 0.30000000000000004
amount = price * 0.08      # FLOAT TAX — silent rounding error
record["amount"] = 33.33   # WRITES FLOAT TO DB
```

…rewrite as:

```python
total = sum_money([Decimal("0.10"), Decimal("0.20")])   # exact 0.30
amount = pct_of(price, Decimal("8"))                    # exact 8% of price
record["amount"] = to_db_amount(Decimal("33.33"))       # "33.3300"
```

## Hook

`hooks/scripts/money_math_guard.py` runs on `PreToolUse` for `Edit`/`Write`. It scans the diff for float literals next to money-shaped identifiers and emits a WARN-level reminder. Never blocks unless `mek.toml > [compliance.gates] > money_write = "block"`.

From mbachaud/MaxExpressKit, Apache-2.0.

Signals

Stars
2
Forks
0
Open issues
0
Last commit (this folder)
May 11, 2026 (5 months ago)
Last release
May 11, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from mbachaud

Cite this page

ledger skill. Agent Mart. https://agentmart.dev/skills/mbachaud-ledger (last updated 2026-10-24)