[{"data":1,"prerenderedAt":845},["ShallowReactive",2],{"figure-telemetry":3,"menu-audits":6,"menu-decisions":7,"menu-projects":23,"menu-workflows":99,"decision-0010-token-delegation":116},{"value":4,"alert":5},"18%",false,[],[8,11,14,17,20],{"label":9,"to":10},"0041 The visitor view becomes its own app, and the portal reads only as a developer platform","\u002Fdecisions\u002F0041-personal-site-splits-from-developer-portal",{"label":12,"to":13},"0040 Visitors land on the front page and toggle to the developer view","\u002Fdecisions\u002F0040-developer-portal-visitor-structure",{"label":15,"to":16},"0039 The developer portal is redesigned for visitors, from a twelve-site benchmark","\u002Fdecisions\u002F0039-developer-portal-benchmark",{"label":18,"to":19},"0038 Marina Roustan's discovery","\u002Fdecisions\u002F0038-marina-roustan-discovery",{"label":21,"to":22},"0013 New linters: the robustness gap is tsconfig and enforcement, not plugins","\u002Fdecisions\u002F0013-linter-coverage",[24,29,60,83],{"labelKey":25,"icon":26,"to":27,"badge":28},"app.menu.allProjects","i-lucide-layers","\u002Fprojects","11",{"labelKey":30,"icon":31,"to":32,"badge":33,"children":34},"app.menu.kinds.apps","i-lucide-app-window","\u002Fprojects?kind=apps","5",[35,40,45,50,55],{"label":36,"icon":31,"to":37,"badge":38,"coverage":39},"developer-portal","\u002Fprojects\u002Fdeveloper-portal","94%",94.37,{"label":41,"icon":31,"to":42,"badge":43,"coverage":44},"huella-legal","\u002Fprojects\u002Fhuella-legal","97%",97.48,{"label":46,"icon":31,"to":47,"badge":48,"coverage":49},"marina-roustan","\u002Fprojects\u002Fmarina-roustan","100%",100,{"label":51,"icon":31,"to":52,"badge":53,"coverage":54},"portfolio","\u002Fprojects\u002Fportfolio","91%",91.31,{"label":56,"icon":31,"to":57,"badge":58,"coverage":59},"wp-editor","\u002Fprojects\u002Fwp-editor","50%",49.89,{"labelKey":61,"icon":62,"to":63,"badge":64,"children":65},"app.menu.kinds.packages","i-lucide-package","\u002Fprojects?kind=packages","4",[66,71,75,80],{"label":67,"icon":62,"to":68,"badge":69,"coverage":70},"configs","\u002Fprojects\u002Fconfigs","76%",75.7,{"label":72,"icon":62,"to":73,"badge":48,"coverage":74},"content","\u002Fprojects\u002Fcontent",99.58,{"label":76,"icon":62,"to":77,"badge":78,"coverage":79},"i18n","\u002Fprojects\u002Fi18n","99%",99.08,{"label":81,"icon":62,"to":82,"badge":48,"coverage":49},"observability","\u002Fprojects\u002Fobservability",{"labelKey":84,"icon":85,"to":86,"badge":87,"children":88},"app.menu.kinds.infrastructure","i-lucide-server","\u002Fprojects?kind=infrastructure","2",[89,94],{"label":90,"icon":85,"to":91,"badge":92,"coverage":93},"scripts","\u002Fprojects\u002Fscripts","79%",78.6,{"label":95,"icon":85,"to":96,"badge":97,"coverage":98},"translations","\u002Fprojects\u002Ftranslations","93%",93.33,[100,103,106,109,112],{"label":101,"to":102},"Huella Legal","\u002Fworkflows\u002Fhuella-legal",{"label":104,"to":105},"Marina Roustan","\u002Fworkflows\u002Fmarina-roustan",{"label":107,"to":108},"Developer portal front door","\u002Fworkflows\u002Fdeveloper-portal-front-door",{"label":110,"to":111},"Huella Legal editorial","\u002Fworkflows\u002Fhuella-legal-editorial",{"labelKey":113,"icon":114,"to":115},"app.menu.newProject","i-lucide-plus","\u002Fworkflows\u002Fnew",{"id":117,"title":118,"body":119,"description":826,"extension":834,"kind":835,"meta":836,"navigation":840,"path":841,"seo":842,"stem":843,"url":835,"verdict":835,"__hash__":844},"docs\u002Fdocs\u002Fdecisions\u002F0010-token-delegation.md","🧭 Token delegation: nothing in this repo is big enough for the hook to fire",{"type":120,"value":121,"toc":825},"minimark",[122,126,131,167,170,174,185,237,248,289,299,333,342,348,396,408,414,428,450,465,495,527,556,562,625,629,729,733,756,771,794,806,810],[123,124,118],"h1",{"id":125},"token-delegation-nothing-in-this-repo-is-big-enough-for-the-hook-to-fire",[127,128,130],"h2",{"id":129},"context","Context",[132,133,134,135,139,140,143,144,147,148,151,152,155,156,159,160,163,164,166],"p",{},"Spotify's ",[136,137,138],"code",{},"shunt"," plugin cuts Claude Code token usage by routing routine I\u002FO away from the expensive\nmodel: a ",[136,141,142],{},"PreToolUse"," hook (",[136,145,146],{},"check-file-size",") hard-blocks any full-file ",[136,149,150],{},"Read"," over ",[136,153,154],{},"SHUNT_MIN_LINES","\n— default 350 — and redirects it to a worker model, and a second \"code-writer\" mode does the same for\ngenerating files from a spec plus reference files. Delegation runs through Spotify's internal Portal\nplatform (",[136,157,158],{},"portal-cli",", one ",[136,161,162],{},"aika:invoke-chat"," per call), which isn't available externally, so only\nthe pattern is reusable: a ",[136,165,142],{}," hook, a wrapper script against a cheap model, and a skill\ntelling Claude when to use it.",[132,168,169],{},"The question was whether that's worth building here, and it was explicitly gated on measuring first —\nhow much of actual usage in this repo is bulk reads and boilerplate versus novel reasoning.",[127,171,173],{"id":172},"result","Result",[132,175,176,184],{},[177,178,179,180,183],"strong",{},"The hook has one possible target in the whole repo, and it is ",[136,181,182],{},"pnpm-lock.yaml","."," The threshold is\n350 lines; the largest source file here is 332. The size distribution isn't close:",[186,187,188,213],"table",{},[189,190,191],"thead",{},[192,193,194,198,201,204,207,210],"tr",{},[195,196,197],"th",{},"Source files",[195,199,200],{},"Total lines",[195,202,203],{},"Median",[195,205,206],{},"p90",[195,208,209],{},"p99",[195,211,212],{},"Max",[214,215,216],"tbody",{},[192,217,218,222,225,228,231,234],{},[219,220,221],"td",{},"357",[219,223,224],{},"21,723",[219,226,227],{},"41",[219,229,230],{},"145",[219,232,233],{},"244",[219,235,236],{},"332",[132,238,239,240,243,244,247],{},"Counts exclude the lockfile and binary assets. The lockfile is the single exception at 21,160 lines,\nand it is the exception that makes the point: in 114 sessions it was read ",[177,241,242],{},"once",", as a ten-line\nranged window rather than a full-file read, which is not what the hook blocks. A lockfile is a ",[136,245,246],{},"grep","\ntarget, not something a worker model is asked to summarise — so the repo's only tracked match above\nthe threshold is a file where delegation has nothing to delegate.",[132,249,250,253,254,257,258,261,262,264,265,268,269,272,273,276,277,280,281,284,285,288],{},[177,251,252],{},"Generated output is where the genuinely large files live, and it is never read."," Build artifacts\ndwarf anything tracked — ",[136,255,256],{},"apps\u002Fhuella-legal\u002F.output\u002Fserver\u002Fchunks\u002Fvirtual\u002Fentry.mjs"," is 51,955 lines,\n",[136,259,260],{},".nx\u002Fworkspace-data\u002Fproject-graph.json"," 47,595 — so the hazard the hook guards against is real in\nprinciple. It has not once materialised: across all 1,007 ",[136,263,150],{}," calls, ",[177,266,267],{},"zero"," touched ",[136,270,271],{},".nuxt\u002F",",\n",[136,274,275],{},".output\u002F",", ",[136,278,279],{},".nx\u002F"," or a coverage report, and the eight that reached into ",[136,282,283],{},"node_modules"," were all\ntype-definition lookups well under the threshold. The structural reason is that every one of those\npaths is ",[136,286,287],{},".gitignore","d build output with nothing in it worth opening.",[132,290,291,292,298],{},"Measured usage agrees. Across every Claude Code session run against this repo between 2026-08-31 and\n2026-09-14 — 114 sessions, 556 human turns, 9,280 assistant messages — there were ",[177,293,294,295,297],{},"1,006 ",[136,296,150],{},"\ncalls, and exactly 2 returned more than 350 lines",":",[186,300,301,311],{},[189,302,303],{},[192,304,305,308],{},[195,306,307],{},"Lines",[195,309,310],{},"What it was",[214,312,313,325],{},[192,314,315,318],{},[219,316,317],{},"872",[219,319,320,321,324],{},"a ",[136,322,323],{},"pnpm audit"," dump written to a scratchpad earlier in the same session",[192,326,327,330],{},[219,328,329],{},"437",[219,331,332],{},"Claude Code's own tool-results spill file",[132,334,335,336,338,339,183],{},"Neither is repo source, and neither is a case delegation helps: both were the agent pulling one\nspecific fact out of a generated dump, which is precisely what a worker-model summary loses. The\npremise ",[136,337,138],{}," is built on — large source files crowding out context — has ",[177,340,341],{},"zero instances here",[132,343,344,347],{},[177,345,346],{},"The cost ceiling confirms it rather than carrying the argument."," Priced at list API rates, the two\nweeks of sessions come to ~$600 ($5.26\u002Fsession). That is a shadow price, not a bill: this is\nsubscription usage, so the real currency is rate-limit headroom, and the ratios are what matter.",[186,349,350,363],{},[189,351,352],{},[192,353,354,357,360],{},[195,355,356],{},"Scenario",[195,358,359],{},"Cost",[195,361,362],{},"Share of spend",[214,364,365,383],{},[192,366,367,377,380],{},[219,368,369,370,373,374,376],{},"If ",[177,371,372],{},"all"," ",[136,375,150],{}," content were free",[219,378,379],{},"$24.35",[219,381,382],{},"4.1%",[192,384,385,390,393],{},[219,386,387,389],{},[136,388,138],{},"'s actual reach (>350-line reads)",[219,391,392],{},"$1.23",[219,394,395],{},"0.2%",[132,397,398,399,402,403,407],{},"Both are upper bounds — the model bills each read's tokens against every later assistant message in\nits session (an 88× amplification) and ignores compaction, which clears them. Tool-payload token\ncounts are estimated at four characters per token; the per-message figures come from the recorded\n",[136,400,401],{},"usage"," and are exact. Subagent turns are not written to the session transcripts at all, so every\ntotal here covers main-thread work only — which understates spend and therefore overstates the share\nthese reads represent. The plugin's headline 90% is ",[404,405,406],"em",{},"mean savings on the bulk reads themselves",", not\non a bill; 90% of a 4.1% ceiling is 3.7%, and 90% of what the hook actually catches here is about a\nfifth of one percent.",[132,409,410,413],{},[177,411,412],{},"Lowering the threshold doesn't rescue it."," At 200 lines the hook catches 45 reads (16.6% of all\nlines read) — worth $4.68, or 0.78%. To fire often in this repo a threshold would have to sit below\nthe size of an ordinary file here (median 41, p90 145), at which point the pattern inverts from\n\"delegate the bulk work\" into \"delegate everything\".",[132,415,416,419,420,423,424,427],{},[177,417,418],{},"The code-writer mode is smaller still."," All 358 ",[136,421,422],{},"Write"," calls together produced 266,087 tokens of\nfile content — 2.77% of output tokens, $5.57. Regenerating every one of them on ",[136,425,426],{},"claude-haiku-4-5","\ncosts $1.33, so the gross saving is $4.23, under 0.7% of spend — before subtracting the input tokens\nspent giving a worker model, on a cold cache, enough spec and reference material to match house\nconventions. At a median 2,028 characters per write, these are small files, not boilerplate slabs;\nthe delegation round-trip plausibly costs more than it saves.",[132,429,430,433,434,437,438,441,442,445,446,449],{},[177,431,432],{},"Reproducing the pattern needs no Portal, no wrapper and no second key — and that is what sinks it.","\nClaude Code delegates to a cheaper model natively: an agent definition carrying ",[136,435,436],{},"model: haiku",", or a\n",[136,439,440],{},"model"," override on the call. This repo already does it —\n",[136,443,444],{},"repo-review-card.md"," pins ",[136,447,448],{},"model: sonnet"," — and\ndelegation happened 89 times in the measured fortnight. So the cost of the\nmechanism is near zero, and the question collapses to whether delegating a single read can pay for\nthe context a delegate has to stand up first.",[132,451,452,453,456,457,460,461,464],{},"It can't. A session here needs a median of ",[177,454,455],{},"38,038 tokens"," of system prompt, tool definitions and\n",[136,458,459],{},"CLAUDE.md"," before its first reply; a subagent's is narrower but the same order of magnitude. A\n350-line read is roughly 4,000 tokens and the largest read in the corpus was ~9,000. ",[177,462,463],{},"Delegating one\nread spends tens of thousands of tokens to avoid carrying a few thousand",", and returns a summary\ninstead of the file — so it loses fidelity and money at once. Haiku's lower rate doesn't close a gap\nof that shape.",[132,466,467,468,471,472,475,476,479,480,483,484,487,488,491,492,494],{},"That also explains where delegation ",[404,469,470],{},"does"," pay, and why no plugin is needed to get it: collapsing\n",[404,473,474],{},"many"," reads into one conclusion amortises the standup across all of them. That is exactly what the\n89 existing ",[136,477,478],{},"Agent"," calls do — 27 ",[136,481,482],{},"Explore",", 23 ",[136,485,486],{},"repo-review-card",", 21 ",[136,489,490],{},"general-purpose",". ",[136,493,138],{},"\nhooks the per-read granularity, which is the one granularity that cannot pay for itself.",[132,496,497,500,501,503,504,507,508,511,512,514,515,518,519,522,523,526],{},[177,498,499],{},"As cheap insurance against the generated-file case, it fails on its own terms."," Three things have\nto hold for \"install it just in case\" to pay, and none do. The harness already caps the accident:\nClaude Code's ",[136,502,150],{}," returns at most 2,000 lines by default, so opening ",[136,505,506],{},"entry.mjs"," costs one\ntruncated page rather than 52,000 lines, and oversized tool results are spilled to a file instead of\ninto context — the 437-line read in the table above ",[404,509,510],{},"is"," that spill mechanism, caught in the act. The\nhook also covers the wrong channel: it gates ",[136,513,150],{}," only, while ",[136,516,517],{},"Bash"," is the larger payload source\nhere, so a ",[136,520,521],{},"cat",", a ",[136,524,525],{},"grep -r"," or a captured build log walks straight past it. And the premium is paid\ncontinuously — a hook, a skill, and a hard block sitting in the read path where a misfire costs a\nturn — against a payout measured in cents.",[132,528,529,530,533,534,537,538,541,542,276,545,272,548,551,552,555],{},"Insurance proportionate to the risk already exists and costs nothing: ",[136,531,532],{},".claude\u002Fsettings.json"," denies\n",[136,535,536],{},"Read(**\u002F.env)"," today, and the same ",[136,539,540],{},"deny"," list takes ",[136,543,544],{},"Read(**\u002F.nuxt\u002F**)",[136,546,547],{},"Read(**\u002F.output\u002F**)",[136,549,550],{},"Read(.nx\u002F**)"," and ",[136,553,554],{},"Read(**\u002Fcoverage\u002F**)"," with no second model, no key and no maintenance.",[132,557,558,559,561],{},"Three things the measurement did surface, none of which ",[136,560,138],{}," addresses:",[563,564,565,608,619],"ul",{},[566,567,568,574,575,577,578,580,581,588,589,592,593,595,596,599,600,603,604,607],"li",{},[177,569,570,571,573],{},"The static preamble costs nine times what all ",[136,572,150],{}," content does."," System prompt, tool\ndefinitions, MCP surface and ",[136,576,459],{}," come to a median 38,038 tokens before the first reply, and\nevery later message re-reads them — 36.5% of all cached input across the corpus, ~$120 of the ~$600.\nIt grew from ~34k to ~45k over the fortnight, tracking Claude Code releases. Only ~3,600 tokens of\nit are this repo's (",[136,579,459],{}," 2,683, the skill listing 896, agents 55), so most is not ours to\ncut — but ",[582,583,585],"a",{"href":584},"repo:.mcp.json",[136,586,587],{},".mcp.json"," passes ",[136,590,591],{},"--minimal=false"," to the nx MCP server, un-hiding\nsix workspace-analysis tools that were called ",[177,594,267],{}," times in 114 sessions. ",[136,597,598],{},"--minimal"," defaults\nto ",[136,601,602],{},"true"," and keeps ",[136,605,606],{},"nx_docs",", the only nx tool actually used (3 calls).",[566,609,610,618],{},[177,611,612,614,615,617],{},[136,613,517],{}," returns more into context than ",[136,616,150],{}," does"," — 46.8% of tool-result payload against 43.4%.\nIf context cost is ever worth chasing here, file reads are not where it lives. Unquantified: the\namplification and size distribution of those calls weren't measured.",[566,620,621,624],{},[177,622,623],{},"111 reads (11%) re-read a path already read in that same session",", content that was still in\ncontext. That is real waste, but it's a prompting problem, not a routing one — a second model would\nbe paid to re-fetch what the first model already had.",[127,626,628],{"id":627},"options-considered","Options considered",[186,630,631,641],{},[189,632,633],{},[192,634,635,638],{},[195,636,637],{},"Option",[195,639,640],{},"Why not",[214,642,643,654,662,670,681,689,712],{},[192,644,645,651],{},[219,646,647,648,650],{},"Port ",[136,649,138],{}," as-is (350-line threshold)",[219,652,653],{},"No source file reaches the threshold, and the files that do — the lockfile, build output — are never full-read; it fires twice in 114 sessions, both times on generated dumps outside the repo",[192,655,656,659],{},[219,657,658],{},"Port it with a lowered threshold",[219,660,661],{},"200 lines reaches 0.78% of spend; a threshold that fires often would sit below the median file size and delegate ordinary reads",[192,663,664,667],{},[219,665,666],{},"Adopt only the code-writer mode",[219,668,669],{},"≤0.7% of spend gross, before the worker's cold-cache input cost; median write is 2 KB, not boilerplate",[192,671,672,678],{},[219,673,674,675,677],{},"Skip Portal; delegate to a ",[136,676,436],{}," subagent instead",[219,679,680],{},"The mechanism is free and already in use here, but a delegate stands up ~38k tokens of context to avoid carrying a ~4k read — per-read delegation cannot pay for itself at any worker price",[192,682,683,686],{},[219,684,685],{},"Build it anyway, ahead of growth",[219,687,688],{},"The trigger is a file size this repo's own structure works against; packages export small focused source files, so nothing is trending toward 350 lines",[192,690,691,694],{},[219,692,693],{},"Install it as insurance against a stray read of build output",[219,695,696,697,699,700,702,703,705,706,708,709,711],{},"The one case it would catch is already capped by ",[136,698,150],{},"'s 2,000-line default and the spill-to-file mechanism, and it gates ",[136,701,150],{}," while ",[136,704,517],{}," is the larger payload channel — a ",[136,707,521],{}," of ",[136,710,506],{}," bypasses it entirely",[192,713,714,717],{},[219,715,716],{},"Deny reads of generated paths instead",[219,718,719,722,723,725,726,728],{},[177,720,721],{},"Not rejected"," — this is the proportionate form of the same insurance, and ",[136,724,532],{}," already denies ",[136,727,536],{}," by the same mechanism",[127,730,732],{"id":731},"consequences","Consequences",[132,734,735,736,738,739,742,743,748,749,755],{},"No ",[136,737,142],{}," hook and no delegation skill. The two ",[136,740,741],{},"PostToolUse"," hooks in\n",[582,744,746],{"href":745},"repo:.claude\u002Fsettings.json",[136,747,532],{}," stay the only hooks in the repo. Cheap-model\ndelegation stays where it already works: agent definitions under ",[582,750,752],{"href":751},"repo:.claude\u002Fagents",[136,753,754],{},".claude\u002Fagents\u002F",",\nchosen per task, at the granularity that amortises the standup cost.",[132,757,758,759,276,761,272,763,551,765,767,768,770],{},"The one piece worth taking is not the plugin: adding ",[136,760,544],{},[136,762,547],{},[136,764,550],{},[136,766,554],{}," to the existing ",[136,769,540],{}," list closes the generated-output\ncase outright, for the cost of four lines and no new dependency. That is a separate change and is not\nmade by this report.",[132,772,773,774,777,778,781,782,785,786,789,790,793],{},"What forecloses it is a property of the repo, not of the plugin, so the condition to revisit is\nspecific: ",[177,775,776],{},"a project here starts carrying source files in the 400+ line range"," — a checked-in\ngenerated client, a vendored schema, a large fixture — or bulk reads of files outside the repo become\nroutine rather than incidental. Re-running the measurement is the check, but not from the session\ntranscripts under ",[136,779,780],{},"~\u002F.claude\u002Fprojects\u002F",": that format is internal to Claude Code and changes between\nreleases, so the scripts behind these numbers are a one-off, not a tool to keep. ",[136,783,784],{},"\u002Fcontext"," reports\nthe live breakdown, and a ",[136,787,788],{},"statusLine"," script receives ",[136,791,792],{},"context_window"," token counts on stdin.",[132,795,796,797,799,800,802,803,805],{},"If context cost does become a pain point before either happens, the measurement gives the order to\nwork in: the static preamble first (nine times the size of the prize ",[136,798,138],{}," chases, and the\n",[136,801,591],{}," flag is a one-word fix), then ",[136,804,517],{}," output volume, then within-session re-reads.\nAll three are cheaper to address than a two-model router, and none needs a hook.",[127,807,809],{"id":808},"confirmation","Confirmation",[132,811,812,814,815,817,818,820,821,824],{},[136,813,532],{}," carries no ",[136,816,142],{}," hook — only the two ",[136,819,741],{}," ones this report\nalready counts. No ",[136,822,823],{},".agents\u002Fskills\u002F"," folder for delegation exists either. Both are the negative\nclaim this record makes, so their absence is what verifies it.",{"title":826,"searchDepth":827,"depth":827,"links":828},"",2,[829,830,831,832,833],{"id":129,"depth":827,"text":130},{"id":172,"depth":827,"text":173},{"id":627,"depth":827,"text":628},{"id":731,"depth":827,"text":732},{"id":808,"depth":827,"text":809},"md",null,{"issue":837,"status":838,"decision":839},101,"wont-implement","accepted",true,"\u002Fdocs\u002Fdecisions\u002F0010-token-delegation",{"title":118,"description":826},"docs\u002Fdecisions\u002F0010-token-delegation","8_bmnHXmMVCp8TyRVQ2M-KHrZY1SEo1oIiewMPq8Z2c",1795478398088]