revenue-flow-diagram
Skill0 starsChanged 8 months agoApache-2.0View on GitHub
Generate a Sankey-style revenue flow diagram from SEC filings (10-Q or 10-K). Use this skill whenever the user uploads a 10-Q, 10-K, annual report, or quarterly earnings document and wants a visual breakdown of revenue → costs → profit flow, an income statement visualization, a revenue waterfall, or a financial Sankey diagram. Also trigger when the user asks to visualize how a company makes money, or requests a P&L flow chart from any financial filing.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 16 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Use the pdf-reading skill at /mnt/skills/public/pdf-reading/SKILL.md to extract text from the uploaded PDF.
- Distinctive: line 37
Look for: "Revenue by segment", "Disaggregation of revenue", or the top lines of the income statement
- Distinctive: line 39
If only total revenue is available (no breakdown), use a single "Total Revenue" node
- Distinctive: line 61
All numbers must tie: Revenue segments must sum to Total Revenue (±1% rounding)
- Distinctive: line 64
Use the EXACT labels from the filing, not generic names
- Distinctive: line 65
Keep the same unit (millions/billions) throughout
- Distinctive: line 66
If a line item is negative (e.g., operating loss), handle gracefully — see rendering notes
- Distinctive: line 103
If the filing provides segment operating income (profit by segment), also extract:
- Distinctive: line 135
Use a clean sans-serif font (system font stack)
- Distinctive: line 156
If Operating Income is negative, the flow reverses: show Operating Loss flowing OUT from expenses
- Distinctive: line 157
Use red coloring for the loss node
- Distinctive: line 161
If a company has more than 6 segments, group smaller ones into "Other" to keep the diagram readable
- Distinctive: line 166
Default to the primary segmentation used in the income statement
- Distinctive: line 167
If user requests segment view, use segment data from the notes
- Distinctive: line 175
Use the currency stated in the filing (USD, EUR, etc.)
- Distinctive: line 181
If ambiguous, ask the user which period they want
- Distinctive: line 185
Before outputting the final diagram, verify:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Revenue Flow Diagram Generator
Generate a professional Sankey-style revenue flow diagram from SEC filings (10-Q / 10-K), similar to the visual income statement breakdowns popularized by financial media.
Overview
This skill takes an uploaded 10-Q or 10-K filing and produces an interactive HTML Sankey diagram showing:
- Revenue sources (left) → Total Revenue (center-left)
- Total Revenue → Cost of Revenue + Gross Profit (center)
- Gross Profit → Operating Expenses breakdown + Operating Income (center-right)
- Operating Income → Tax + Other items + Net Income (right)
Step-by-Step Workflow
Step 1: Read the uploaded filing
Use the pdf-reading skill at /mnt/skills/public/pdf-reading/SKILL.md to extract text from the uploaded PDF. Focus on:
- Consolidated Statements of Income (or "Consolidated Statements of Operations")
- Revenue disaggregation notes (usually in the Notes to Financial Statements, often Note 1, 2 or a dedicated "Revenue" note)
- Segment information (for segment-level revenue breakdown)
Extract text first. If the income statement is in a complex table format, also rasterize that page for visual inspection.
Step 2: Parse financial data
Extract these specific line items (in millions or billions, matching the filing's unit):
Revenue side (sources):
- Segment revenues OR product/service revenue lines
- Look for: "Revenue by segment", "Disaggregation of revenue", or the top lines of the income statement
- Common patterns: Product vs Service revenue, or named business segments
- If only total revenue is available (no breakdown), use a single "Total Revenue" node
Cost side:
- Cost of revenue / Cost of goods sold (COGS)
- Gross profit (= Revenue - COGS)
Operating expenses (itemized):
- Research and development (R&D)
- Sales and marketing / Selling, general and administrative (SG&A)
- General and administrative (G&A) — sometimes combined with Sales as SG&A
- Depreciation and amortization (if broken out separately)
- Restructuring charges (if material)
- Other operating expenses
- Operating income / Operating profit
Below operating income:
- Interest income / expense (net)
- Other income / expense (net)
- Income tax provision
- Net income
CRITICAL DATA INTEGRITY RULES:
- All numbers must tie: Revenue segments must sum to Total Revenue (±1% rounding)
- Revenue - COGS = Gross Profit (verify this)
- Gross Profit - Total OpEx = Operating Income (verify this)
- Use the EXACT labels from the filing, not generic names
- Keep the same unit (millions/billions) throughout
- If a line item is negative (e.g., operating loss), handle gracefully — see rendering notes
Step 3: Structure the data
Organize into a JSON structure for the diagram:
{
"company": "Company Name",
"period": "Q2 FY2025 (Three Months Ended June 30, 2025)",
"unit": "$bn",
"currency": "USD",
"revenue_sources": [
{"name": "Segment A", "value": 16.6},
{"name": "Segment B", "value": 20.9},
{"name": "Segment C", "value": 14.4}
],
"total_revenue": 51.9,
"cost_of_revenue": 16.4,
"gross_profit": 35.4,
"gross_margin_pct": 68,
"operating_expenses": [
{"name": "Research & Development", "value": 6.9},
{"name": "Sales & Marketing", "value": 6.3},
{"name": "General & Admin", "value": 1.8}
],
"operating_income": 20.5,
"operating_margin_pct": 40,
"below_operating": [
{"name": "Tax", "value": 3.8, "type": "expense"},
{"name": "Other Income", "value": 0.5, "type": "income"}
],
"net_income": 16.7,
"net_margin_pct": 32
}If the filing provides segment operating income (profit by segment), also extract:
"segment_profits": [
{"name": "Segment A", "value": 7.2, "margin_pct": 44},
{"name": "Segment B", "value": 8.7, "margin_pct": 42},
{"name": "Segment C", "value": 4.6, "margin_pct": 32}
]Step 4: Generate the Sankey diagram
Create a single self-contained HTML file using D3.js (via CDN) that renders an interactive Sankey diagram. Use the helper script at scripts/sankey_template.py as a reference for the HTML structure and D3 Sankey layout, BUT you should adapt colors and labels to match the specific company.
Design specifications:
Layout (left → right flow):
[Revenue Sources] → [Total Revenue] → [Gross Profit] → [Operating Income] → [Net Income]
↘ [COGS] ↘ [OpEx items] ↘ [Tax, Other]Color scheme:
- Revenue sources: Use distinct, saturated colors per segment (blue, orange, green, purple, etc.)
- Total Revenue / Gross Profit / Operating Income / Net Income: Green spectrum (positive flow)
- Cost of Revenue: Red/coral
- Operating expenses: Red/orange spectrum (each item a slightly different shade)
- Tax: Red
- Net Income: Bright green (if profit) or red (if loss)
Typography:
- Company name + period as title
- Each node labeled with: Name, dollar amount, and margin % where applicable
- Use a clean sans-serif font (system font stack)
Interactivity:
- Hover on links to highlight the flow path and show exact values
- Hover on nodes to show detailed breakdown
- Responsive — scales to container width
Annotations:
- Show margin percentages (gross margin, operating margin, net margin) at key nodes
- Include the source period prominently
- Show unit (e.g., "All figures in $billions")
Step 5: Output
Save the HTML file to /mnt/user-data/outputs/ with a descriptive filename like {company}_revenue_flow_{period}.html.
Present the file to the user using present_files.
Handling Edge Cases
Companies with operating losses
- If Operating Income is negative, the flow reverses: show Operating Loss flowing OUT from expenses
- Use red coloring for the loss node
- Net Loss similarly shown in red
Very complex segment structures
- If a company has more than 6 segments, group smaller ones into "Other" to keep the diagram readable
- Maximum recommended segments: 6 (top-level nodes on left side)
Consolidated vs Segment reporting
- Some companies (e.g., Alphabet) report revenue by type AND by segment
- Default to the primary segmentation used in the income statement
- If user requests segment view, use segment data from the notes
Non-standard line items
- Some companies have unique items (e.g., "Content costs" for Netflix, "Traffic acquisition costs" for Google)
- Preserve the company's exact terminology
- Map to the correct position in the flow (cost of revenue vs. operating expense)
Foreign currency
- Use the currency stated in the filing (USD, EUR, etc.)
- Convert unit label accordingly ($bn, €bn, etc.)
Quarterly vs Annual
- For 10-K: Use full-year figures
- For 10-Q: Default to the most recent quarter (three months ended), NOT the year-to-date
- If ambiguous, ask the user which period they want
Quality Checklist
Before outputting the final diagram, verify:
- Revenue sources sum to Total Revenue (±1% tolerance for rounding)
- Revenue - COGS = Gross Profit
- Gross Profit - Total OpEx = Operating Income
- Operating Income ± below-the-line items - Tax = Net Income
- All labels match the filing's exact terminology
- Period is correctly stated
- Margin percentages are calculated correctly
- The HTML renders properly with D3 Sankey layout
- Colors are visually distinct and follow the positive/negative convention
- The diagram is readable on a standard screen width (1200px+)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

