agentleFS
pppop00pppop00/revenue-flow-skills/revenue-flow-diagram/SKILL.md

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.

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
  1. Very specific:

    Use the pdf-reading skill at /mnt/skills/public/pdf-reading/SKILL.md to extract text from the uploaded PDF.

    line 23
  2. Distinctive:

    Look for: "Revenue by segment", "Disaggregation of revenue", or the top lines of the income statement

    line 37
  3. Distinctive:

    If only total revenue is available (no breakdown), use a single "Total Revenue" node

    line 39
  4. Distinctive:

    All numbers must tie: Revenue segments must sum to Total Revenue (±1% rounding)

    line 61
  5. Distinctive:

    Use the EXACT labels from the filing, not generic names

    line 64
  6. Distinctive:

    Keep the same unit (millions/billions) throughout

    line 65
  7. Distinctive:

    If a line item is negative (e.g., operating loss), handle gracefully — see rendering notes

    line 66
  8. Distinctive:

    If the filing provides segment operating income (profit by segment), also extract:

    line 103
  9. Distinctive:

    Use a clean sans-serif font (system font stack)

    line 135
  10. Distinctive:

    If Operating Income is negative, the flow reverses: show Operating Loss flowing OUT from expenses

    line 156
  11. Distinctive:

    Use red coloring for the loss node

    line 157
  12. Distinctive:

    If a company has more than 6 segments, group smaller ones into "Other" to keep the diagram readable

    line 161
  13. Distinctive:

    Default to the primary segmentation used in the income statement

    line 166
  14. Distinctive:

    If user requests segment view, use segment data from the notes

    line 167
  15. Distinctive:

    Use the currency stated in the filing (USD, EUR, etc.)

    line 175
  16. Distinctive:

    If ambiguous, ask the user which period they want

    line 181
  17. Distinctive:

    Before outputting the final diagram, verify:

    line 185

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  1. Revenue sources (left) → Total Revenue (center-left)
  2. Total Revenue → Cost of Revenue + Gross Profit (center)
  3. Gross Profit → Operating Expenses breakdown + Operating Income (center-right)
  4. 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:

  1. All numbers must tie: Revenue segments must sum to Total Revenue (±1% rounding)
  2. Revenue - COGS = Gross Profit (verify this)
  3. Gross Profit - Total OpEx = Operating Income (verify this)
  4. Use the EXACT labels from the filing, not generic names
  5. Keep the same unit (millions/billions) throughout
  6. 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+)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.