How AI Berkshire Implements Warren Buffett's Value Investing Principles: A Six-Gate Technical Framework

AI Berkshire encodes Warren Buffett's value investing principles into a programmable six-gate checklist system that enforces ability-circle discipline, economic moat verification, and safety-margin calculations through precise decimal arithmetic and multi-agent cross-validation.

AI Berkshire transforms Warren Buffett's qualitative investment philosophy into a reproducible, code-driven research workflow. The open-source system operationalizes the Oracle of Omaha's core tenets—circle of competence, durable moats, and margin of safety—through structured markdown skills and Python-based financial rigor tools that eliminate calculation errors and emotional bias.

The Six-Gate Checklist Architecture

At the heart of AI Berkshire lies a six-gate checklist implemented in skills/investment-checklist.md that mirrors Buffett's sequential investment process. Each gate acts as a hard filter; failing any single gate aborts the analysis immediately, preventing wasted effort on businesses that fail fundamental criteria.

Gate 1: Ability Circle ("I only invest in what I understand")

The first gate enforces Buffett's circle of competence (能力圈) principle. In skills/investment-checklist.md (lines 48-53), the system parses input tickers and resolves them to exchanges, then demands a single-sentence explanation of the business model.

If the analyst cannot articulate the business in one sentence, the skill returns a hard reject before any valuation occurs. This mimics Buffett's discipline of avoiding industries he cannot comprehend, effectively filtering out complex tech or speculative sectors unless the user can demonstrate genuine understanding.

Gate 2: Good Business ("Economic characteristics")

The second gate validates quantifiable business quality metrics. The checklist forces exact computation of ROE, gross margin (毛利率), free cash flow (FCF), and debt-to-asset ratios (资产负债比).

According to the source code, this gate invokes tools/financial_rigor.py verify-valuation (lines 69-74) to compute PE ratios and profitability metrics using decimal.Decimal for zero-drift precision. No estimation or "LLM-heart-calculation" is permitted; every number must be verified against primary sources.

Gate 3: Economic Moat ("Durable competitive advantage")

The third gate assesses economic moat depth (护城河). The system enumerates five moat categories—brand loyalty (品牌), switching costs (转换成本), network effects (网络效应), economies of scale (规模), and proprietary technology (技术)—and requires concrete evidence for each claimed advantage.

In skills/investment-research.md (lines 12-24), this expands into Buffett's five moat categories with a mandatory 10-year durability check ("巴菲特式追问"). The skill forces analysts to distinguish between wide moats (宽) and narrow moats (窄) based on trend data, not narrative.

Gate 4: Management Quality ("People matter")

The fourth gate evaluates trustworthy management through a checklist of honesty, capital allocation discipline, shareholder alignment, and succession planning. This assessment appears in skills/investment-checklist.md as the fourth checkpoint (第四关) and deepens in skills/investment-research.md (lines 38-44).

The research skill requires a detailed CEO/Founders matrix and inserts joint commentary from "段永平 & 巴菲特" (Duan Yongping and Buffett) regarding management integrity, ensuring qualitative judgment complements quantitative data.

Gate 5: Safety Margin ("Buy at a discount")

The fifth gate implements the margin of safety principle through three-scenario valuation. When triggered, tools/financial_rigor.py three-scenario (lines 20-38) computes optimistic, neutral, and pessimistic intrinsic value targets based on varying growth and PE assumptions.

The system compares the current market price against the pessimistic scenario's intrinsic value. Only if the price falls below a user-defined discount threshold (typically 30% of intrinsic value) does the safety margin pass, mirroring Buffett's insistence on buying dollars for fifty cents.

Gate 6: Decision Discipline ("Avoid emotional bias")

The final gate addresses behavioral discipline through simple yes/no questions that flag FOMO, peer pressure, or inability to articulate a concise thesis. This "mirror test" (镜子测试) appears in lines 75-84 of investment-checklist.md, ensuring the analyst can defend the position without relying on market sentiment or expert consensus.

The verdict ("✅ 通过 Checklist") is only emitted when all six gates are satisfied, creating a forced discipline similar to Buffett's famous "too hard" pile.

Financial Rigor Engine

The quantitative backbone resides in tools/financial_rigor.py, which eliminates the calculation errors that would otherwise distort Buffett's safety-margin calculations. The script uses decimal.Decimal (lines 28-33) to prevent floating-point drift in financial computations.

The module provides CLI sub-commands that all skills invoke via Bash:

  • verify-market-cap: Cross-validates market capitalization against price and shares outstanding
  • verify-valuation: Computes exact PE, ROE, and FCF yields
  • cross-validate: Checks consistency across two independent data sources
  • three-scenario: Generates the optimistic, neutral, and pessimistic valuation bands

