How the Quality-Screen Skill Applies Seven Hard Filters for Stock Screening in AI-Berkshire
The quality-screen skill in xbtlin/ai-berkshire implements a "go-no-go" workflow that evaluates stocks against seven strict financial thresholds—ROE ≥8%, positive 5-year FCF, interest coverage ≥2x, gross margin ≥15%, OCF/NI ratio ≥0.7, net margin ≥5%, and share dilution ≤20%—while allowing specific exemptions for strategic growth cases.
The quality-screen skill is a Claude-Code/Codex-compatible workflow designed for disciplined equity screening. Located in skills/quality-screen.md, this tool automates a rigorous "eliminate the inferior" (去劣) process that parses ticker lists, collects financial data in parallel, and enforces hard cut-offs to filter out low-quality companies before they reach deeper analysis.
The Seven Hard Filters Defined in quality-screen.md
The core screening logic resides in skills/quality-screen.md (lines 24–35), where seven indicators serve as non-negotiable gates. A company failing any filter is excluded unless it qualifies for a specific exemption.
Capital Efficiency and Cash Reality Metrics
Filter 1: 10-Year Average ROE ≥ 8%
The skill requires a minimum 10-year average Return on Equity (ROE) of 8%. This threshold ensures shareholders' capital generates returns above the long-term opportunity cost. In quality-screen.md, this filter appears first in the hard-filter table, emphasizing capital efficiency as the primary quality indicator.
Filter 2: 5-Year Cumulative Free Cash Flow (FCF) Must Be Positive
The skill rejects companies with negative cumulative FCF over five years. This captures the "cash reality" check—verifying that profits are backed by actual cash generation rather than accounting adjustments.
Profitability and Financial Health Thresholds
Filter 3: Interest Coverage Ratio ≥ 2×
Calculated as EBIT divided by interest expense, this ratio must exceed 2× to confirm debt serviceability. The source code explicitly notes that banks and insurance companies are exempt from this filter due to their interest-bearing business models.
Filter 4: Long-Term Gross Margin ≥ 15%
This threshold tests pricing power. Companies with gross margins below 15% typically lack product differentiation or competitive moats, making them vulnerable to price wars.
Filter 5: Operating Cash Flow to Net Income Ratio ≥ 0.7
Measured as a 5-year average, this ratio validates earnings quality. If operating cash flow consistently falls below 70% of net income, the skill flags potential accrual accounting distortions or working capital inefficiencies.
Filter 6: Long-Term Net Margin ≥ 5%
The skill requires sustainable net margins above 5% to ensure the company can withstand revenue shocks without immediate losses. This serves as a resilience buffer against cyclical downturns.
Shareholder Protection Criteria
Filter 7: 5-Year Share Dilution ≤ 20%
Excluding M&A-related issuance, total share dilution over five years must not exceed 20%. This protects existing shareholders from excessive equity financing that erodes ownership value without proportional value creation.
How the Screening Workflow Executes
The skill implements a modular pipeline defined in skills/quality-screen.md, separating data ingestion from rule evaluation to ensure reproducibility.
Input Parsing and Mode Detection
In lines 5–12 of quality-screen.md, the skill accepts a single $ARGUMENTS string that triggers three operating modes:
- Individual mode: Comma-separated tickers (e.g.,
"腾讯, 美团") - Industry mode: Thematic searches (e.g.,
"中国啤酒行业") - Index mode: Benchmark constituents (e.g.,
"沪深300")
For batch operations, the skill automatically expands industry or index inputs by querying constituent companies via web search before proceeding to data collection.
Parallel Data Collection via Background Agents
Lines 81–94 of the source file describe the parallel agent architecture. For each target company, the skill spawns a dedicated background Agent that simultaneously queries:
- Annual reports (primary source)
- Broker research (secondary validation)
- Financial data platforms (real-time verification)
Each agent retrieves the seven data points required for the hard filters (ROE, FCF, interest coverage, gross margin, OCF/NI, net margin, and share dilution), enabling concurrent processing that reduces total runtime linearly with the number of target companies.
Filter Evaluation and Exemption Logic
Once data is collected, the skill evaluates each company against the seven thresholds (lines 24–35). If a company fails a specific filter, the workflow checks three exemption rules (lines 36–63) before finalizing exclusion:
- Strategic-Investment Period: Applies to young, high-margin companies (listed <10 years, gross margin >30%, cash-flow positive last 2 years) that may have ROE below 8% due to growth investments.
- Intentional Low-Profit: Covers high-margin firms reinvesting for market share (gross margin >30% with net margin ≥5% in recent years or trending upward).
- High-Turnover Thin-Profit: For membership/platform models (ROE >20%, OCF/NI >1.0, confirmed business type) where margins appear thin but capital efficiency is high.
If any exemption criteria are satisfied, the hard filter failure is waived and the company receives a "通过" (pass) status.
Generating Screening Reports
After processing all companies, the skill aggregates results into a structured markdown report (lines 96–138). The output includes:
- Pass list: Companies satisfying all seven filters (or qualifying exemptions)
- Exclusion list: Companies failing filters without valid exemptions
- Boundary cases: Companies with data gaps or marginal failures requiring manual review
- Sector insights: Aggregate statistics showing pass rates by industry
The report follows a strict markdown template defined in lines 66–89, ensuring compatibility with downstream automation tools like Slack bots or email pipelines.
Practical Usage Examples
Screening Individual Tickers
# Single-ticker mode with Chinese equities
result = await agent.run(
skill="quality-screen",
arguments="腾讯, 美团, 英伟达"
)
print(result) # Returns markdown report with pass/fail per company
Industry-Wide Screening
# Automatic expansion of beer industry constituents
result = await agent.run(
skill="quality-screen",
arguments="中国啤酒行业"
)
Index Constituent Screening
# Full CSI 300 index screening
result = await agent.run(
skill="quality-screen",
arguments="沪深300"
)
Summary
- Seven hard filters in
skills/quality-screen.mdenforce minimum standards for ROE (≥8%), FCF (positive 5-year), interest coverage (≥2×), gross margin (≥15%), OCF/NI (≥0.7), net margin (≥5%), and dilution (≤20%). - Parallel agent architecture spawns background processes per company to fetch financial data from annual reports, broker research, and data platforms simultaneously.
- Three exemption rules allow strategic cases (young growth companies, reinvestment phases, asset-light platforms) to bypass specific filters when they meet alternative criteria.
- Strict markdown output standardizes results into pass lists, exclusion lists, and sector insights for automated downstream consumption.
Frequently Asked Questions
What happens if a company fails just one of the seven hard filters?
According to the logic in quality-screen.md lines 36–63, a failing company is immediately flagged for exclusion unless it satisfies one of the three exemption rules (strategic-investment, intentional low-profit, or high-turnover thin-profit). The skill operates on a "漏网不可误杀" (better to miss a good company than let a bad one through) philosophy, making filters strict but allowing overrides only for specific business model justifications.
Are financial institutions treated differently by the quality-screen skill?
Yes. Lines 52–60 of the source code explicitly exempt banks and insurance companies from the interest-coverage filter (Filter 3), as their business models inherently involve interest-bearing liabilities. Additionally, REITs receive special handling for ROE calculations due to their high leverage structures and regulatory distribution requirements.
How does the skill handle incomplete financial data?
The parallel data collection agents (lines 81–94) prioritize sources hierarchically: annual reports first, then broker research, then financial platforms. If critical data points remain missing after exhausting these sources, the skill places the company in a boundary cases section of the final report rather than making assumptions, allowing human analysts to decide whether to procure additional data or exclude the security.
Can the seven filter thresholds be customized without modifying code?
Yes. Because the thresholds are stored in a declarative markdown table within skills/quality-screen.md (lines 24–35), non-engineers can adjust the cut-off values (e.g., changing ROE from 8% to 10%) by editing the table directly. The scripts/sync-codex-skills.py utility ensures these changes propagate to the Codex-compatible prompt version automatically, maintaining synchronization between Claude-Code and Codex environments.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →