Works with the AI Agents you already use
Grounded Math & Quote Verification Compiler
by Wasabi hu
Zero-dependency Python verification compiler that grounds every LLM quote to exact character offsets and executes deterministic Decimal math with accounting, currency, and statute guardrails.
$7.99
Grounded Math & Quote Verification Compiler
Example session with this skill installed
Verify the Q3 adjusted net profit calculation (GAAP net profit 43,870 + share-based compensation 6,342 + fair-value adjustment (4,120)) against synthetic_meridian_filing.md, and show how the compiler rejects hallucinated figures or cross-currency addition.
- Read your context and instructions
- Compiled the grounded math
Executed verify_grounded_math.py offline against synthetic_meridian_filing.md using Python's exact Decimal runtime with double-execution replay verification (symbolic.replay_identical: true).
1. Verified Adjusted Net Profit (status: "ANSWER")
| Argument | Source Quote | Character Offset | Parsed Value |
|---|---|---|---|
| GAAP net profit | "43,870" | 1936..1942 | 43870 |
| Share-based compensation | "6,342" | 1147..1152 | 6342 |
| Fair-value adjustment | "(4,120)" | 1098..1105 | -4120 |
Result (ADD) | — | — | 46092 |
Exact JSON emitted by scripts/verify_grounded_math.py:
{
"status": "ANSWER",
"value": "46092",
"type": "number",
"reason": "GAAP + SBC + fair-value adjustment",
"evidence": [
{"start": 1936, "end": 1942, "quote": "43,870"},
{"start": 1147, "end": 1152, "quote": "6,342"},
{"start": 1098, "end": 1105, "quote": "(4,120)"}
],
"version": "1.0.0",
"symbolic": {
"program": {
"op": "ADD",
"args": [{"quote": "43,870"}, {"quote": "6,342"}, {"quote": "(4,120)"}],
"reason": "GAAP + SBC + fair-value adjustment"
},
"replay_identical": true
}
}
2. Guardrail Rejection Examples (status: "REJECTED")
- Hallucinated digit swap (
"6,432"instead of"6,342"): returns"status": "REJECTED","reason": "HALLUCINATED_QUOTE_NOT_IN_DOC:'6,432'","evidence": []. - Cross-currency addition (
"RMB 10,000"+"USD 2,500"): returns"status": "REJECTED","reason": "CURRENCY_MISMATCH:['RMB', 'USD']".
Exact Command Executed
python3 scripts/verify_grounded_math.py \
--doc synthetic_meridian_filing.md \
--question "What is adjusted net profit = GAAP net profit + SBC + fair-value adjustment?" \
--raw '{"op":"ADD","args":[{"quote":"43,870"},{"quote":"6,342"},{"quote":"(4,120)"}],"reason":"GAAP + SBC + fair-value adjustment"}'
Next Steps
- Use
scripts/focus_prompt_tables.pyfirst on long multi-year tables to slice target columns before emitting a JSON plan. - Run
scripts/batch_replay_audit.pyon archived verification records to catchOFFSET_DRIFT,HALLUCINATED_QUOTE, orARITHMETIC_MISMATCHoffline.
Connects securely to your tools. The creator never sees your data.
About this skill
LLMs frequently hallucinate numbers, fail at mental arithmetic, and paraphrase quotes until they no longer match the source document. This skill turns any coding or research agent into a deterministic verification compiler—never letting the model guess figures or calculate math in prose.
What it does
Three standalone, offline Python 3.11+ scripts verify every quote and calculation against unmodified source files:
- Stage 1 — Lossless Table Focusing (
scripts/focus_prompt_tables.py): Slices wide multi-year Markdown tables (including empty leading header cells like|| 2025 | 2024 |) to target columns and prunes 30+ row statements to relevant lines ±2 neighbors. Automatically skips pruning on aggregation queries (total,sum,highest,which) and checks omitted rows before accepting anABSENTverdict (check-absent-retry). - Stage 2 — Grounded Span & Exact Decimal Math (
scripts/verify_grounded_math.py): Strips<think>blocks and code fences from the model's single-line JSON DSL plan, locates every snippet character-for-character on the untouched source document using 1-to-1 Unicode and Traditional/Simplified CJK folding (len(norm) == len(orig)), executes exactDecimaloperations (VALUE,TEXT,ADD,SUB,ABS_DIFF,MUL,DIV,COUNT,COMPARE,ABSENT,CONFLICT) including parenthesized accounting negatives like(4,120), and enforces five strict firewalls:- Blocks
-,—,--, andN/Aplaceholders from grounding numeric answers - Blocks silent cross-currency arithmetic (
RMB+USD) and cross-dimension mixing (%+ money) - Rejects unflagged cross-period summations on
ADD - Rejects statutory article mismatches (asking about Article 999 when citing Article 42)
- Rejects coarse rounded
亿元headlines when exact元or千元table precision was requested - Runs double execution to confirm
symbolic.replay_identical == true
- Blocks
- Stage 3 — Zero-Token Batch Replay Audit (
scripts/batch_replay_audit.py): Re-executes archived verification records offline with zero LLM calls to flagOFFSET_DRIFT,HALLUCINATED_QUOTE, andARITHMETIC_MISMATCH.
Runtime & security design
Built strictly on Python 3.11+ standard library (decimal, json, re, pathlib, argparse). Zero third-party packages, zero network calls, zero environment variable reads, zero native C bindings, and read-only stdout JSON output.
Included references
references/dsl-spec.md— Schema for all 11 DSL operations, optional operand fields, and error retry hints.references/guardrails.md— 1-to-1 offset preservation, accounting negative parsing, and firewall rules.references/examples.md— Complete synthetic walkthroughs across financial, clinical, and statutory inputs.
Known limitations
Operates on extracted Markdown or plain text; does not run OCR on image-only scanned PDFs, fetch live external data, or provide financial or legal advice.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 4 days ago
- Software
Python
Permissions
Read-only local Python execution. Reads supplied document or JSON inputs via file path or stdin and prints structured UTF-8 JSON to stdout. Zero network requests, zero environment variables, zero external packages, and zero file mutations.
What's inside
Frequently Asked Questions
New in LLM Ops
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.