Skip to content

Merge the clear commands into one /clear-tools - #11

Merged
maxsoldev merged 4 commits into
mainfrom
feat-one-clear-tools
Nov 12, 2026
Merged

maxsoldev merged 4 commits into
mainfrom
feat-one-clear-tools

Conversation

@maxsoldev

Copy link
Copy Markdown
Owner

What

One command, /clear-tools [outputs] [keep N], replaces /clear-tool-outputs, /clear-tool-calls and /clear-tools. The matching form is /compact tools [outputs] [keep N].

  • Default: stubs old tool calls (inputs) and old tool outputs in one pass, so the prompt cache is rewritten once.
  • outputs: stubs only old tool outputs and keeps the calls.
  • There is no calls-only mode and there are no aliases (release 0.1). /compact tool-outputs and /compact tool-calls now go to Claude Code like any other instructions.
  • Argument errors say what is wrong, e.g. /clear-tools: keep needs a whole number, not "-1". Usage: /clear-tools [outputs] [keep N], or unknown word "calls".

Why

Users found three commands confusing. One command with a single option covers both useful cases.

Kept as before

Deterministic stubs, tool ids kept, the last N left whole, small inputs left whole, subagent compactions left to Claude Code, and a failed clear skips the compaction (it never falls back to a paid summary).

Code

clear-tools.ts has the parser (parseClearArgs), the /compact request reader and clearTools. register.ts registers one command; the three-entry command table is removed. The stub modules (clear-tool-calls.ts, clear-tool-outputs.ts) only got new headers.

Docs: README, ARCHITECTURE, known-issues (the resume caveat is kept, plus a new low row: a typed /compact tools <bad words> still goes to a summary).

How tested

  • Test first: new packages/mod/test/clear-tools.test.ts (plugin test kit) covers both modes, keep N, bad words, the single registered command, the old /compact forms being left to Claude Code, subagents, and the failure skip. The command tests in the two older test files moved here.
  • corepack pnpm check passes (44 mod tests, with claude on PATH).
  • Not tried by hand in a live Claude Code session.

/clear-tool-outputs, /clear-tool-calls and /clear-tools were three
commands for one job and confused users. Now there is one:
/clear-tools [outputs] [keep N], also as /compact tools [outputs]
[keep N]. The default stubs old calls and outputs in one pass, so the
cache is rewritten once; `outputs` keeps the calls. There is no
calls-only mode, and no aliases (release 0.1).

Argument errors now say what is wrong (`keep -1`, an unknown word).
Behaviour is unchanged otherwise: same stubs, ids kept, small inputs
kept, subagent compactions left to Claude Code, a failed clear skips
the compaction. The old /compact tool-outputs and tool-calls forms now
go to Claude Code like any other instructions.
The review of session 244 found 554 inputs of up to 800 chars left
whole (165k chars). A 300-char input and 80-char field limit stubs
249 of them for ~84k chars. With lower limits a stub of an input made
of short fields can grow it, so a stub must now save 100 chars.

ToolSearch results stay whole: their tool_reference blocks load the
deferred tool schemas that later calls in the history still use.
A clear changes the start of the context, so the next call writes the
whole new context to the cache again. On session 244 that was 422k
tokens ($3.72) for a 226k saving per call, which pays back only after
~36 calls. The toast now gives the chars removed (exact), the tokens
(~), the one-time re-write and its price for the 5-min and 1-h cache,
and the payback in calls for each: the mod cannot see the TTL.

A run with nothing to clear now answers a skip, so Claude Code writes
no compact boundary. The toast shows after the live update, so a
failed clear no longer shows "Cleared" first (review L1).
The row on lost images and text was wrong: on a live clear the rebuilt
messages kept every thinking, text and image block, and its fix could
not be done. It is now low and limited to the one untested case. The
review's medium and low items not fixed here get their own rows.
@maxsoldev
maxsoldev merged commit 855f61e into main Nov 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant