# Holy Trinity Testing: TLA+, Lean 4 and Bend 2 Bug Finder

> Hunts the bugs your tests never reached: crashes mid-operation, retries, interleavings and boundary rules in storage, database, queue and ledger code. On a storage engine that already had unit and crash tests, this method found 11 defects nobody had caught. TLA+, Lean 4, Bend 2.

Holy Trinity Testing: TLA+, Lean 4 and Bend 2 Bug Finder is a paid AI agent skill on Agensi by Eris Margeta, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $10 (one-time purchase)
- Creator: [Eris Margeta](https://www.agensi.io/creators/eris-margeta)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Version: 1.0
- Last updated: 2026-12-03
- Security: scan passed (2026-12-03); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/holy-trinity-testing-tla-lean-4-and-bend-2-bug-finder
- Tags: code-review, testing, formal-methods, reliability, backend

## What it does

- Scans your folders to find which parts of your code are risky enough to need extra checking
- Models how your code handles crashes and retries to find hidden timing errors
- Proves whether your business rules hold up for every possible input without missing any cases
- Creates real tests in your project language that recreate the exact steps of a discovered bug
- Maintains a record of all found holes and the specific conditions needed to trigger them
- Ensures every green result is backed by a negative test that proves the checker is actually working

## Who it's for

- **Founders building complex systems like banks or databases:** Find the hidden errors in your logic that normal testing misses before they crash your business. Try: "Check my new payment ledger code for bugs that happen during server crashes."
- **Software teams managing high-risk codebases:** Strengthen your most critical features with math-based proof and targeted tests. Try: "Verify our distributed locking logic to make sure two users can't edit the same file."
- **Developers working on data storage or queues:** Catch rare timing issues and race conditions that only happen once in a million runs. Try: "Find why our background worker occasionally misses a task when it retries."

## About this skill

When code handles money, storage, or complex timing, normal tests often miss the "one in a million" bugs that cause total failure. This skill finds those hidden cracks by using formal logic to check your designs. It looks for problems that only happen when a server crashes at the exact wrong time or when tasks happen in a weird order.

Instead of just guessing, this skill models your riskiest logic and proves whether it can actually break. It focuses on things like payment flows, database rules, and messy retry loops.

**How it works**

1. Your AI agent scans your code to see if it is a good fit for this deep check.
2. It picks one risky area, like how you save data, and writes down exactly what that code promises to do.
3. It creates a small model of that logic to test every possible order of events.
4. If it finds a failure, it helps you write a real, failing test in your own language to prove the bug exists.
5. It guides you through fixing the code and keeps the model as a guard to stop that bug from ever coming back.

**What you get:** A report on the safety of your logic, a list of discovered holes, and new tests that catch rare crashes.

**Source and paper**

The method is open source on GitHub as "holy-trinity-testing", with five runnable examples, a CLI (npx holy-trinity) and the whitepaper "Serving, deploying, and testing enterprise code in the generative AI era" (8 pages).

Nothing here guarantees a result: what you find depends on what you model and how faithfully. A green model means no counter-example within the checked bounds, not that the code is correct.

## Requires

- Node.js
- holy-trinity
- Optional: Java 11+ (TLA+ TLC)
- Optional: Lean 4
- Optional: Bend 2

## Known limitations

This skill is for complex logic only. It is not for simple websites or UI code. It requires TLA+, Lean, or Bend tools to be installed to run the full checks.

## Technical details

Uses TLA+ for concurrency/ordering, Lean 4 for rule proofs, and Bend 2 for executable model replays. It generates a trinity/ folder containing PLAN.md, HOLES.md, and expected.tsv to track verification state. It relies on a CLI tool (npx holy-trinity) for scaffolding and gating. Best suited for systems with ACID requirements, distributed state, or complex idempotency logic.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Holy Trinity Testing: TLA+, Lean 4 and Bend 2 Bug Finder skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What kind of bugs does this skill find that my normal tests might miss?

This skill finds rare bugs that happen during server crashes, weird timing, or messy retries. It uses formal logic to check critical areas like payment flows and database rules where normal testing often misses "one in a million" failures.

### Do I need any special software or accounts to use this?

Your AI agent uses specialized tools named TLA plus, Lean 4, and Bend 2 to model your code. You do not need to provide anything extra, but the agent will check if these tools are available to run the deep checks.

### Is this skill a good fit for any type of code?

It is for high risk logic like data storage, payment ledgers, and systems where multiple tasks happen at once. It is not meant for user interfaces, simple data entry code, or code that changes every week.

### What exactly do I get after the skill finished its work?

You receive a report on your logic safety, a list of discovered holes in your code, and new tests that prove the bugs exist. It also provides the specific fixes to close those holes and prevent the bugs from returning.

### How do I tell my agent to start using this skill on my project?

You can ask your agent to verify or formally check a specific part of your code, such as a database or a payment queue. It will first scan your repository to tell you plainly if the code is a good fit for this type of deep analysis.

### Does a successful check mean my code is 100 percent bug free?

A green result means no errors were found within the specific limits and rules defined for the model. It does not guarantee the entire program is perfectly correct, only that the specific logic path was checked against those rules.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
