CLAUDE LABJP
2.1.273 — A round of connection work landed together: five opt-in headers for LLM gateways, and a notice when Claude Code stops trying to reconnect an MCP server09/29 — The date beside claude-sonnet-4-5 is 12 days out, but it is an earliest-possible estimate. The model is still Active, and public retirements get at least 60 days noticeMCP — People keep asking to reconnect a dropped server without ending the session. The disconnect is now announced, but reattaching is still something you do by handNEW — A scheduled task ran some days and not others. The cause was that only one folder had been bound to itWINDOWS — When Cowork fails on its very first task, check developer mode and the setup state before going looking for a causeHANDOFF — Before a long draft gets too heavy for one chat, decide on the three things the summary must carry into the next one2.1.273 — A round of connection work landed together: five opt-in headers for LLM gateways, and a notice when Claude Code stops trying to reconnect an MCP server09/29 — The date beside claude-sonnet-4-5 is 12 days out, but it is an earliest-possible estimate. The model is still Active, and public retirements get at least 60 days noticeMCP — People keep asking to reconnect a dropped server without ending the session. The disconnect is now announced, but reattaching is still something you do by handNEW — A scheduled task ran some days and not others. The cause was that only one folder had been bound to itWINDOWS — When Cowork fails on its very first task, check developer mode and the setup state before going looking for a causeHANDOFF — Before a long draft gets too heavy for one chat, decide on the three things the summary must carry into the next one
Articles/Claude Code
Claude Code/2026-08-14Advanced

One generated file outweighed all 70 hand-written source files, so I redrew what Claude Code may read

I profiled a repository I actually run to see which areas consume the most context. Here is what I found, the deny rules I settled on, how search selectivity changes the math, and the options I considered but rejected.

Claude Code253settings.json8context10cost design4repository operations

Premium Article

"Which file decides where the preview gets cut off?" I asked Claude Code that about a site I run.

The answer came back correct — two files, precisely identified. What surprised me was the volume read along the way. It went well past what I had pictured when I said "just go find it."

As an indie developer working alone, there is nobody to point out that kind of friction. So before changing how I explore, I decided to measure the repository itself. You cannot decide what to exclude until you know what weighs what.

The finding that stopped me: a single generated file — one that gets rebuilt on every build — outweighed all seventy hand-written source files combined.

Measure the repository before the session starts

The subject is the claudelab.net repository: a Next.js site holding 806 Japanese and 806 English articles as MDX, with 1,796 files under version control.

I started with a small script that ranks areas by "how heavy is this to read." There is no need to replicate a tokenizer exactly. As long as areas can be compared against each other, the decision is the same. Japanese characters count as roughly one token each; everything else as roughly 3.6 characters per token.

#!/usr/bin/env python3
"""ctxweight.py - rank version-controlled files by how heavy they are to read.
 
Usage:
    python3 ctxweight.py            # whole repository
    python3 ctxweight.py src        # one directory
"""
import collections
import subprocess
import sys
 
PRICE_PER_MTOK = 2.0  # input price in USD per 1M tokens; substitute your own model's
 
 
def estimate_tokens(text: str) -> int:
    """Approximate CJK at ~1 char per token and everything else at ~3.6 chars.
 
    Exact counts depend on the model's tokenizer, so treat this as a relative
    measure -- "area A is N times area B" -- rather than an absolute figure.
    """
    cjk = sum(1 for ch in text if ' ' <= ch <= '鿿' or '＀' <= ch <= '￯')
    return int(cjk + (len(text) - cjk) / 3.6)
 
 
def tracked_files(roots):
    # git ls-files means .gitignore'd paths drop out without a hand-kept list
    out = subprocess.check_output(['git', 'ls-files', '-z'] + list(roots)).decode()
    return [f for f in out.split('\0') if f]
 
 
def group(path: str) -> str:
    parts = path.split('/')
    return '/'.join(parts[:2]) if len(parts) > 1 else '(root)'
 
 
