Skip to content

feat: flow stats — local usage & ROI analytics#80

Merged
anshulsao merged 23 commits into
mainfrom
worktree-flow-roi-analytics
Jun 23, 2026
Merged

feat: flow stats — local usage & ROI analytics#80
anshulsao merged 23 commits into
mainfrom
worktree-flow-roi-analytics

Conversation

@anshulsao

@anshulsao anshulsao commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds flow stats (+ flow stats --card) — local, user-facing usage & ROI analytics derived entirely from data flow already keeps (flow.db + Claude session transcripts + on-disk auto-runs/owner/kb dirs). No schema change, no new instrumentation. A derived per-file cache makes repeat runs incremental — only changed transcripts are re-scanned.

Highlights

  • Lookups spine — counts every time flow served you stored context: resume / reference / cross-task / kb.
  • Memory-led framing — leads with the value every (manual) user gets: tokens of context you never re-typed, and instant in-context resumes. The automation tier (auto runs / owner ticks / playbook runs) and its $ figure appear only when you actually use it — a manual-only user sees no automation block and no dollar number.
  • File-size-grounded token model — "context re-established" sums the real byte-size of the brief/updates/KB each lookup served (not a flat multiplier), so it reflects every re-explanation eliminated.
  • Honesty by construction — ground-truth counts are exact; every estimate is labelled est.; assumptions live in user-editable ~/.flow/stats.json.
  • Shareable HTML card via --card [--out <path>].

How it works

internal/stats/ (pure logic): scan (jsonl → lookups + token usage) → cache (per-file, keyed by mtime+size) → report (BuildStats over db + transcripts + dirs) → model (counterfactual savings). Thin renderers in internal/app/{stats,card}.go. Reuses claude.EncodeCwd to locate transcripts; reads flow.db via flowdb.ListTasks. Config/cache are JSON (no TOML dependency — keeps the binary CGO-free and dependency-light).

Testing

  • TDD throughout; full go test ./... green.
  • Verified end-to-end on real data; cache confirmed incremental (touch one transcript → only that entry re-scans; 234/238 served from cache on a warm run).

Design spec + implementation plan under docs/superpowers/.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

Update — shareable PNG

Also adds flow stats --png: renders the card to a self-contained PNG with no browser/runtime dependency (pure-Go drawing via fogleman/gg + embedded Go fonts; CGO stays off). Cost: +1.27 MB binary (+7%), zero build-time impact, no new runtime deps. --card still emits HTML for those who prefer it.

anshulsao and others added 23 commits June 17, 2026 14:18
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sumption; punchier card subtitle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cross-task comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… compact number format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…in automation block

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ency)

Adds flow stats --png — renders the share card to a self-contained PNG with
no runtime dependency (pure-Go drawing via fogleman/gg + embedded Go fonts;
CGO stays off). Cost: +1.27MB binary (+7%), no build-time impact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nvas

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… hero, dark palette

Re-skins the PNG card to flow's brand: GitHub-dark palette (#0B0D10/#161B22),
1px bordered surface, the embedded flow wordmark (light flo + gradient wave-w,
30K transparent PNG), and the hero number filled with the brand wave gradient
(#0AEAA8 to #198FFF). Content-driven height; automation band only when used.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@anshulsao anshulsao merged commit f59f6a8 into main Jun 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant