# Core Functionalities of AI Berkshire: Modular Agent-Driven Investment Research

> Explore AI Berkshire's core functionalities. This open-source framework empowers investors with 18 skills, 4 AI agents, and precision tools for advanced investment research.

- Repository: [Xbt Lin/ai-berkshire](https://github.com/xbtlin/ai-berkshire)
- Tags: deep-dive
- Published: 2026-06-29

---

**AI Berkshire is a deterministic, open-source research framework that transforms individual investors into full-stack operations through 18 canonical skills, four parallel AI agents representing value investment masters, and precision financial calculation tools.**

AI Berkshire implements a three-layer architecture—Skill, Agent, and Tool—to automate rigorous fundamental analysis while eliminating cognitive bias. The repository, maintained at `xbtlin/ai-berkshire`, organizes its capabilities as plain-text Markdown files, Python utilities, and shell scripts that deliver reproducible, decision-ready investment research.

## The Three-Layer Architecture

The core functionalities of AI Berkshire rest on three interoperating layers, illustrated in `assets/architecture.png` and defined in `assets/architecture.mmd`. Each layer serves a distinct purpose in the research pipeline:

- **Skill Layer**: Public entry points exposing 18 high-level research capabilities via slash-commands or CLI invocations.
- **Agent Layer**: Four autonomous AI agents operating concurrently, each embodying the investment philosophy of a specific value master (段永平, 巴菲特, 芒格, 李录).
- **Tool Layer**: Precision finance utilities ensuring mathematical exactness and data integrity.

## Skill Layer: 18 Canonical Research Capabilities

The framework defines **18 canonical skills** documented under `skills/` and generated into `codex-skills/` and `codex-prompts/`. These skills fall into five functional families:

### Deep Research

- **`investment-research`**: Full-company analysis synthesizing four value-investment perspectives
- **`investment-team`**: Parallel-agent team research for comprehensive coverage
- **`management-deep-dive`**: Executive and leadership quality assessment
- **`private-company-research`**: Detective work for non-public entities (e.g., SpaceX)
- **`deep-company-series`**: Multi-part systematic analysis series

### Financial Analysis

- **`earnings-review`**: First-hand SEC filing analysis
- **`earnings-team`**: Collaborative earnings deep-dive preparation for publication

### Industry Screening

- **`industry-research`**: Complete industry chain mapping
- **`industry-funnel`**: Multi-stage filtering from market to final picks
- **`quality-screen`**: Fast hard-filter implementation using the 7-point quality checklist
- **`bottleneck-hunter`**: Supply chain constraint identification
- **`investment-checklist`**: Rapid 8-point red-line evaluation (快速否决清单)

### Portfolio Management

- **`portfolio-review`**: Position sizing and allocation optimization
- **`thesis-tracker`**: Investment thesis monitoring and drift detection
- **`news-pulse`**: Immediate price-move attribution and news analysis

### Thinking Tools

- **`dyp-ask`**: "Ask Duan Yongping" style qualitative Q&A
- **`financial-data`**: Rigorous data cross-validation workflows
- **`wechat-article`**: Collaborative article generation for WeChat publication

Each skill resides as a self-contained Markdown file in `skills/` describing workflows, required parameters, and example invocations, synchronized via [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py).

## Agent Layer: Four-Master Parallel Analysis

Every skill invocation spawns **four autonomous agents** representing distinct value investment masters. As implemented in the architecture design, each agent:

1. **Collects data** from web sources or `tools/` utilities
2. **Performs independent analysis** covering business model, moat, valuation, and risk
3. **Challenges perspectives** through "reverse-thinking" and "mirror-tests"

The agents operate concurrently, producing independent sub-reports with **A/B/C information richness ratings** and mirror-test failure flags. A *Team Lead* agent then aggregates these outputs, applies the **8-point red-line checklist**, and generates a structured final report containing:
- **Decision**: Pass / Grey / Fail
- **Price ranges**: Aggressive, balanced, and conservative allocation targets
- **Confidence levels**: Source citations and uncertainty quantification

## Tool Layer: Precision Finance Utilities

To guarantee **data integrity** and **mathematical exactness**, AI Berkshire ships Python tools under `tools/` using `decimal.Decimal` for all calculations to avoid floating-point drift:

### Financial Rigor Toolkit ([`financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/financial_rigor.py))

The primary arithmetic validation module exposes CLI commands:

- **`verify-market-cap`**: Cross-validates market capitalization against price and share count
- **`verify-valuation`**: Validates valuation metrics using multiple input streams
- **`cross-validate`**: Multi-source data triangulation
- **`three-scenario`**: Scenario-based valuation modeling
- **`benford`**: Benford's Law anomaly detection for financial statement integrity
- **`calc`**: High-precision decimal calculator

### Data Acquisition and Screening

- **[`stock_screener.py`](https://github.com/xbtlin/ai-berkshire/blob/main/stock_screener.py)**: Implements the 7-point quality checklist for fast hard-filtering
- **[`xueqiu_scraper.py`](https://github.com/xbtlin/ai-berkshire/blob/main/xueqiu_scraper.py)**: Real-time market data extraction from Xueqiu
- **[`morningstar_fair_value.py`](https://github.com/xbtlin/ai-berkshire/blob/main/morningstar_fair_value.py)**: Fair-value estimate generation from Morningstar data
- **`momentum_backtest*.py`**: Momentum strategy back-testing utilities

## Deterministic Research Workflow

The core functionalities of AI Berkshire follow a **deterministic pipeline** ensuring identical inputs always generate the same structured output:

1. **Skill Invocation**: User triggers a skill (e.g., `/investment-research 腾讯` or `codex --skill investment-research "腾讯"`)
2. **Agent Dispatch**: The skill dispatcher launches four parallel agents, each calling appropriate tools for data retrieval and numeric validation via [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py)
3. **Sub-report Generation**: Agents produce independent analyses with uncertainty ratings and mirror-test results
4. **Synthesis**: Team Lead aggregates findings, applies the red-line checklist, and outputs decision-ready recommendations with price targets and confidence metrics

This reproducible workflow enables side-by-side comparison of research iterations and eliminates stochastic drift in financial calculations.

## Extensibility and Customization

The framework supports modular extension without core modification:

- **Adding Skills**: Create a Markdown file under `skills/` and execute [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) to regenerate `codex-skills/` packages
- **Adding Tools**: Place Python modules in `tools/` and expose CLI entries in [`financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/financial_rigor.py) or dedicated scripts
- **Updating Architecture**: Modify `assets/architecture.mmd` (Mermaid source) and regenerate `assets/architecture.png`

## Command-Line Interface Examples

The following commands demonstrate common operations, compatible with both Claude Code (slash-commands) and Codex CLI:

```bash

# Deep company research with four-master synthesis

investment-research 腾讯

# Parallel-agent team research for comprehensive coverage

investment-team 美团

# Quick red-line evaluation across multiple tickers

investment-checklist 腾讯,阿里巴巴,茅台,英伟达

# Industry funnel screening from sector to final candidates

industry-funnel "AI算力"

# Private company analysis (e.g., SpaceX)

private-company-research SpaceX

# Raw SEC filing earnings analysis

earnings-review PDD 2025Q4

# Immediate price-move attribution

news-pulse 腾讯

# High-precision market cap validation

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

```

## Summary

- **AI Berkshire** implements a three-layer architecture (Skill, Agent, Tool) for deterministic investment research
- **18 canonical skills** provide slash-command access to deep research, financial analysis, industry screening, and portfolio management
- **Four parallel agents** representing 段永平, 巴菲特, 芒格, and 李录 challenge each other via mirror-tests and reverse-thinking before final synthesis
- **Precision tools** in [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) use `decimal.Decimal` to eliminate floating-point errors in valuation calculations
- **Deterministic workflows** ensure reproducible research outputs with A/B/C information ratings and 8-point red-line filtering
- **Modular extensibility** allows adding new skills via `skills/` Markdown files and [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py)

## Frequently Asked Questions

### How does AI Berkshire ensure mathematical accuracy in financial calculations?

AI Berkshire guarantees precision by implementing all arithmetic operations in [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) using Python's `decimal.Decimal` class rather than standard floating-point numbers. This prevents drift in multi-step valuation calculations. The tool suite includes specific validators like `verify-market-cap` and `cross-validate` that triangulate data across multiple sources before presenting figures to the agent layer.

### What distinguishes the four AI agents in the analysis workflow?

Each agent embodies the specific investment philosophy of one of four value masters: 段永平 (Duan Yongping), 巴菲特 (Warren Buffett), 芒格 (Charlie Munger), and 李录 (Li Lu). They operate concurrently, conducting independent research on business models, moats, and valuations. The agents challenge each other through "mirror-tests" (identifying cognitive biases) and "reverse-thinking" exercises before a Team Lead synthesizes their outputs into a unified recommendation.

### Can I add custom investment strategies to AI Berkshire?

Yes. The framework supports extension through the `skills/` directory. Create a new Markdown file describing your workflow, parameters, and examples, then run [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) to generate the corresponding Codex packages in `codex-skills/`. For calculation utilities, add Python modules to `tools/` and expose CLI commands through [`financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/financial_rigor.py) to maintain integration with the agent layer's validation requirements.

### How does the "investment-checklist" skill differ from "quality-screen"?

The `quality-screen` skill applies a **7-point quality checklist** for fast hard-filtering of large stock universes, functioning as an initial funnel. In contrast, `investment-checklist` implements an **8-point red-line checklist** (快速否决清单) used later in the workflow to make final Pass/Grey/Fail decisions after deep research. The former eliminates weak candidates early; the latter prevents capital allocation to structurally flawed opportunities.