halley

context-broker

Answers big-file reads with an exact skeleton: 80 to 95% fewer tokens, no second model

Area
Developer tools
Language
C++
License
MIT
Plate
No. 11 of 14
Fig. 11context-broker
Move your pointer over it

What came back

  1. 89%

    fewer tokens on big-file reads in a 506k-line monorepo, scanned in 296 ms.source

  2. ~1 ms

    to outline an 800-line file, with no second model in the loop.source

  3. 91 tokens

    to read a 102,448-token file as an exact outline.source

context-broker is a Claude Code hook that intercepts reads of large files and answers with the file's exact structure instead: imports, signatures and types as verbatim lines with real line numbers. It takes about a millisecond, runs entirely on your machine and sends nothing to another model. The agent then reads only the slices it needs by line range, so reading and editing a big file costs a fraction of a full read.

How it works

  1. 01

    A PreToolUse hook catches Read calls on files over 350 lines; small files, binaries, images and ranged reads pass straight through.

  2. 02

    The denial carries the answer: the file's skeleton, extracted by hand-rolled structural matchers for TypeScript, Python, Go, Rust, Java and more.

  3. 03

    The agent expands only the bodies it needs with ranged reads, which are never intercepted.

What it does

  • Verbatim source lines with real line numbers, so a skeleton can be incomplete but never wrong
  • Ranged reads always pass through, so the read-then-edit path needs no second full read
  • Fails open on any error, so the hook can never break a read
  • cb bench measures savings across your repo before you install, with no model calls
  • Also a CLI: skeleton, ranged read, log folding for noisy build output, and a running savings ledger