This architecture ensures that every valuation, market-cap verification, and ratio calculation runs through a single, audited Python module rather than LLM estimation, preserving the mathematical rigor Buffett demands.

Multi-Agent Research Team

For deep analysis, AI Berkshire employs a multi-agent perspective through skills/investment-team.md. The system launches four parallel agents, each embodying one investment master: Buffett, Charlie Munger (芒格), Duan Yongping (段永平), and Li Lu (李录).

As implemented in README.md (lines 62-66), these four masters are designed not for simple division of labor but for cross-challenge (互相挑战). Each agent produces independent analyses, and the team lead aggregates findings only after identifying points of consensus and contradiction. This structure prevents single-viewpoint dominance and surfaces contrarian insights that one analyst might miss.

The system also includes an "information richness rating" (信息丰富度评级) and "AI research bias alert" (AI研究偏见预警) in README.md (lines 65-70), flagging consensus traps and prompting contrarian probes like "聪明人为什么不买?" (Why don't smart people buy this?).

Practical Implementation

Users interact with AI Berkshire through Codex commands that trigger the underlying Python tools and markdown skills.


# Run the six-gate Buffett checklist on Chinese tickers

codex /investment-checklist 腾讯, 茅台, 英伟达

# Verify market-cap calculation with precise decimal arithmetic

python3 tools/financial_rigor.py verify-market-cap \
  --price 510 --shares 9.11e9 --reported 4.65e12 --currency HKD

# Generate three-scenario intrinsic value estimate

python3 tools/financial_rigor.py three-scenario \
  --price 510 --eps 23.5 --shares 9.11 \
  --growth 0.15 0.08 0.00 \
  --pe 25 20 15 \
  --years 3 --currency HKD

# Launch the four-master research team for comprehensive analysis

codex /investment-team 美团

The output includes a six-gate checklist table, exact financial ratios generated by financial_rigor.py, three-scenario target prices with safety-margin percentages, and commentary blocks from each of the four masters.

For preliminary screening, skills/quality-screen.md provides a lightweight "7 hard indicators" (7条硬指标) filter that mirrors Buffett's early-stage filter before deep research commences.

Summary

  • AI Berkshire operationalizes Buffett's value investing through a programmatic six-gate checklist in skills/investment-checklist.md that enforces ability-circle discipline and safety-margin requirements.
  • Financial precision is guaranteed by tools/financial_rigor.py, which uses decimal.Decimal arithmetic and cross-validation to eliminate calculation errors in PE, ROE, and intrinsic value estimates.
  • Economic moats are assessed through five standardized categories with mandatory 10-year durability checks, while management quality is evaluated via a CEO/Founders matrix incorporating Buffett and Duan Yongping's criteria.
  • Behavioral discipline is enforced through "mirror tests" that flag FOMO and herd bias, supported by a multi-agent system (skills/investment-team.md) where four investment masters challenge each other's conclusions.
  • Practical workflow moves from lightweight quality screens to deep research pipelines, with all quantitative data flowing through a single rigor engine to ensure Buffett's mathematical standards are met.

Frequently Asked Questions

How does AI Berkshire enforce the circle of competence requirement?

The system requires a single-sentence business description before proceeding with any valuation. In skills/investment-checklist.md (lines 48-53), if the analyst cannot explain the business model concisely, the skill returns a hard reject, mirroring Buffett's refusal to invest in companies he does not understand. This "ability circle" gate (能力圈) acts as the first filter in the six-gate workflow.

What prevents calculation errors in the valuation models?

All quantitative operations route through tools/financial_rigor.py, which uses Python's decimal.Decimal class (lines 28-33) instead of floating-point arithmetic to prevent rounding errors. The tool provides CLI commands like verify-valuation and three-scenario that compute exact ratios and cross-validate against multiple data sources, ensuring the safety-margin calculations are mathematically precise.

How does the multi-agent system improve investment decisions?

The skills/investment-team.md configuration launches four parallel agents representing Buffett, Munger, Duan Yongping, and Li Lu. As described in README.md (lines 62-66), these agents are designed to challenge each other's conclusions (互相挑战) rather than simply divide tasks. This architecture surfaces contrarian viewpoints and prevents confirmation bias, ensuring the final recommendation has survived rigorous cross-examination.

Can AI Berkshire be used for real-time stock analysis?

Yes. Users can invoke the system via Codex commands or direct Python execution. The three-scenario command accepts real-time price data and generates immediate intrinsic value estimates, while the /investment-checklist command processes live tickers through the six-gate framework. However, the system requires users to input accurate financial data (EPS, shares outstanding, etc.) or connect to data feeds, as the tools perform calculations but do not fetch real-time market data autonomously.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →