AI-powered stock analysis patterns for StockFind. Includes bull/bear thesis, growth catalysts, risk analysis, and competitive landscape. Use when building AI analysis features, designing LLM prompts, working with the AI Analysis tab, or adding new analysis sections. Also use when implementing Pro tier gating for AI features.
GitHub Issue: #143
Status: Planned
Tier: Pro
Plan file: .claude/plans/harmonic-humming-piglet.md
Reference specific StockFind metrics in every AI insight. Never generate standalone prose without citing financial data.
| Section | Must Reference |
|---|---|
| Bull/Bear Thesis | Revenue CAGR, EPS growth, margins, ROIC, debt ratios |
| Growth Catalysts | Revenue trends, R&D intensity, capital allocation |
| Risk Analysis | Debt ratios, margin trends, concentration risk |
| Competitive Landscape | Health scores, valuation ratios, growth data |
Pattern: "Revenue CAGR of 35% over 5 years, outperforming the Technology sector benchmark of 12%" Not: "The company has strong revenue growth."
3 bull points + 3 bear points. Each has title, description, and dataReference (the specific metric cited). Frame as "potential considerations" not recommendations (SEC compliance).
3 key drivers grounded in financial evidence. Quantify where possible: "If this catalyst materializes, it could impact the model estimate by approximately X%."
3 short-term + 3 long-term risks. Quantify impact: "If this risk materializes, the model estimate may decrease by approximately X%." Connect to specific financial metrics.
3 primary competitors with comparative metrics from StockFind's existing health scores, valuation ratios, and growth data.
ai + @ai-sdk/anthropic)generateObject() with Zod schema for structured outputclaude-sonnet-4-5-20250514GET /stocks/:symbol/ai-analysis
stock:ai-analysis:{symbol}, 7 day TTL)| Layer | TTL | Tag |
|---|---|---|
| Redis | 7 days | stock:ai-analysis:{symbol} |
| Next.js | "weeks" | stock:ai-analysis:{symbol} |
const thesisPointSchema = z.object({
title: z.string(),
description: z.string(),
dataReference: z.string(),
});
const competitorSchema = z.object({
name: z.string(),
ticker: z.string(),
description: z.string(),
});
const aiAnalysisSchema = z.object({
bullThesis: z.array(thesisPointSchema).length(3),
bearThesis: z.array(thesisPointSchema).length(3),
growthCatalysts: z.array(thesisPointSchema).length(3),
shortTermRisks: z.array(thesisPointSchema).length(3),
longTermRisks: z.array(thesisPointSchema).length(3),
competitors: z.array(competitorSchema).length(3),
generatedAt: z.string(),
});
System prompt: Include SEC compliance constraints (no buy/sell, educational framing, use "suggests"/"indicates"/"may"), data-connected requirement ("every point must reference specific financial metrics provided"), and output format expectations.
User prompt: Provide company profile, key financials, valuation ratios, growth metrics (with sector benchmarks), ROIC vs WACC spread, and SBC metrics. Format for readability, not raw JSON.
Introduce tabs to the stock detail page:
Stock Header (persistent)
├── Tab: Overview (default) — all existing cards
└── Tab: AI Analysis (Pro) — AI content + Community Health Score
Manage tab state via nuqs search params for shareable URLs.
Location: apps/web/.../stocks/[symbol]/components/ai-analysis/
| Component | Purpose |
|---|---|
ai-analysis-content.tsx | Server component, fetch + render all sections |
bull-bear-card.tsx | Side-by-side thesis (green bull / red bear) |
growth-catalysts-card.tsx | Numbered growth drivers |
risks-card.tsx | Short-term / long-term columns |
competitors-card.tsx | Competitor cards with comparative metrics |
ai-disclosure.tsx | Reusable AI disclosure banner |
ai-analysis-skeleton.tsx | Loading skeleton for Suspense |
Include AI disclosure on every section: "This analysis was generated by AI for educational purposes." Use "suggests", "indicates", "may" — never "shows", "proves", "will". Frame thesis points as "potential considerations." No buy/sell/hold language. See .claude/rules/sec-compliance.md for full requirements.
apps/web/.../stocks/[symbol]/components/health-score-card.tsxapps/web/.../stocks/[symbol]/components/valuation-ratios-toggle.tsx.claude/rules/sec-compliance.md