Works with the AI Agents you already use

    Grounded Math & Quote Verification Compiler

    by Wasabi hu

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Grounded Math & Quote Verification Compiler

    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")

    ArgumentSource QuoteCharacter OffsetParsed Value
    GAAP net profit"43,870"1936..194243870
    Share-based compensation"6,342"1147..11526342
    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

    1. Use scripts/focus_prompt_tables.py first on long multi-year tables to slice target columns before emitting a JSON plan.
    2. Run scripts/batch_replay_audit.py on archived verification records to catch OFFSET_DRIFT, HALLUCINATED_QUOTE, or ARITHMETIC_MISMATCH offline.

    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:

    1. 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 an ABSENT verdict (check-absent-retry).
    2. 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 exact Decimal operations (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 -, —, --, and N/A placeholders 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
    3. Stage 3 — Zero-Token Batch Replay Audit (scripts/batch_replay_audit.py): Re-executes archived verification records offline with zero LLM calls to flag OFFSET_DRIFT, HALLUCINATED_QUOTE, and ARITHMETIC_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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Terminal / Shell
    Read Files

    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.

    Listed4 days ago

    What's inside

    Frequently Asked Questions

    This skill solves the problem of LLMs hallucinating numbers or paraphrasing text during data extraction. It forces the agent to use a neuro-symbolic compiler that verifies every quote against exact character offsets and executes math via a deterministic Decimal runtime instead of error-prone mental arithmetic.

    The skill provides three core Python scripts: focus_prompt_tables.py for shrinking large tables, verify_grounded_math.py for checking quotes and executing arithmetic, and batch_replay_audit.py for offline verification. You only need a Python 3.11 plus environment with standard libraries like decimal and json to run these tools.

    This skill cannot perform OCR on images or PDF files, so documents must be converted to Markdown or plain text first. It is also not intended for probabilistic forecasting, external data fetching, or making investment recommendations.

    The skill produces structured JSON DSL plans and audit logs that confirm if a claim is valid or rejected. It enforces hard firewalls against currency mixing, unit precision errors, and statutory article mismatches, ensuring that every output is grounded in the source text.

    You can direct your agent to use the scripts to verify specific financial deltas, reconcile GAAP adjustments, or extract verbatim statutory clauses. For example, ask the agent to focus a wide Markdown table first and then emit a JSON plan to verify a net profit calculation against the original document.

    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.