# How the Munger Inversion Test Works in AI Berkshire: Implementation Guide

> Learn how the Munger Inversion Test works in AI Berkshire. This guide explains how the checklist reveals hidden vulnerabilities by simulating a company's disappearance.

- Repository: [Xbt Lin/ai-berkshire](https://github.com/xbtlin/ai-berkshire)
- Tags: how-to-guide
- Published: 2026-07-27

---

**The Munger Inversion Test is a mental-model checklist embedded in AI Berkshire’s investment-research workflow that forces analysts to imagine a company disappearing tomorrow and evaluate the fallout to expose hidden vulnerabilities in its economic moat.**

The **Munger Inversion Test** applies Charlie Munger’s famous "invert, always invert" philosophy to automated equity research in the xbtlin/ai-berkshire repository. This systematic approach helps AI agents and human analysts stress-test business durability by envisioning catastrophic failure scenarios before finalizing investment ratings.

## What Is the Munger Inversion Test?

The test operationalizes Munger’s contrarian thinking by requiring the analyst to **invert the problem**: instead of asking why a company will succeed, it asks how the company could fail. Specifically, the analyst imagines the target company vanishing overnight and assesses how painful that loss would be for its user base and ecosystem.

This inversion exposes **moat vulnerabilities** that traditional growth analysis often misses. If customers could easily switch to substitutes with minimal disruption, the business possesses a shallow moat. Conversely, if the company’s disappearance would severely disrupt markets and user workflows, the moat is considered durable and wide.

## Workflow Placement and Pipeline Integration

According to the pipeline diagram in [`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md), the Munger Inversion Test occupies a critical position in the research sequence. It executes **after** the Duan Yongping-style business-essence analysis and Warren Buffett-style moat assessment, but **before** the final quality rating.

This placement ensures that qualitative insights about business durability are stress-tested against concrete failure modes. The workflow progression flows from data collection → business essence → moat analysis → **inversion test** → final risk assessment, preventing over-optimistic conclusions from unchecked bullish analysis.

## Technical Implementation and Prompt Engineering

While the Munger Inversion Test is implemented as a **prompt template** rather than a compiled library function, it follows rigorous structural constraints. The logic resides primarily in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md), where the LLM receives specific instructions to generate five distinct "how could X die?" scenarios, each accompanied by a probability estimate.

The test evaluates plausible failure modes such as regulatory crackdowns, loss of critical technology partners, or supply-chain collapses. For each scenario, the AI must answer:

- What would users and merchants lose?
- How quickly could they substitute the service?

The outcomes are then scored (for example, ★★☆☆☆) and fed into the final risk assessment to weight the investment recommendation.

The following Python pseudo-code demonstrates how a Claude-Code skill invokes this test:

```python
def munger_inversion(company_name, prompt):
    """
    Invoke the Munger Inversion Test via LLM prompt.
    Template sourced from skills/investment-research.md
    """
    inversion_prompt = f"""
    Imagine {company_name} disappears tomorrow.
    List 5 plausible ways it could die, with a brief probability estimate for each.
    For each scenario, answer:
      • What would users/merchants lose?
      • How quickly could they substitute the service?
    """
    response = llm.complete(inversion_prompt)
    return response

# Usage example

result = munger_inversion("Pinduoduo", user_prompt)
print(result)

```

## Key Files and Architecture

The Munger Inversion Test spans multiple components across the xbtlin/ai-berkshire codebase:

- **[`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md)** – Documents the overall research pipeline and includes the Munger-Style Inversion Test table showing workflow sequence.
- **[`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md)** – Contains the actual prompt template that triggers the inversion analysis for the AI agent.
- **[`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md)** – Consumes the inversion outcomes to help rate the company’s overall quality score.
- **[`tools/report_audit.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/report_audit.py)** – Validates that generated research reports include the inversion section before finalization, ensuring compliance with the workflow.

## Summary

- The **Munger Inversion Test** applies Charlie Munger’s "invert, always invert" principle by forcing analysts to imagine a company’s disappearance and measure the resulting pain.
- It sits **between moat analysis and final rating** in the AI Berkshire pipeline, acting as a safeguard against optimistic bias.
- The implementation relies on **structured prompt engineering** in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md), requiring five death scenarios with probability estimates and substitution analysis.
- **[`tools/report_audit.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/report_audit.py)** enforces inclusion of inversion results before report finalization, ensuring systematic risk assessment.

## Frequently Asked Questions

### What is the primary purpose of the Munger Inversion Test in AI Berkshire?

The primary purpose is to **expose hidden vulnerabilities** in a company’s economic moat by inverting the analytical perspective. Instead of confirming why a business might succeed, the test forces the AI to enumerate specific failure modes and assess whether users could easily substitute the service if the company vanished.

### How does the test differ from traditional Buffett moat analysis?

While Buffett-style moat analysis in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md) focuses on identifying competitive advantages and durability, the Munger Inversion Test **stress-tests those conclusions** by simulating catastrophic failure. It answers whether the identified moat is real by measuring the pain of its absence, adding a contrarian safety check to the bullish assessment.

### Where is the inversion logic implemented in the codebase?

The core logic lives in **[`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md)** as a structured prompt template. The validation logic resides in **[`tools/report_audit.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/report_audit.py)**, which checks that reports contain the inversion section, while **[`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md)** consumes the test outputs to adjust final quality ratings.

### Can the Munger Inversion Test be used for non-tech companies?

Yes, the framework is **sector-agnostic**. While the example code uses "Pinduoduo," the prompt template in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md) accepts any company name and adapts the failure scenarios to the specific business model, whether analyzing retail, manufacturing, or software companies.