# How to Implement the Four-Master Investment Framework (Buffett · Munger · Duan · Li) in AI Berkshire

> Implement the four-master investment framework Buffett Munger Duan Li in AI Berkshire. Analyze business, moats, inversion, and trends for informed AI driven investment decisions.

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

---

**The AI Berkshire repository implements a staged, multi-agent pipeline where Duan Yong-ping analyzes business essence, Warren Buffett evaluates economic moats, Charlie Munger applies inversion thinking, and Li Lu assesses civilizational trends, converging into a unified decision matrix that outputs price-anchored buy/hold/sell recommendations.**

The `xbtlin/ai-berkshire` open-source project codifies the value-investment mental models of these four masters into a reproducible AI workflow. This **four-master investment framework** structures research as a sequential pipeline—visualized in `assets/architecture-en.svg` and documented in [`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md)—where each analytical layer feeds into the next, ensuring outputs pass rigorous pass/fail/gray-zone criteria before generating final recommendations.

## Pipeline Architecture and Data Flow

The framework processes raw inputs through seven distinct stages orchestrated by the **investment-research** skill defined in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md). Data collection begins with the **financial-data** skill ([`skills/financial-data.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/financial-data.md)), which gathers annual reports, 13-F filings, and macro data, cross-validating them into JSON storage layers ([`data/fundamentals.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/fundamentals.json), [`data/watchlist.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/watchlist.json)) for downstream consumption.

## Stage 1: Business Essence (Duan Yong-ping)

Duan’s analytical lens extracts the business core: product-market fit, competitive advantage mechanics, and founder-led capital allocation. Unlike ratio-based screening, this stage emphasizes *how the business creates value*. The **investment-research** skill explicitly implements the "Business Essence" block to evaluate these qualitative factors before quantitative analysis begins.

## Stage 2: Moat Durability (Warren Buffett)

Buffett’s layer evaluates competitive fortress durability through network effects, switching costs, economies of scale, and cash-machine quality. The **investment-checklist** skill, defined in [`skills/investment-checklist.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-checklist.md), encodes Buffett’s six-gate pre-buy checklist. Final reports surface this analysis in structured ratings such as "Moat (Buffett) | Wide and widening".

## Stage 3: Inversion Analysis (Charlie Munger)

Munger’s inversion principle systematically asks, "What could cause this investment to fail?" The **investment-research** skill contains a dedicated "Inversion (Munger)" stage that identifies downside catalysts, regulatory risks, and management misalignment. This stage produces a *risk-inversion* score that feeds directly into the final decision matrix.

## Stage 4: Management Assessment (Duan + Buffett)

This joint evaluation layer combines both masters’ emphasis on *people*. It assesses CEO quality, capital allocation discipline, and interest alignment between owners and management. The assessment appears in final outputs as the "Management (Duan + Buffett)" rating, requiring both qualitative judgment and quantitative insider-ownership metrics.

## Stage 5: Civilizational Trends (Li Lu)

Li Lu contributes a macro-civilizational perspective evaluating long-term industry secular trends, geopolitical stability, and existential durability. This stage determines whether the company will still exist in ten years. The **investment-research** skill captures this view in the "Civilizational Trends (Li Lu)" column, filtering out businesses facing technological obsolescence or regulatory extinction.

## Decision Matrix and Memo Generation

All five analytical scores converge through the **investment-memo-craft** skill defined in [`codex-skills/investment-memo-craft/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/investment-memo-craft/SKILL.md). This Codex-only skill formats the final research memo, ensures consistent typography, and applies the **four-master decision matrix** logic to yield clear *Buy / Hold / Sell* recommendations with specific price bands. The matrix requires that all five lenses align (or explicitly flag gray-zone exceptions) before issuing a buy signal.

## Parallel Agent Execution

The framework leverages a multi-agent architecture described in the **investment-team** skill ([`codex-skills/investment-team/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/investment-team/SKILL.md)). Four specialized agents—Buffett, Munger, Duan, and Li—run in parallel, each invoking its respective sub-skill, then synchronize findings through the investment-research skill’s orchestration layer. This parallelization maintains analytical independence while ensuring convergent conclusions.

## CLI Commands for Implementation

Run the complete pipeline or isolate specific master analyses using the `ai-berkshire` CLI wrapper:

```bash

# Execute the full four-master research pipeline on a ticker

ai-berkshire /investment-research AAPL

# Isolate Buffett’s moat analysis using the six-gate checklist

ai-berkshire /investment-checklist AAPL --stage moat

# Generate Li Lu’s 10-year civilizational outlook

ai-berkshire /investment-research AAPL --stage li-trends

# Compile all analyses into a formatted investment memo

ai-berkshire /investment-memo-craft AAPL --format markdown

```

Each command invokes the respective Codex skills and returns Markdown blocks suitable for direct insertion into research reports.

## Summary

- The **four-master investment framework** processes data through seven sequential stages from collection to decision, as defined in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md).
- Each master contributes a distinct analytical lens: Duan (business essence), Buffett (moat), Munger (inversion), and Li (civilizational trends).
- The **investment-checklist** skill encodes Buffett’s six-gate pre-buy criteria, while the **investment-memo-craft** skill generates final price-anchored signals.
- Parallel agent execution via [`codex-skills/investment-team/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/investment-team/SKILL.md) allows simultaneous processing by four specialized agents before synchronization.

## Frequently Asked Questions

### Which source files define the core four-master pipeline?

The primary orchestration logic resides in [`skills/investment-research.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-research.md) and [`codex-skills/investment-research/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/investment-research/SKILL.md). Buffett’s specific six-gate checklist is implemented in [`skills/investment-checklist.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/investment-checklist.md), while the multi-agent coordination is defined in [`codex-skills/investment-team/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/investment-team/SKILL.md).

### How does the framework handle data validation and storage?

Raw inputs are collected by the **financial-data** skill and cross-validated before persistence in [`data/fundamentals.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/fundamentals.json) and [`data/watchlist.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/watchlist.json). This JSON data layer ensures consistent formatting for downstream analytical stages.

### Can I run individual master analyses without the full pipeline?

Yes. Use stage-specific flags such as `--stage moat` for Buffett’s analysis or `--stage li-trends` for Li Lu’s civilizational outlook. The full integrated pipeline runs via `/investment-research` without flags.

### What determines the final buy/hold/sell recommendation?

The **investment-memo-craft** skill converges five quantitative/qualitative scores—Business Essence, Moat, Inversion, Management, and Civilizational Trends—into a weighted decision matrix. This matrix yields a definitive signal only when the majority of lenses align, with explicit price bands derived from DCF and comparative valuation models.