Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
561 lines (509 loc) · 47.4 KB
/
Copy pathindex.html
File metadata and controls
561 lines (509 loc) · 47.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ThinWindow documentation</title>
<meta name="description" content="Less in the window. Don't pay for it twice. ThinWindow keeps Claude Code's context window thin for the whole session: it trims oversized reads and command logs, shows what each request carries, and offers a fresh start from a short brief after the prompt cache expires. Plugin and Agent Skill.">
<meta name="theme-color" content="#fcf9f4" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#121317" media="(prefers-color-scheme: dark)">
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon/favicon-32.png">
<link rel="icon" type="image/png" sizes="192x192" href="assets/favicon/favicon-192.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicon/favicon-180-precomposed.png">
<link rel="stylesheet" href="style.css">
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<div class="layout">
<aside class="sidebar">
<a class="brand" href="#overview">
<img src="assets/icon.iconset/icon_32x32@2x.png" alt="" width="32" height="32">
<span>ThinWindow <small>docs · v0.5.1</small></span>
</a>
<nav aria-label="Documentation">
<div class="nav-group">
<h2>Introduction</h2>
<ol>
<li><a href="#overview">Overview</a></li>
<li><a href="#problem">Why context is the bill</a></li>
</ol>
</div>
<div class="nav-group">
<h2>The four moments</h2>
<ol>
<li><a href="#start">Start</a></li>
<li><a href="#during">During</a></li>
<li><a href="#between">Between sessions</a></li>
<li><a href="#after">After</a></li>
</ol>
</div>
<div class="nav-group">
<h2>Usage</h2>
<ol>
<li><a href="#install">Install</a></li>
<li><a href="#surfaces">Where it works</a></li>
<li><a href="#configuration">Configuration</a></li>
<li><a href="#upgrading">Upgrading from 0.3.0</a></li>
</ol>
</div>
<div class="nav-group">
<h2>Trust</h2>
<ol>
<li><a href="#checked">How it's checked</a></li>
<li><a href="#privacy">What it reads, writes and sends</a></li>
<li><a href="#limitations">Limitations</a></li>
</ol>
</div>
<div class="nav-group">
<h2>Project</h2>
<ol>
<li><a href="#repository">Repository</a></li>
<li><a href="#faq">FAQ</a></li>
</ol>
</div>
</nav>
<div class="sidebar-foot">
MIT licensed · Node 18+ · zero dependencies<br>
<a href="https://github.com/thinwindow/thinwindow">Source on GitHub</a>
</div>
</aside>
<main id="main">
<div class="content">
<header class="hero" id="overview">
<img src="assets/icon.iconset/icon_128x128@2x.png" alt="ThinWindow logo" width="96" height="96">
<div>
<h1>ThinWindow</h1>
<p class="lede"><strong>Less in the window. Don't pay for it twice.</strong> ThinWindow keeps Claude Code's context window thin from the first prompt to the next morning. It trims oversized reads and logs while you work, shows what every request carries, and when you come back to an expired session, offers a fresh start from a short brief instead of paying for the old context again. Listed in the official Claude Code plugin directory.</p>
</div>
</header>
<section aria-labelledby="overview-h">
<h2 id="overview-h"><span class="num">01</span>Overview</h2>
<p>ThinWindow is a small, local plugin for Claude Code, and an Agent Skill for other agents. It works at the four moments of a session:</p>
<div class="cards">
<div class="card">
<h3>Start <span class="tag">setup</span></h3>
<p>Shows what every request carries, once a week per project, and offers an opt-in profile with fewer built-in tools.</p>
</div>
<div class="card">
<h3>During <span class="tag">guards</span></h3>
<p>Short rules, and hooks that trim oversized reads, logs and searches before they enter the context.</p>
</div>
<div class="card">
<h3>Between sessions <span class="tag">resume</span></h3>
<p>Keeps a brief of each session, and before you re-pay an expired one, offers a fresh start from it.</p>
</div>
<div class="card">
<h3>After <span class="tag">report</span></h3>
<p>Shows where your own sessions' context went, from the transcripts on your machine.</p>
</div>
</div>
<p><strong>Who it is for:</strong> people who run Claude Code for hours on real repositories, and pay for it in money or in usage limits.</p>
<p><strong>What it is not:</strong> a model, a proxy, a service or a memory system. Nothing is hosted, nothing is sent anywhere, and it changes no setting on its own.</p>
</section>
<section id="problem" aria-labelledby="problem-h">
<h2 id="problem-h"><span class="num">02</span>Why context is the bill</h2>
<p>A coding agent pays for what it carries more than for what it writes.</p>
<ul>
<li><strong>Every request re-sends the whole session.</strong> Each file Claude reads, each log it prints and each long answer stays in the conversation, and is paid again, from the prompt cache, on every request after it.</li>
<li><strong>An expired session gets paid for twice.</strong> Claude Code keeps a session's prompt cache for up to an hour. Come back later, and your next prompt writes the whole context again at the cache-write price, many times what reading it from the cache costs.</li>
<li><strong>Your setup rides on every request.</strong> The system prompt, the tool definitions, the skill and agent listings, MCP instructions and CLAUDE.md files go out with each one.</li>
</ul>
<figure class="illustration">
<div class="figure-box">
<svg viewBox="0 0 640 215" role="img" aria-labelledby="ill-t ill-d">
<title id="ill-t">How one early read is paid on every later turn</title>
<desc id="ill-d">Two sets of six bars. Each bar is the context sent on one turn. On the left, a whole file read on turn 2 adds a large block that is re-sent on turns 2 to 6. On the right, a ranged read adds a small block instead. The total area on the left is much larger.</desc>
<text class="title" x="20" y="16">Whole file read on turn 2</text>
<text class="title" x="350" y="16">Range read on turn 2</text>
<line class="axis" x1="10" y1="185" x2="300" y2="185"/>
<line class="axis" x1="340" y1="185" x2="630" y2="185"/>
<!-- left: base context grows a little each turn; the big read stays -->
<rect class="base" x="20" y="161" width="30" height="24"/>
<rect class="base" x="66" y="151.4" width="30" height="33.6"/><rect class="read" x="66" y="79.4" width="30" height="72"/>
<rect class="base" x="112" y="141.8" width="30" height="43.2"/><rect class="read" x="112" y="69.8" width="30" height="72"/>
<rect class="base" x="158" y="132.2" width="30" height="52.8"/><rect class="read" x="158" y="60.2" width="30" height="72"/>
<rect class="base" x="204" y="122.6" width="30" height="62.4"/><rect class="read" x="204" y="50.6" width="30" height="72"/>
<rect class="base" x="250" y="113" width="30" height="72"/><rect class="read" x="250" y="41" width="30" height="72"/>
<!-- right: same turns, a small ranged read -->
<rect class="base" x="350" y="161" width="30" height="24"/>
<rect class="base" x="396" y="151.4" width="30" height="33.6"/><rect class="read-small" x="396" y="137" width="30" height="14.4"/>
<rect class="base" x="442" y="141.8" width="30" height="43.2"/><rect class="read-small" x="442" y="127.4" width="30" height="14.4"/>
<rect class="base" x="488" y="132.2" width="30" height="52.8"/><rect class="read-small" x="488" y="117.8" width="30" height="14.4"/>
<rect class="base" x="534" y="122.6" width="30" height="62.4"/><rect class="read-small" x="534" y="108.2" width="30" height="14.4"/>
<rect class="base" x="580" y="113" width="30" height="72"/><rect class="read-small" x="580" y="98.6" width="30" height="14.4"/>
<g text-anchor="middle">
<text x="35" y="202">1</text><text x="81" y="202">2</text><text x="127" y="202">3</text><text x="173" y="202">4</text><text x="219" y="202">5</text><text x="265" y="202">6</text>
<text x="365" y="202">1</text><text x="411" y="202">2</text><text x="457" y="202">3</text><text x="503" y="202">4</text><text x="549" y="202">5</text><text x="595" y="202">6</text>
</g>
</svg>
</div>
<figcaption>Illustration, not measured data. Each bar is the context sent on one turn (1–6). A whole-file read on turn 2 (blue) is re-sent on every turn after it; a ranged read (orange) costs a fraction of that. The billed total is the area of all the bars.</figcaption>
</figure>
</section>
<section id="start" aria-labelledby="start-h">
<h2 id="start-h"><span class="num">03</span>Start: know what every request carries</h2>
<h3>The setup-cost notice</h3>
<p>Once a week per project, when a session's first request is 40k tokens or more, ThinWindow shows you one line: what every request in that session starts at, and its largest parts. It's shown to you and never sent to Claude. In the desktop app it appears as a collapsed "Claude Code notice". Example:</p>
<pre><code>ThinWindow: each request in this session starts at 54k tokens (skill listing 5.3k, deferred tools 2.5k, MCP instructions 1.6k). Run /context to see what you could turn off.</code></pre>
<h3><code>thinwindow-minimal</code>, an opt-in profile</h3>
<p>One file you copy, for focused coding sessions. It keeps Claude Code's own system prompt and your MCP tools, and removes the built-in tools the maintainer's sessions almost never used: subagents and agent teams; <code>/loop</code>, scheduled tasks, remote triggers and push notifications; background-task tools (background Bash commands still run); reading the task list back; worktrees, notebooks and multiple-choice questions; plan mode entered by Claude (Shift+Tab still works); the Skill tool and its listing (skills you type still run); and, in the desktop app, artifacts, design sync, file cards, feedback and review findings.</p>
<pre><code>curl -fsSL --create-dirs -o ~/.claude/agents/thinwindow-minimal.md https://raw.githubusercontent.com/thinwindow/thinwindow/main/profiles/thinwindow-minimal.md
claude --agent thinwindow-minimal</code></pre>
<p>Or, for every session in a project, <code>"agent": "thinwindow-minimal"</code> in that project's <code>.claude/settings.json</code>. ThinWindow never turns it on for you. Skip it when you want subagents, <code>/loop</code>, scheduled tasks or skills Claude starts on its own. While the file is in <code>~/.claude/agents/</code>, sessions that don't use it list it among your subagents, one line with its tool list; delete the file to remove it.</p>
</section>
<section id="during" aria-labelledby="during-h">
<h2 id="during-h"><span class="num">04</span>During: keep the window thin while you work</h2>
<p>The rules tell Claude what to do. The guards make sure the expensive part happens, because a rule the agent can forget under pressure is not a rule. They act on the tool call itself, before its result reaches the context, so enforcing them costs no extra turn.</p>
<h3>The rules</h3>
<p>This is the complete text added to Claude's context at session start, from <code>rules/thinwindow.md</code>. The Agent Skill, the <code>AGENTS.md</code> snippet and this page carry the same copy, and CI checks that they stay in sync. The rules stay under 2,000 characters.</p>
<!-- rules:start (generated from rules/thinwindow.md by scripts/sync-rules.mjs; edit the source, not this block) -->
<pre><code># thinwindow: spend fewer tokens
Everything you read or write stays in context and is re-sent on every later turn. Read, write and say only what the task needs.
Read less
- Locate before reading: grep or glob for the symbol, then read only the range around it.
- Don't read whole files over ~300 lines. Don't re-read what is already in context unless it changed.
- Batch independent lookups into one call. Stop exploring once you have enough to act.
- To count, search or summarize across many files, run one command that prints only the answer.
- Don't send a subagent to explore what one grep answers.
Print less
- Cap command output: quiet flags, `| tail -n 40`, `--max-count`, `git diff --stat`, `git log -n 10 --oneline`.
Write less
- Before adding code, check that it needs to exist and that the codebase, standard library or platform doesn't already do it. Then make the smallest change that works.
- Never cut validation, error handling, security or tests to save lines.
- Don't add comments or docstrings that restate the code.
Say less
- Don't narrate between tool calls; just make the next call.
- End with at most three lines: what changed and where. No preamble, no restating the task, no step-by-step recap unless asked.
- Cite `file:line` instead of pasting code back.</code></pre>
<!-- rules:end -->
<h3>The workflow of one tool call</h3>
<div class="flow">
<div class="flow-step">
<span class="dot">1</span>
<div>
<h3>Session start</h3>
<p>The <code>SessionStart</code> hook adds the rules to the agent's context. After a compaction or <code>/clear</code>, it also forgets which files were read, because that content is gone from the context.</p>
</div>
</div>
<div class="flow-step">
<span class="dot">2</span>
<div>
<h3>The agent decides on a tool call</h3>
<p>A <code>Read</code> of a file, a <code>Bash</code> command, or a <code>Grep</code> search.</p>
</div>
</div>
<div class="flow-step tw">
<span class="dot">3</span>
<div>
<h3>ThinWindow's hooks inspect it</h3>
<p>Locally, in a Node script, with no network access. It ends in one of four outcomes:</p>
<div class="outcomes">
<div><b>Passes unchanged</b>Most calls. Already ranged, capped, or allowlisted.</div>
<div><b>Fixed in place</b>The input is rewritten to a cheaper equivalent, with a note to the agent. No turn is lost.</div>
<div><b>Refused, with a replacement</b>The agent is told why and what to run instead.</div>
<div><b>Cut after it runs</b>A noisy command runs as written; when it succeeds with a long output, the agent gets the last lines and the path of the full log.</div>
</div>
</div>
</div>
<div class="flow-step">
<span class="dot">4</span>
<div>
<h3>The result enters the context</h3>
<p>Smaller than it would have been, and therefore cheaper on every turn that follows.</p>
</div>
</div>
</div>
<h3>Guards reference</h3>
<p>Every threshold below is configurable; see <a href="#configuration">Configuration</a>.</p>
<h3><code>SessionStart</code></h3>
<p>On startup, resume, clear, compact and fork: adds <code>rules/thinwindow.md</code> to the context. On compact and clear, it also resets read tracking, because that content is gone from the context. On startup, it also removes state files and briefs older than 7 days.</p>
<h3><code>PreToolUse</code> · <code>Read</code></h3>
<div class="table-wrap"><table>
<thead><tr><th>Guard</th><th>When</th><th>What happens</th></tr></thead>
<tbody>
<tr><td>Large file</td><td>No <code>offset</code>/<code>limit</code>, and the file has more than 400 lines</td><td>The Read returns the first 120 lines plus a line-numbered outline of the file's classes, functions and headings, so the next read can target a range. With <code>"rewrite": false</code>, it is refused with the line count and a grep-plus-range suggestion.</td></tr>
<tr><td>Re-read</td><td>Same file and range, read earlier by the same agent, with the same mtime and size</td><td>Refused as "already in context". The main conversation and each subagent are tracked separately.</td></tr>
<tr><td>Soft block</td><td>The exact refused call is repeated within ten minutes</td><td>Goes through.</td></tr>
</tbody>
</table></div>
<p class="small muted">Images, PDFs, notebooks, binary files and missing paths are left alone. Ranged reads count for Claude Code's read-before-edit check.</p>
<h3><code>PreToolUse</code> · <code>Bash</code></h3>
<div class="table-wrap"><table>
<thead><tr><th>Category</th><th>Examples</th><th>What happens</th></tr></thead>
<tbody>
<tr><td>Noisy commands</td><td>install, build, test and lint for npm, pnpm, yarn, bun, pip, uv, poetry, pytest, cargo, go, gradle, maven, dotnet, make and more</td><td>Run as written, so your permission rules match them. When one succeeds with more than 10 lines on a stream, a <code>PostToolUse</code> hook cuts that stream to its last 10 lines and adds the path of the full log. A failed run, or a command that also runs something else, comes back whole. Already capped commands (a pipe, a redirect, a quiet flag) and background commands are left alone. With <code>"rewrite": false</code>, a soft block.</td></tr>
<tr><td>Unbounded scope</td><td>Recursive <code>grep</code>/<code>rg</code>/<code>ag</code> over the whole tree with no cap or exclude; a bare <code>git diff</code></td><td>Fixed in place: the search is limited to its first 100 lines (grep also skips <code>node_modules</code>, <code>.git</code>, <code>dist</code>, <code>build</code>), and <code>git diff</code> runs as <code>git diff --stat</code>. With <code>"rewrite": false</code>, a soft block.</td></tr>
<tr><td>Unbounded listings</td><td><code>git log</code> without <code>-n</code>, a range or <code>--since</code>; <code>ls -R</code>; <code>tree</code> without <code>-L</code>; <code>find</code> from the repo root without <code>-maxdepth</code> (with <code>-delete</code> it runs; with <code>-exec</code>, a soft block)</td><td>Fixed in place, since 0.5.1: <code>ls -R</code>, <code>tree</code> and <code>find</code> are capped to their first 100 lines, and <code>git log</code> to the last 20 commits. The command runs, so the session shows no failed tool call. With <code>"rewrite": false</code>, refused as before.</td></tr>
<tr><td>Anti-patterns</td><td><code>cat</code> (or <code>bat</code>, <code>less</code>, <code>more</code>, <code>nl</code>, <code>tac</code>) of a big, lock, minified or binary file</td><td>Refused, with a cheaper replacement. Output piped into <code>head</code>, <code>tail</code>, <code>grep</code>, <code>wc</code> and similar, or redirected to a file, counts as capped and is not blocked.</td></tr>
</tbody>
</table></div>
<h3><code>PreToolUse</code> · <code>Grep</code></h3>
<p>A content search (<code>output_mode: "content"</code>) with no <code>head_limit</code> gets <code>head_limit: 100</code>. File-list and count searches are left alone.</p>
<h3><code>thinwindow-run</code></h3>
<p>Part of the Agent Skill, for agents without the hooks; in Claude Code, a direct <code>thinwindow-run <cmd></code> call is pointed at it. Runs a command and keeps its full stdout and stderr in a log under the OS temp directory, never inside your repository. It prints the exit code and duration, then:</p>
<ul>
<li>on success, the last 10 lines;</li>
<li>on failure, the last 40 lines plus earlier error-like lines (error, fail, warn, panic, exception), deduplicated;</li>
<li>and the path of the full log, so the agent can read exactly the part it needs.</li>
</ul>
<p>When nothing would be cut (10 lines or fewer on success, 40 on failure), the output comes back as it is, with the exit code if the command failed. The command's exit code is preserved.</p>
<h3><code>Stop</code></h3>
<p>At the end of every turn: updates the session's brief from what the transcript gained since the last turn (at most 4 MB per turn, plus <code>git status</code> after a turn that could have changed files), then shows the setup-cost notice when one is due. Each part fails open on its own.</p>
<h3><code>UserPromptSubmit</code></h3>
<p>Before each prompt you send: the cold-resume notice. It reads the last 256 KB of the transcript for the last request's time, context size and model, and holds the prompt once per idle gap when the session was idle for over an hour with at least <code>coldResumeMinTokens</code> tokens of context. In the desktop app, where a held prompt isn't put back in the input box, it lets the prompt through with a one-line notice instead (<code>coldResumeMode</code>). It acts only in sessions a person attends, and never on commands or on prompts Claude Code writes itself.</p>
<h3>State, logs and briefs</h3>
<p>Read tracking and the hooks' counts live in one small file per session in <code><os temp dir>/thinwindow/state/</code>, with one tiny file per project for the setup-cost notice. The logs of cut output and of <code>thinwindow-run</code> go to <code><os temp dir>/thinwindow/logs/</code>; both folders are created so only your user can open them. Briefs go to the plugin's data folder. ThinWindow removes them once they're 7 days old, the next time it runs. Nothing is written inside your repository, and nothing is sent anywhere.</p>
<h3>What Claude gets back</h3>
<p>What the agent asks for, and what it gets with ThinWindow installed. All of these are default behaviours of the plugin.</p>
<div class="example">
<div class="call">Read src/command.js <span class="muted"># a file over 400 lines, no range</span></div>
<div class="result"><b>Fixed in place.</b> The agent gets the first 120 lines and a line-numbered outline of the rest, then reads the one range it needs.</div>
</div>
<div class="example">
<div class="call">npm test</div>
<div class="result"><b>Cut after it runs.</b> Runs as <code>npm test</code>, so <code>Bash(npm test:*)</code> still matches. If the tests pass, the agent sees the exit code, the duration, the last 10 lines and where the full log is. If they fail, it sees the output as Claude Code returns it.</div>
</div>
<div class="example">
<div class="call">grep -rn useColor .</div>
<div class="result"><b>Fixed in place.</b> Limited to its first 100 lines, skipping <code>node_modules</code>, <code>.git</code>, <code>dist</code> and <code>build</code>.</div>
</div>
<div class="example">
<div class="call">git diff</div>
<div class="result"><b>Fixed in place.</b> Runs as <code>git diff --stat</code>; the agent can then diff the one path it cares about.</div>
</div>
<div class="example">
<div class="call">cat package-lock.json</div>
<div class="result"><b>Refused</b>, with a cheaper way to get the answer. A lockfile is rarely worth its size in context.</div>
</div>
<div class="example">
<div class="call">Read src/utils.js <span class="muted"># again, unchanged since the last read</span></div>
<div class="result"><b>Refused</b> as already in context. If the agent really needs it again, repeating the call goes through.</div>
</div>
<h3>Design principles</h3>
<ul>
<li><strong>Fails open.</strong> If a hook errors for any reason, the tool call or the prompt proceeds. ThinWindow must never block someone's work because of its own bug.</li>
<li><strong>Can't get stuck.</strong> Repeating a refused <code>Read</code>, or a refused noisy or unbounded command, within ten minutes lets it through. The commands that are always refused come with a cheaper replacement that works.</li>
<li><strong>Never approves anything.</strong> ThinWindow never returns an <code>allow</code> decision, so it can't approve a call your permission settings would have asked about. A rewritten command still goes through your permission rules.</li>
<li><strong>Its own footprint is budgeted.</strong> The rules stay under 2,000 characters, and CI fails otherwise. The commands you type add nothing to the skill listing Claude sees.</li>
<li><strong>Never phones home.</strong> No telemetry, no analytics, no update or license checks.</li>
</ul>
</section>
<section id="between" aria-labelledby="between-h">
<h2 id="between-h"><span class="num">05</span>Between sessions: resume without paying twice</h2>
<h3>The brief</h3>
<p>At the end of every turn, ThinWindow keeps a short brief of the session up to date, without calling a model: the goal, your last requests, the files changed, the last commands with their exit codes, and Claude's last reply. A session that never uses the brief gains no tokens from it.</p>
<h3>The cold-resume notice</h3>
<p>You send a prompt to a session that has been idle for over an hour with at least 100k tokens of context. ThinWindow holds it once and shows what continuing re-writes, in tokens and in US$ at the model's list price, next to a fresh start. You decide every time: send the prompt again to continue. Commands are never held, and neither are prompts in <code>-p</code>, SDK or background sessions. In the desktop app, which doesn't put a held prompt back in the input box, the prompt goes through and one line says what it re-writes; <code>"coldResumeMode": "block"</code> holds it there too. Example:</p>
<pre><code>ThinWindow held this message: this session has been idle 9 h, so its prompt cache has expired.
Continuing re-writes ~427k tokens (~US$3.42 at Opus 5.5 list price): send it again.
A fresh start from a short brief re-writes ~55k tokens (~US$0.44): /clear, then /thinwindow:resume <your request>.</code></pre>
<h3><code>/thinwindow:resume</code></h3>
<p>After <code>/clear</code>, it starts the new session from this project's newest brief, up to 48 hours old, optionally followed by your next request. The brief is at most 600 characters, marked as reference for Claude to check against <code>git status</code>, and comes with its age, the commits made since and the path to the full brief.</p>
<h3><code>/thinwindow:brief</code></h3>
<p>Before you step away, Claude writes a five-line handoff while the cache is still warm: what's done, where it stopped, the decisions, what didn't work, and the next step. ThinWindow keeps it in the brief.</p>
<div class="callout">
<strong>Claude Code's own "Resume from summary"</strong>
<p>Claude Code shows its own dialog when you <code>--resume</code> a large session after about an hour (Pro and Max plans). ThinWindow also covers sessions you left open, shows what continuing costs before you pay it, and keeps a brief for any later <code>/clear</code>.</p>
</div>
</section>
<section id="after" aria-labelledby="after-h">
<h2 id="after-h"><span class="num">06</span>After: see where your context went</h2>
<p><code>/thinwindow:report</code> reads the transcripts of your own Claude Code sessions on this machine and prints, on one screen:</p>
<ul>
<li>how much context each request re-sends, on average and in your longest sessions;</li>
<li>how often a session was re-written after its cache expired, at what size, and what those re-writes cost at list price;</li>
<li>what a session's first request carries, and its largest parts;</li>
<li>whose tool output is re-sent most, and in what sizes;</li>
<li>what ThinWindow did in the last 7 days.</li>
</ul>
<p>The amounts are what's at stake in your own sessions, not what ThinWindow saved. On a subscription, read US$ as a relative size. <code>/thinwindow:report --json</code> prints a short summary without US$ amounts; you can share it in <a href="https://github.com/thinwindow/thinwindow/issues/43">#43</a> if you want to. Nothing is collected automatically.</p>
</section>
<section id="install" aria-labelledby="install-h">
<h2 id="install-h"><span class="num">07</span>Install</h2>
<h3>From the plugin directory</h3>
<p>In the Claude desktop app, Customize → Plugins → Discover → ThinWindow. In Claude Code, <code>/plugin</code> → Discover → ThinWindow, or:</p>
<pre><code>claude plugin install thinwindow@anthropic-plugin-directory</code></pre>
<p>The directory serves 0.4.0 for now; the newest version installs from the repository.</p>
<h3>From the repository, in Claude Code</h3>
<pre><code>/plugin marketplace add thinwindow/thinwindow
/plugin install thinwindow@thinwindow</code></pre>
<h3>Any agent with Agent Skills</h3>
<p>Codex, Cursor, Copilot, Gemini CLI, OpenCode and other agents that support the Agent Skills standard get the rules, <code>thinwindow-run</code> and the report script.</p>
<pre><code>npx skills add thinwindow/thinwindow</code></pre>
<h3>Agents that read <code>AGENTS.md</code></h3>
<p>Paste <code>adapters/AGENTS.md</code> into your project's <code>AGENTS.md</code>, or into whichever instructions file your agent loads.</p>
<h3>Turning it off</h3>
<p>Set <code>THINWINDOW=off</code> in the environment, or <code>"enabled": false</code> in <code>.thinwindow.json</code>. With it off, <code>thinwindow-run</code> runs commands with their output as it is.</p>
<p class="small muted">Requirements: Node.js 18 or newer. No other dependencies.</p>
</section>
<section id="surfaces" aria-labelledby="surfaces-h">
<h2 id="surfaces-h"><span class="num">08</span>Where it works</h2>
<div class="table-wrap"><table>
<thead><tr><th>Where</th><th>What ThinWindow does there</th></tr></thead>
<tbody>
<tr><td>Claude Code (terminal, IDE, the desktop app's Code tab)</td><td>Everything: the rules, the guards, the brief, the cold-resume notice, the setup-cost notice and the <code>/thinwindow:</code> commands. The <code>thinwindow-minimal</code> profile works from the terminal.</td></tr>
<tr><td>Cowork</td><td>The rules, the Read guard and <code>/thinwindow:brief</code> work. <code>/thinwindow:report</code> covers only the current task, briefs don't carry over between tasks, and neither notice shows.</td></tr>
<tr><td>Chat (claude.ai, the desktop and mobile apps)</td><td>Only the Agent Skill: Claude loads the rules when it decides a task needs them, and <code>/thinwindow:brief</code> works. The other commands need a shell, which chat doesn't run.</td></tr>
</tbody>
</table></div>
<p class="small muted">ThinWindow's validation ran in Claude Code. Cowork and chat were checked for what works there, not measured.</p>
</section>
<section id="configuration" aria-labelledby="config-h">
<h2 id="config-h"><span class="num">09</span>Configuration</h2>
<p>ThinWindow works without configuration. To change it, create <code>.thinwindow.json</code> in the project root or <code>~/.thinwindow.json</code> in your home directory. Project values override home values; lists from both files are combined.</p>
<pre><code>{
"enabled": true,
"maxReadLines": 400,
"rewrite": true,
"briefs": true,
"coldResumeNotice": true,
"coldResumeMode": "block",
"coldResumeMinTokens": 100000,
"setupNotice": true,
"setupNoticeMinTokens": 40000,
"noisyCommands": ["^just (build|test)\\b"],
"allowlist": {
"paths": ["docs/**", "*.lock"],
"commands": ["^make lint$"]
}
}</code></pre>
<div class="table-wrap"><table>
<thead><tr><th>Key</th><th>Default</th><th>Effect</th></tr></thead>
<tbody>
<tr><td><code>enabled</code></td><td><code>true</code></td><td><code>false</code> turns every hook off for that project, or everywhere in <code>~/.thinwindow.json</code>.</td></tr>
<tr><td><code>maxReadLines</code></td><td><code>400</code></td><td>Line count above which a whole-file <code>Read</code> is shortened, and <code>cat</code> of the file is refused.</td></tr>
<tr><td><code>rewrite</code></td><td><code>true</code></td><td>Fix wasteful calls in place. <code>false</code> refuses them instead, as a soft block, at the cost of a turn each.</td></tr>
<tr><td><code>briefs</code></td><td><code>true</code></td><td><code>false</code> stops keeping session briefs for <code>/thinwindow:resume</code>.</td></tr>
<tr><td><code>coldResumeNotice</code></td><td><code>true</code></td><td><code>false</code> turns off the cold-resume notice.</td></tr>
<tr><td><code>coldResumeMode</code></td><td><code>"block"</code>; <code>"notify"</code> in the desktop app</td><td><code>"block"</code> holds the prompt once, <code>"notify"</code> lets it through with one line, <code>"off"</code> turns the notice off.</td></tr>
<tr><td><code>coldResumeMinTokens</code></td><td><code>100000</code></td><td>The smallest context, in tokens, for which the notice holds a prompt.</td></tr>
<tr><td><code>setupNotice</code></td><td><code>true</code></td><td><code>false</code> turns off the setup-cost notice.</td></tr>
<tr><td><code>setupNoticeMinTokens</code></td><td><code>40000</code></td><td>The smallest first request, in tokens, for which the notice shows.</td></tr>
<tr><td><code>noisyCommands</code></td><td>built-in list</td><td>Extra regular expressions for noisy commands, added to the built-in list.</td></tr>
<tr><td><code>allowlist.paths</code></td><td><code>[]</code></td><td>Globs for files ThinWindow never blocks.</td></tr>
<tr><td><code>allowlist.commands</code></td><td><code>[]</code></td><td>Regular expressions for Bash commands ThinWindow never blocks.</td></tr>
</tbody>
</table></div>
<p>A missing, unreadable or mistyped file is ignored, and a key with the wrong type keeps its default.</p>
<h3>Environment variables</h3>
<div class="table-wrap"><table>
<thead><tr><th>Variable</th><th>Effect</th></tr></thead>
<tbody>
<tr><td><code>THINWINDOW=off</code></td><td>Turns ThinWindow off, whatever the config files say.</td></tr>
<tr><td><code>THINWINDOW_DEBUG=1</code></td><td>The hooks write each decision to stderr, which Claude Code keeps in its debug log (<code>claude --debug</code>).</td></tr>
</tbody>
</table></div>
<p class="small muted">The complete reference is <code>docs/configuration.md</code> in the repository.</p>
</section>
<section id="upgrading" aria-labelledby="upgrading-h">
<h2 id="upgrading-h"><span class="num">10</span>Upgrading</h2>
<p><strong>From 0.4:</strong></p>
<ul>
<li><strong>Noisy commands run as written.</strong> They're no longer rewritten to <code>node '…/thinwindow-run.mjs' <cmd></code>; a hook after each <code>Bash</code> call cuts the output of the ones that succeed. A permission rule you added for <code>thinwindow-run</code> is no longer needed.</li>
<li><strong>In the desktop app</strong> the cold-resume notice lets the prompt through with one line. <code>"coldResumeMode"</code> picks the behavior.</li>
<li><strong><code>/thinwindow:report</code></strong> also counts the reads cut to an outline and the outputs cut.</li>
</ul>
<p><strong>From 0.3.0:</strong></p>
<p>Nothing that worked stops working, and every new part has its own off switch.</p>
<ul>
<li><strong>New hooks:</strong> at the end of each turn (the brief and the setup-cost notice), and before each prompt (the cold-resume notice).</li>
<li><strong>New commands:</strong> <code>/thinwindow:resume</code>, <code>/thinwindow:brief</code> and <code>/thinwindow:report</code>. You type them; they add nothing to the skill listing Claude sees.</li>
<li><strong>New switches:</strong> <code>briefs</code>, <code>coldResumeNotice</code>, <code>coldResumeMinTokens</code>, <code>setupNotice</code> and <code>setupNoticeMinTokens</code>.</li>
<li><strong>New, optional:</strong> the <code>thinwindow-minimal</code> profile, a file you copy in.</li>
<li><strong>Changed:</strong> the rules say the same in fewer words.</li>
</ul>
</section>
<section id="checked" aria-labelledby="checked-h">
<h2 id="checked-h"><span class="num">11</span>How it's checked</h2>
<p>ThinWindow used to publish one benchmark percentage per model. From 0.4.0 it's checked with a different method (<a href="https://github.com/thinwindow/thinwindow/issues/28">#28</a>):</p>
<ul>
<li><strong>Every mechanism has unit tests,</strong> run in CI on macOS, Linux and Windows.</li>
<li><strong>Ideas are first replayed</strong> on recorded sessions, at no model cost, to see what's at stake.</li>
<li><strong>A few targeted agent runs</strong> answer what only a model can, with the pass criteria written before the first run.</li>
<li><strong>0.4.0 was validated before release</strong> against Claude Code without the plugin, on real open-source repositories, with its method and pass rules posted before the first run (<a href="https://github.com/thinwindow/thinwindow/issues/38">#38</a>). On Sonnet 5.5, every benchmark task and every resume chain completed with ThinWindow, as they did without it. When the second task of a chain started fresh after the prompt cache expired, it cost less per completed chain than continuing. The expiry was priced in from each run's token counts, not waited out; with a warm cache, continuing cost less.</li>
</ul>
<p>The method, the raw rows and the agents' scrubbed transcripts are public in <a href="https://github.com/thinwindow/thinwindow/tree/main/bench">bench/</a>.</p>
</section>
<section id="privacy" aria-labelledby="privacy-h">
<h2 id="privacy-h"><span class="num">12</span>What it reads, writes and sends</h2>
<ul>
<li><strong>Reads:</strong> the tool call Claude Code passes to the hooks (a file path, a command or a search pattern), and the line count and outline of files Claude is about to read or print; its settings in <code>.thinwindow.json</code>; the environment variables <code>THINWINDOW</code>, <code>THINWINDOW_DEBUG</code>, <code>CLAUDE_PROJECT_DIR</code>, <code>CLAUDE_PLUGIN_DATA</code>, <code>CLAUDE_CODE_SESSION_ATTENDED</code> and <code>CLAUDE_CODE_ENTRYPOINT</code>; the output of each <code>Bash</code> call that succeeded, of which it keeps and cuts only a noisy command's; before each prompt, the last 256 KB of the session's transcript, and the first 256 KB when a cold-resume notice is due; at the end of each turn, the part of the transcript written since the last turn, and its first 256 KB while a setup-cost notice may be due; and <code>git status</code> in the session's folder after a turn that could have changed files. <code>/thinwindow:resume</code> also runs <code>git log</code> there. It reads no credentials.</li>
<li><strong>Writes, to your operating system's temp folder:</strong> one small file per session (which files and ranges were read, recent refusals, when a cold-resume notice was last shown, and counts of what the hooks did), one tiny file per project (when the setup-cost notice was last shown), and the full log of each command whose output was cut or that ran through <code>thinwindow-run</code>, in folders created so only your user can open them.</li>
<li><strong>Writes, to the plugin's data folder</strong> (<code>~/.claude/plugins/data/</code>): one small brief per session, in a folder per project. A brief holds <strong>excerpts of your prompts and of Claude's replies</strong>: the first prompt (up to 200 characters), the last three requests (up to 80 each), the last reply (up to 1,200), the changed files, and the last four commands (up to 70 characters each) with their exit codes. <code>"briefs": false</code> stops writing them.</li>
<li><strong>Deletes:</strong> ThinWindow removes its files once they're 7 days old, the next time it runs. Claude Code deletes the plugin's data folder when you uninstall the plugin. If you remove ThinWindow from your account in the Claude desktop app, briefs can stay; delete the <code>thinwindow-*</code> folder in <code>~/.claude/plugins/data/</code> to remove them.</li>
<li><strong>Sends:</strong> nothing. There is no network code. A brief enters a conversation only when you type <code>/thinwindow:resume</code>.</li>
</ul>
<p><code>/thinwindow:report</code> reads your Claude Code transcripts (<code>~/.claude/projects</code>, or <code>$CLAUDE_CONFIG_DIR/projects</code>) only when you run it, and writes nothing. It prints aggregate numbers with its own labels: never prompts, file contents, commands, paths, project names, session ids, or the names of your tools, models or MCP servers; a test checks this. Through the slash command, the printed numbers become part of your conversation; run the script yourself with <code>!</code> to keep them out. If Claude Code changes its transcript format, the report says "format not recognized" instead of printing wrong numbers.</p>
<p class="small muted">This page loads no external fonts or scripts either.</p>
</section>
<section id="limitations" aria-labelledby="limits-h">
<h2 id="limits-h"><span class="num">13</span>Limitations</h2>
<ul>
<li><strong>ThinWindow is built for long sessions,</strong> and for coming back to big ones. A short task carries little context to begin with.</li>
<li><strong>The hooks need Claude Code.</strong> Other agents get the rules, and Cowork and chat get the parts listed in <a href="#surfaces">Where it works</a>.</li>
<li><strong>US$ figures are estimates at the API list price.</strong> They aren't a bill.</li>
<li><strong>No warranty.</strong> The software is provided "as is" under the MIT License, without warranty of any kind. The hooks are designed to fail open, and the tests cover that, but no amount of testing is a guarantee. Review the code before trusting it with real work.</li>
</ul>
</section>
<section id="repository" aria-labelledby="repo-h">
<h2 id="repo-h"><span class="num">14</span>Repository</h2>
<div class="table-wrap"><table>
<thead><tr><th>Path</th><th>Contents</th></tr></thead>
<tbody>
<tr><td><code>rules/thinwindow.md</code></td><td>The rules: the single source of truth for the behaviour.</td></tr>
<tr><td><code>skills/</code></td><td>The Agent Skill, with <code>thinwindow-run</code> and the report script, and the <code>/thinwindow:</code> commands.</td></tr>
<tr><td><code>.claude-plugin/</code>, <code>hooks/</code></td><td>The plugin manifest, its marketplace entry and the hooks.</td></tr>
<tr><td><code>profiles/</code></td><td>The opt-in <code>thinwindow-minimal</code> profile.</td></tr>
<tr><td><code>adapters/AGENTS.md</code></td><td>The rules as a snippet for agents that read <code>AGENTS.md</code>.</td></tr>
<tr><td><code>bench/</code></td><td>Tasks, runner, report, hidden checks, reference solutions, raw results and the method.</td></tr>
<tr><td><code>docs/</code></td><td>Product spec, configuration reference and manual testing guide.</td></tr>
<tr><td><code>test/</code>, <code>scripts/</code></td><td>The test suite (<code>node --test</code>) and the repository checks CI runs.</td></tr>
<tr><td><code>assets/</code>, <code>website/</code></td><td>The ThinWindow logo and icon set, and this documentation site.</td></tr>
</tbody>
</table></div>
<h3>Contributing</h3>
<ol>
<li><strong>A task from your own stack:</strong> another language, a monorepo, a framework with heavy generated code.</li>
<li><strong>A reproducible regression,</strong> with the rows that show it.</li>
<li><strong>A rule or hook proposal,</strong> with the compliance table (<code>node bench/compliance.mjs</code>), and, when the decision depends on how the model reacts, a few targeted runs whose pass criteria are written before running them.</li>
</ol>
<p>The workflow is in <code>CONTRIBUTING.md</code>. The project uses Conventional Commits and the MIT License.</p>
</section>
<section id="faq" aria-labelledby="faq-h">
<h2 id="faq-h"><span class="num">15</span>FAQ</h2>
<details>
<summary>Does it make Claude worse at the task?</summary>
<p>In 0.4.0's validation on Sonnet 5.5, every benchmark task and resume chain completed with ThinWindow as often as without it, and a blind review of final answers found them correct and complete in both conditions. Every guard fails open.</p>
</details>
<details>
<summary>How is it different from Claude Code's "Resume from summary"?</summary>
<p>That dialog appears when you <code>--resume</code> a large session after about an hour, on Pro and Max plans. ThinWindow also covers sessions you left open, shows what continuing costs in tokens and US$ before you pay it, and keeps a brief for any later <code>/clear</code>.</p>
</details>
<details>
<summary>Will the cold-resume notice interrupt me?</summary>
<p>At most once per idle gap: only after an hour idle, and only over 100k tokens of context. Send the prompt again to continue, In the desktop app it doesn't hold the prompt; it adds one line. Turn it off with <code>"coldResumeMode": "off"</code>.</p>
</details>
<details>
<summary>Does it send my code or telemetry anywhere?</summary>
<p>No. There is no network code in the project: no analytics, crash reports, usage statistics, or license or update checks. The hooks are local Node scripts.</p>
</details>
<details>
<summary>Does it work outside Claude Code?</summary>
<p>The rules do, through Agent Skills or <code>AGENTS.md</code>. The hooks need Claude Code. Cowork and chat get the parts in <a href="#surfaces">Where it works</a>.</p>
</details>
<details>
<summary>Can it block something I actually need?</summary>
<p>It's designed not to. A refused <code>Read</code> or noisy command goes through when repeated, the always-refused commands come with a working replacement, paths and commands can be allowlisted, and <code>THINWINDOW=off</code> disables everything. If a hook itself fails, the call proceeds.</p>
</details>
</section>
<footer class="page-foot">
<span><img src="assets/favicon/favicon-48.png" alt="" width="20" height="20">ThinWindow · MIT License · by Iván Luna</span>
<a href="https://github.com/thinwindow/thinwindow">GitHub</a>
<a href="https://github.com/sponsors/imprvhub">GitHub Sponsors</a>
<a href="https://ko-fi.com/ivanlunadev">Ko-fi</a>
</footer>
</div>
</main>
</div>
</body>
</html>