# How the Quality-Screen Skill Filters Stocks in the AI-Berkshire Repository

> Discover how the quality-screen skill in xbtlin/ai-berkshire filters stocks using financial metrics and exemption rules. Learn about its Pass/Fail/Gray classifications.

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

---

**The `/quality-screen` skill in the xbtlin/ai-berkshire repository applies seven hard financial metrics and three exemption rules to eliminate poor-quality companies, using parallel agents to scrape data from annual reports and broker research before generating Pass/Fail/Gray classifications.**

The **quality-screen skill** functions as a deterministic “go-bad-companies-out” filter designed for rapid elimination of low-quality investment targets. Implemented in the [xbtlin/ai-berkshire](https://github.com/xbtlin/ai-berkshire) project, this command orchestrates multiple AI agents defined in [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md) to evaluate securities against rigorous quantitative standards.

## Input Parsing and Scope Resolution

The skill begins execution in the **Input Parser** section of [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md), where it detects the mode of the user’s `$ARGUMENTS` and normalizes each entry to a company name, ticker, and exchange.

For **individual-stock mode**, processing proceeds directly to data collection. For **batch mode** (industries, indices, or themes), the skill triggers a **WebSearch Agent** that searches the supplied market or sector, extracts the top 10-30 listed companies, and builds a consolidated watch-list. This logic is described under *“第一步：解析输入，确定筛选范围”* (Step 1: Parse Input, Determine Screening Scope) in the skill definition.

## Parallel Data Collection Architecture

According to the architecture diagram in [`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md) (lines 51-61), the **Agent Layer** spawns parallel background agents for each company. As specified under *“第二步：并行数据收集”* (Step 2: Parallel Data Collection), each agent scrapes seven critical data points with the following source priority: annual reports → broker research → financial data platforms.

The seven metrics collected are:

- **10-year average ROE** (Return on Equity)
- **5-year cumulative Free Cash Flow** (FCF)
- **Interest-Coverage Ratio** (EBIT/Interest)
- **Long-term Gross-Margin**
- **Operating-Cash-Flow / Net-Profit** (5-year average)
- **Long-term Net-Margin**
- **5-year Total-Equity-Dilution** (flagged if >20% excluding M&A)

## The Rule Engine and Exemption Processor

Located in [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md) lines 28-63, the **Rule Engine** implements a two-stage evaluation system.

### Seven Hard Filters

The **hard-filter table** (lines 28-35) maps each metric to a reject threshold. Companies failing any single metric receive a ❌ flag immediately.

### Three Exemption Rules (A-C)

Lines 36-63 define qualitative patterns allowing companies to bypass specific failures:

- **Rule A:** “Strategic-investment-phase” exemption for low ROE
- **Rule B:** “High-margin-but-low-profit-strategy” exemption for net-margin failures  
- **Rule C:** “High-turnover-thin-margin” exemption covering both gross-margin and net-margin

The engine evaluates each metric (✅/❌/⚠️), checks applicable exemptions, and produces a final **Pass/Fail/Gray** status.

## Result Generation and Reporting

The **Result Formatter** (lines 106-148 of [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md)) generates a markdown report containing:

- A summary table with all seven metrics and final results
- Segregated lists of passed, excluded, and exemption-approved companies
- Sector-level statistics including pass-rate and qualitative “quality-layer” groupings (in batch mode)

## Usage Examples

### Screening Individual Stocks

```text
/quality-screen 腾讯, 美团, 英伟达

```

This command returns an evaluation table:

```text

# 去劣筛选结果

## 汇总表

| 公司 | ①ROE | ②FCF | ③利息覆盖 | ④毛利率 | ⑤OCF/NI | ⑥净利率 | ⑦稀释 | 结果 |
|------|------|------|-----------|----------|----------|----------|--------|------|
| 腾讯 | ✅ 24% | ✅ | ✅ | ✅ 56% | ✅ | ✅ | ✅ 30% | ✅ 通过 |
| 美团 | ⚠️→✅ | ✅ | ✅ | ✅ 35% | ✅ | ✅ | ✅ | ✅ 豁免通过 |
| 英伟达 | ❌ 3% | ❌ | ❌ | ✅ 20% | ✅ | ❌ 2% | ✅ | ❌ 排除 |

```

### Batch Screening Multiple Companies

```text
/quality-screen 恒生指数成分股

```

Batch mode produces sector analysis:

```text

## 板块总结

**通过率**：12/20 = 60%
**行业质量判断**：整体质量中等，需重点关注 ROE 低且无豁免的科技股。

## 通过的公司（12家）

[北京航空、腾讯、阿里巴巴, …]

## 排除的公司（8家）

| 公司 | 触犯指标 | 具体数据 | 排除理由 |
|------|----------|----------|----------|
| 某银行 | ③利息覆盖 | 1.5× | 银行不适用此指标 |
| 某REIT | ①ROE | -5% | ROE波动大 |

```

## Implementation Files

The quality-screen skill relies on these key components:

- **[`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md)** – Primary skill definition containing input parsing logic, the seven-metric table, exemption rules, and output templates
- **[`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md)** (Architecture section, lines 51-61) – Documents the three-layer design (Skill → Agent → Tool) enabling parallel execution
- **[`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py)** – Underlying precision utilities for cross-validating financial data scraped by agents
- **[`codex-skills/quality-screen/SKILL.md`](https://github.com/xbtlin/ai-berkshire/blob/main/codex-skills/quality-screen/SKILL.md)** – Auto-generated Codex wrapper providing identical functionality for OpenAI Codex users

## Summary

- The **quality-screen skill** operates as a deterministic filter using seven hard financial metrics and three contextual exemptions to remove poor-quality companies
- **Parallel agent architecture** in [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md) enables simultaneous data collection from annual reports, broker research, and financial platforms
- **Batch mode** leverages a WebSearch Agent to expand industry or index inputs into constituent watch-lists automatically
- **Deterministic rule engine** at lines 28-63 of the skill file produces Pass/Fail/Gray classifications with detailed exemption tracking
- **Markdown reporting** generates sector statistics and company-level breakdowns suitable for direct investment research workflows

## Frequently Asked Questions

### What are the seven specific metrics used in the quality-screen skill?

The skill evaluates **10-year average ROE**, **5-year cumulative Free Cash Flow**, **Interest-Coverage Ratio**, **long-term Gross-Margin**, **Operating-Cash-Flow/Net-Profit ratio**, **long-term Net-Margin**, and **5-year Total-Equity-Dilution**. Each metric is scraped by parallel agents following a strict source hierarchy: annual reports first, then broker research, then financial platforms.

### How does the exemption system work in the quality-screen skill?

Three exemption rules (A-C) defined in [`skills/quality-screen.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/quality-screen.md) lines 36-63 allow companies to bypass specific metric failures if they meet qualitative patterns. For example, a company in a "strategic-investment-phase" may receive an exemption for low ROE (Rule A), while high-turnover businesses may bypass thin-margin thresholds (Rule C). The system flags these as ⚠️→✅ in the results table.

### Can the quality-screen skill analyze entire stock indices or sectors?

Yes. When provided with an index name, industry, or theme (such as `恒生指数成分股`), the skill activates **batch mode**. A WebSearch Agent identifies the top 10-30 listed companies in that category, builds a consolidated watch-list, and runs parallel screening across all constituents. The output includes sector-level pass rates and quality-layer groupings.

### What is the role of the Agent Layer in the quality-screen implementation?

According to the architecture diagram in [`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md) lines 51-61, the **Agent Layer** orchestrates the skill as a lightweight command that spawns parallel background agents. These agents handle data collection for each company simultaneously while [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) provides cross-validation utilities, ensuring both speed and reproducibility in the screening process.