Measuring Off-Task Token Spend in Claude Code: The 'Undeclared-Intent' Metric

A developer building custom hooks for Claude Code created a metric called undeclared-intent spend to measure token usage outside the declared objective.
Key Findings
- In one session, total compute was 5,137 tokens, with 1,173 (22.8%) classified as undeclared and 3,964 (77.2%) on-declared.
- Undeclared spend captures cost of retries, loops, reasoning drift, and off-task execution — not just governance violations.
- The metric treats cost as a behavioral signal, not billing telemetry alone.
Implementation Challenge
The hook surface doesn't always expose enough context to distinguish true drift from indeterminable intent. The author notes two distinct failure modes: genuine drift (wandered into unrelated files/systems) vs. indeterminable from hook data. Different responses needed per mode.
Example output format:
Total compute 5,137 tokens
Undeclared 1,173 tokens (22.8%)
Declared 3,964 tokens (77.2%)
No tool or library is shared in the source; the post is a discussion prompt. The author is interested whether others are measuring off-task compute or still treating token spend purely as billing/optimization.
📖 Read the full source: r/ClaudeAI
👀 See Also

Claude's Code Dashboard Tracks 19M+ AI-Generated Commits on GitHub
A developer built a dashboard tracking over 19 million commits generated by Claude Code on GitHub public repositories, showing TypeScript (35.3%), Python (19.2%), and JavaScript (10.3%) as the top languages. The system uses Next.js with Recharts and PostgreSQL, with an ETL pipeline that works around GitHub's API rate limits.

ClawProxy: Self-Hosted AI Routing Proxy for Rotating Free-Tier API Keys
ClawProxy is a self-hosted AI routing proxy that manages multiple free-tier AI API keys to avoid rate limits and provider overloads. It features in-flight key rotation, weighted load balancing, model translation, and a dashboard with deep-parsed logs.

Measuring Claude Code MCP Stack: Cache Friendliness vs. Byte Savings, and a 2-Line Fix for Prompt Cache
Greg Shevchenko benchmarks MCP compressors and retrieval layers on two axes: byte savings and cache friendliness. A 2-line fix (sort rg hits, sort map entries) boosts cache from ~0% to 100% with no byte-savings loss. Open-source harness included.

Jobly: Contract Marketplace with AI-First Dispute Resolution and Community Voting
Jobly is a contract marketplace built with Next.js 14, TypeScript, and Supabase, featuring an escrow system with 10% provider bonds on proposals and a dispute pipeline that starts with AI evaluation using Claude, then allows appeals to community stake voting.