DEV Community

QuoLu
QuoLu

Posted on

Published Throughline to npm: A hook to offload Claude Code tool I/O to SQLite

I have published a hook plugin for Claude Code called Throughline to npm.

What it does

In a Claude Code session, the majority of the context is filled with the remnants of "tool I/O." The contents of read files, grep results, and Bash output—data that served its purpose the moment the AI read it, made a decision, and moved on. However, it stays in the context until the end, consuming tokens.

Throughline manages the conversation in three layers.

Layer Content Context Injection
L2 Conversation body (user input + AI response) Last 20 turns injected as is
L1 Summarized version of L2 (1/5th size) while retaining key points Injected for turns older than 20
L3 Tool I/O, system messages, and thinking Not injected; offloaded to SQLite, retrieved by Claude as needed

Since tool I/O is completely removed from the context, read grep results and Bash outputs do not linger until the end of the session. Older conversations are compressed to 1/5th of their original size while keeping key points, so you can still follow the context of decisions made dozens of turns ago.

In a 50-turn session on my machine, a conversation that consumed 125,000 tokens was reduced to within 13,000 tokens.

Installation

npm install -g throughline
throughline install
Enter fullscreen mode Exit fullscreen mode

install registers the hook in ~/.claude/settings.json. It runs automatically for all Claude Code projects on your PC. No configuration is required for individual projects.

Carrying over between sessions

Throughline offloads conversations to SQLite, so the data remains even after running /clear. If you want to carry over your memory to the next session, type /tl in the previous session.

Data is only carried over to the next session when you type /tl. If you don't type it, it starts as a fresh session. Even if you open parallel windows or restart VSCode, it is designed so that it "won't fire accidentally unless you type /tl."

When carrying over, the "next step memo" written by the previous Claude and the internal reasoning (thinking) of the final turn are passed along as well. The next Claude runs in "continue from interruption" mode rather than "reading past logs" mode.

Token Monitor

As a byproduct, a multi-session capable token monitor is included.

throughline monitor
Enter fullscreen mode Exit fullscreen mode
[Throughline] 1 session
▶ Throughline  2ed5039c  ████░░░░░░░░░░░░░░░░  205.1k /  21%  Remaining 794.9k  claude-opus-4-6
Enter fullscreen mode Exit fullscreen mode

Since it reads actual API values (message.usage) from the transcript JSONL, it provides accurate values rather than estimates based on character count / 4. It also supports automatic detection of 1M context windows.

Requirements

  • Node.js 22.5+ (uses the built-in node:sqlite module)
  • Claude Code (supports hooks)
  • Claude Max plan (used for Haiku calls for L1 summarization; no API key required)
  • Windows / macOS / Linux

Dependencies

Zero. The tarball published to npm contains only .mjs files. No build process or native bindings are required.


The background of the design and my trial-and-error process are written in this article.

Throughline — GitHub

MIT licensed. Bug reports and PRs are welcome.

Top comments (0)