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

Transforming Claude Code into an Autonomous Engineering Team
The ~/.claude/ configuration turns Claude Code into an autonomous build system, generating and testing code autonomously.

MCP Server for Local XMind Mind Map Files Released
A developer has published an MCP server that provides 22 tools for reading and writing local XMind mind map files. The server works with MCP-compatible AI clients like Claude Desktop and Cursor.

OpenClaw Local Agent Implementation with TurboQuant Caching for Mid-Range Hardware
A one-click app for OpenClaw with local models now runs on mid-range devices like MacBook Air with 16GB RAM using TurboQuant caching and context warming. The implementation patches llama.cpp for reliable tool calling and achieves 10-15 tokens per second with Gemma 4 and QWEN 3.5.

Implementing AI Checks with Continue for Source-Controlled PR Reviews
Continue integrates AI checks directly into your pull request workflow by using markdown files as source-controlled checks, visible through GitHub status checks.