def main():
    agg = collections.defaultdict(lambda: [0, 0])  # [tokens, files]
    per_file = []
 
    for path in tracked_files(sys.argv[1:]):
        try:
            text = open(path, encoding='utf-8').read()
        except (UnicodeDecodeError, OSError):
            continue  # binaries such as images are out of scope; skip quietly
        tokens = estimate_tokens(text)
        agg[group(path)][0] += tokens
        agg[group(path)][1] += 1
        per_file.append((tokens, path))
 
    total = sum(v[0] for v in agg.values()) or 1
    print(f"{'area':<28}{'est. tokens':>12}{'files':>7}{'share':>8}{'$/read':>9}")
    for key, (tokens, files) in sorted(agg.items(), key=lambda x: -x[1][0])[:15]:
        print(f"{key:<28}{tokens:>12,}{files:>7,}"
              f"{tokens / total * 100:>7.1f}%{tokens / 1e6 * PRICE_PER_MTOK:>9.3f}")
    print(f"{'total':<28}{total:>12,}"
          f"{sum(v[1] for v in agg.values()):>7,}{100.0:>7.1f}%"
          f"{total / 1e6 * PRICE_PER_MTOK:>9.3f}")
 
    print("\n-- heaviest individual files --")
    for tokens, path in sorted(per_file, reverse=True)[:5]:
        print(f"{tokens:>12,}  {path}")
 
 
if __name__ == '__main__':
    main()

Using git ls-files matters more than it looks. It drops node_modules and .next for free, and a hand-maintained exclusion list always drifts out of date.

Run against the whole repository:

AreaEst. tokensFilesShare
content/articles7,666,9271,61291.0%
src/generated289,60323.4%
repository root162,418151.9%
content/blog157,421701.9%
src/app80,278361.0%
src/components37,332220.4%
Total8,422,3231,796100%

Article bodies taking 91% is unremarkable for a content site. That line matched my expectations exactly.

The next line did not.

A generated file weighed 2.2 times all the code I wrote by hand

Narrow the scope to src and the distortion becomes obvious.

AreaEst. tokensFilesShare of src
src/generated289,603268.9%
src/app80,2783619.1%
src/components37,332228.9%
src/config8,11521.9%
src/lib and others5,029101.2%

All seventy hand-written source files together come to 130,754 tokens. src/generated reaches 289,603 across two files, with articles.json alone accounting for 284,072. A ratio of 2.21.

That file is metadata assembled mechanically from the MDX sources and rewritten on every build. Reading it adds no information whatsoever. Every fact inside it already lives under content/.

Yet in any exploration scoped to src, it sits right at the front of the queue. The filename says articles.json and the path says src, and both read as important. Files that look central by name and location are sometimes the derived ones.

Converted to input price, those two files cost about USD 0.58 per read. Reading every hand-written file costs USD 0.26. The side carrying zero new information was more than twice as expensive.

Prices move, of course. Sonnet 5's input price became permanent at USD 2 per million tokens on 10 August 2026, and the increase that had been scheduled for 1 September will not happen. Still, replace PRICE_PER_MTOK with a figure you have checked yourself rather than trusting a number in an article.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
You will be able to pinpoint which parts of your own repository eat context, using a single command, and decide what to exclude with evidence behind it
You will be able to avoid the failure where generated artifacts quietly enter exploration, inflating input cost and muddying reasoning at the same time
You will be able to recognise the cases where a poorly scoped search costs more than simply reading the files
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $15 for lifetime access
View Membership →

Related Articles

Claude Code2026-08-27
Curating the /model picker with modelPicker, and what replacing the lineup hides
Claude Code v2.1.242 added modelPicker, which lets you write the /model lineup yourself. Here is how appending differs from replacing, why project settings are ignored, and where it quietly narrows what availableModels allows.
Claude Code2026-08-27
Trusting the allow rules in your repo, or moving them to the environment
On disposable machines, the permissions.allow rules committed to your repo are dropped while the workspace waits to be trusted. Here is what gets dropped and what survives on 2.1.246, where each kind of rule belongs, and a preflight that catches the gap before a run starts.
Claude Code2026-08-25
A One-Letter Typo in settings.json Is Ignored Without a Single Warning
I diffed claude doctor output between a settings.json with misspelled keys and a correct one. There was no difference at all. Here is what actually gets validated, what slips through, and a small check that catches typos before they cost you a day.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links