Загрузка видео...

Не удалось загрузить видео

На главную

I reverse-engineered Claude Code's binary to add a feature I always wanted: When context fills up - instead of nuking everything with /compact - I can now surgically strip tool calls/results and thinking blocks while keeping all actual messages intact.

198,284 просмотров • 7 месяцев назад •via X (Twitter)

Комментарии: 68

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

The problem was: when you're deep in a session, context is 96% full, and your options are: - /compact: summarizes everything, loses detail, costs an API call - /clear: nuclear option, start over I wanted to strip the heavy garbage and leave only user/agent messages instead.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

So I cracked open the binary. Claude Code is a Bun-compiled executable: ~183MB. All JS is embedded in a __BUN Mach-O section - 4,945 modules, fully minified. Even with `--bytecode`, Bun always stores the full JS source alongside. The bytecode is just a startup optimization.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

What I found inside: Claude already HAS a microcompact() system. It runs before every API call, strips old tool results, saves them to disk, replaces images with placeholders. But it doesn't touch everything and leaves many of the thinking intact...

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

It has limitations: - 20K token minimum savings - only kicks in near context limits - keeps last 3 tool results - never removes tool_use blocks. Even after it runs, tons of tool artifacts remain in context. That's by design, but it's not enough when you're running out of space.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

There's also a thinking cleanup before every API call: - filterOrphanedThinking(): removes messages that are ONLY thinking - removeTrailingThinking(): strips thinking from end of last message But thinking blocks inside messages with tool_use? Those survive. They pile up.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

So I built two new commands: /microcompact: strips ALL tool calls + results + media. No thresholds, no "keep last 3". Picker lets you choose how far back to strip. /clear-thinking: strips ALL thinking blocks backward from selected message. Both instant with no LLM calls.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

The meta part: I reverse-engineered Claude Code using Claude Code :) 48 sessions over several days. Built 20 tools: binary extraction, module splitting, vendor fingerprinting, AI renaming (23,105 identifiers via Gemini for ~$2), and a full round-trip pipeline.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

I also built bun-demincer - a generic toolkit for cracking open ANY Bun-compiled binary. Extract embedded JS, split into modules, identify npm packages (fingerprint DB is 1,668 packages rn), deobfuscate, organize into directories and reassemble it back!

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

The irony: Claude couldn't finish the job - started forgetting things after another Plan mode run :) After 42 sessions it hit a wall kept looping the full pipeline instead of isolating the failing stage. Classic. Switched to Codex for the final stretch. One shot of course :)

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

For the Claude-specific patches (microcompact, clear-thinking) - I'm holding off on publishing them for now. Don't want to step on anyone's toes, unless @AnthropicAI are cool with it. cc: @alexalbert__

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

But would love these to be built-in honestly - the code paths are already there, just need manual triggers and looser thresholds. Also /compact should let you pick a message: summarize everything before it, keep everything after. Right now it just nukes the whole conversation.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

All this reverse engineering really helped me to understand what's under the hood of Claude Code. I will be posting more about my explorations... Hold on for new Memory threads!

Фото профиля 0xSero
0xSero7 месяцев назад

@vicnaum @banteg @claudeai everything with /compact - I can now surgically strip tool calls/results and thinking blocks while keeping all actual messages intact. You’d be destroying the cache which will cost you tons of tokens and make the model less reliable

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@banteg @claudeai Yes. But it still wins over going in circles with the model that forgot what project it was working on... And actually, If I strip 195k tokens context into 5k (just user/agent conversation) - then who cares about cache?

Фото профиля 0xSero
0xSero7 месяцев назад

@vicnaum @banteg @claudeai Mainly that it will usually just reread all the files you stripped out again anyway. I’m not arguing with you it’s something I was interested in exploring too but I never quite got it right

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@banteg @claudeai I usually ask it to use sub-agents for file reading & modifications, and report back. but sometimes it still does things itself..

Фото профиля Pascal Brokmeier
Pascal Brokmeier7 месяцев назад

@vicnaum @claudeai I built this thing maybe this will also be helpful for you @vicnaum Basically per git repo backup of AI convos.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Oh yeah! I had a simple skill with a script for that: But yours is on a whole new level!

Фото профиля Alessio Masucci
Alessio Masucci7 месяцев назад

@vicnaum @claudeai Cool hack, but we're essentially writing manual garbage collection for LLM context now. /compact is a grenade. This is a scalpel. But the real question is why we're still doing memory management by hand in 2026

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Exactly! Memory and context management is in such an infancy phase right now that I’m surprised this is still an untackled problem

Фото профиля Youssef Tharwat
Youssef Tharwat7 месяцев назад

@vicnaum @SucciMas @claudeai We’re trying @noodl_box

Фото профиля Alessio Masucci
Alessio Masucci7 месяцев назад

@vicnaum @claudeai @noodl_box How is it going?

Фото профиля maddada • ghostex.dev
maddada • ghostex.dev7 месяцев назад

You might've heard about this already, but this flow does the same thing and it's built in (keeps the messages, strips the tool calls): 1- Do /export and select md file 2- /new to start a new conversation 3- paste that md's path as context in the chat 4- Send any request and the previous messages will be in context The issue with this trick (and /microcompact) is you get deeper and deeper into the dumb zone of the context after a few cycles of this since you're keeping all the chat messages even the unnecessary ones. Still great job on bun-demincer.

Фото профиля Marcel Samyn
Marcel Samyn7 месяцев назад

@vicnaum @claudeai The model should be deciding this on its own.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Ideally yes!

Фото профиля Conor
Conor7 месяцев назад

@vicnaum @claudeai Yep, context adjustments are the single biggest unlock and why you should generally create and use your own harnesses. OpenAI if you are reading this, you are missing out by not enabling more functionality here in the vanilla instance

Фото профиля SIGKITTEN
SIGKITTEN7 месяцев назад

@vicnaum @claudeai rip limits

Фото профиля heswithme
heswithme7 месяцев назад

@vicnaum @claudeai there's dynamic context pruner for opencode that does the same automatically during the session

Фото профиля AzFlin 🗿
AzFlin 🗿7 месяцев назад

@vicnaum @banteg @claudeai That’s great. The tool calls take the most space

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@banteg @claudeai exactly! It was around 150k of tool calls - crazy..

Фото профиля zodomo.gwei (🌍,💻)
zodomo.gwei (🌍,💻)7 месяцев назад

@vicnaum @claudeai @bcherny add this to Claude Code

Фото профиля Daniel
Daniel7 месяцев назад

@vicnaum @claudeai You reverse engineered an open source binary?

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Its not really opensource - its still minified (later I found it on NPM, but would had saved me a few minutes on extracting the JS from bun-binary)

Фото профиля Matt Pistachio
Matt Pistachio7 месяцев назад

@vicnaum @claudeai yesss i’ve also often felt the need for a saving grace when at 90% context. you could, alternatively, build a script that runs on the transcript’s JSONL, without touching the Claude binary?

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Yeah, thats what I was doing before, and also asked another instance of Claude to break it down to me, see what takes most context and help us decide what to trim.

Фото профиля Matt Pistachio
Matt Pistachio7 месяцев назад

@vicnaum can you post the script version?

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

i was doing it on 2.1.63, but many new versions came out. I still have the transfer functionality to move my patches to newer versions - but havent tried it on latest yet. will probably post the patch soon

Фото профиля Nick Richardson
Nick Richardson7 месяцев назад

@vicnaum @claudeai How did you give Clawd a hat???????? This is very important information I need.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai I painted it in :) but pistol didn't turn out that good Wanted to make it a pirate )

Фото профиля ʘ ZERO
ʘ ZERO7 месяцев назад

@vicnaum @claudeai Fascinating work. ~5000 modules is revealing CC as sloppy patchwork. Pi agent main binary has ~20 direct deps and <400 unique transitive packages. Comparing apples to oranges here in terms of functionality out of the box. Just to illustrate how bloated CC is

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai not really, its more of minification artifacts, I’d say - we can never tell what the original source was

Фото профиля ʘ ZERO
ʘ ZERO7 месяцев назад

@vicnaum @claudeai Thanks for clarifying. We think that the number is plausible from React ink deps alone.

Фото профиля ʘ ZERO
ʘ ZERO7 месяцев назад

@vicnaum @claudeai Mastra has an interesting concept called Observational Memory where 2 external models curate the transcript at runtime which basically results in unlimited context, preserving important details

Фото профиля AI Now
AI Now7 месяцев назад

@vicnaum @claudeai Context limit hits, most people restart the whole conversation. This guy cracked open the binary and built what he needed. That’s the real AI skill gap

Фото профиля Blacktop
Blacktop7 месяцев назад

@vicnaum @claudeai @claudeai hire this person

Фото профиля Dan Pralea
Dan Pralea7 месяцев назад

@vicnaum @claudeai anthropic ships this as a feature in 2 weeks and this becomes the most well-documented wasted weekend ever

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Let them do :) I have much more features in my mind - if that’s the only way I can contribute to Claude - so be it 😁

Фото профиля ʘ ZERO
ʘ ZERO7 месяцев назад

@vicnaum @claudeai The number of ~5000 dependencies for a CLI is staggering. Worth a good rant:

Фото профиля Kyriakos
Kyriakos7 месяцев назад

@vicnaum @claudeai Hack the tool until it fits the workflow

Фото профиля Rob Schmidt
Rob Schmidt7 месяцев назад

@vicnaum @claudeai I’ve asked Claude to build a .md context file from current session and load it into a new session. It’s simple and I’ve had great results doing that.

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Yeah, I was also doing that, and even have a skill for this: But I wanted something native, and still keep the tool-calls/thinking from some later messages.

Фото профиля NΞ∆
NΞ∆7 месяцев назад

@vicnaum @claudeai That's classic.. bro you're lucky you didn't have to go through what I did back then haha

Фото профиля עדי (Adi)
עדי (Adi)7 месяцев назад

@vicnaum @claudeai Yo, this is genius. Well done bro 👏

Фото профиля Gregor
Gregor7 месяцев назад

@vicnaum @claudeai It sounds like you turned a feature limitation into an opportunity for more precision. Reminds me of when I had to deal with similar limitations in my app, and I ended up designing a custom data compression algorithm to prioritize certain data types.

Фото профиля Subhash Dasyam
Subhash Dasyam7 месяцев назад

150k tokens of tool calls sitting in context is wild. The fact that Claude already has microcompact() internally but caps it with a 20K minimum and "keep last 3" feels like they were being cautious about cache invalidation costs. Stripping everything down to 5k of pure conversation and letting the model rebuild its understanding from that is a bold tradeoff, but honestly probably better than watching it loop on forgotten state. The bun-demincer tool sounds more generally useful than the Claude patches themselves.

Фото профиля 2018's Most Trusted Webzone
2018's Most Trusted Webzone7 месяцев назад

@vicnaum @claudeai

Фото профиля otman.ETH
otman.ETH7 месяцев назад

@vicnaum @claudeai the dawn of self-editing code

Фото профиля TelepathicPug
TelepathicPug7 месяцев назад

@vicnaum @claudeai Very cool feature.

Фото профиля Asaf Fisher
Asaf Fisher7 месяцев назад

@vicnaum @claudeai Cool!

Фото профиля winston
winston7 месяцев назад

@vicnaum @claudeai Can I install your version of claude code with this feature? Absolutely need it

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai i think I will post a patch soon that anyone can install

Фото профиля James Epps 🌞
James Epps 🌞7 месяцев назад

@vicnaum @claudeai 😂😂😂

Фото профиля jake cukjati
jake cukjati7 месяцев назад

@vicnaum @claudeai This sounds like it would have side affects? Like dementia

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai not really, quite the opposite - if you compact at this stage - it will forget much more than if you keep the conversation intact, but remove the tools

Фото профиля jake cukjati
jake cukjati7 месяцев назад

@vicnaum @claudeai

Фото профиля hazle11
hazle117 месяцев назад

@vicnaum @claudeai Smart approach. The built-in compaction heuristics always felt too conservative for long sessions. Surgically stripping tool artifacts while keeping the conversation intact is the fix power users need.

Фото профиля Kay
Kay7 месяцев назад

this solves my biggest claude code frustration tbh lost count of how many times ive hit 96% context in a deep debugging session and had to choose between /compact (lose everything) or start over the message picker approach is perfect. sometimes you just need to clear tool noise from the middle of a session, not nuke the whole conversation

Фото профиля Convergence Boy
Convergence Boy7 месяцев назад

@claudeai Here I've made it a skill also:

Похожие видео

Pi was built when there were already agent harnesses around. Here’s why Mario Zechner(Mario Zechner), found them suboptimal and built Pi, a minimalist self-modifying agent: #1 - Mario initially was a believer in Claude Code: "I was a believer in Claude code because they were the first that packaged agentic search up in a really compelling package. And at the time that fit my workflow really well. Everything around the LLM was kind of nice and tidy and easy to understand. I was super happy. I was proselytising Claude code." #2 - Reverse engineering Claude Code highlighted the degradation that Mario felt as a user: "I personally like simple tools that are stable and that I can rely on. Even if they have non-deterministic parts, all the deterministic parts should be as stable as possible. That was just not the experience with Claude Code around summer 2025. They would take away your control of the context. They would inject stuff behind your back, which is bad. Then, your workflows stopped working because there's now a system reminder that you don't even see in the UI that would modify the behaviour of the model. They would also do this to the system prompt. I built a little service where I can track the progression or evolution of the system, prompt and tool definitions and, with every release, it was messing with stuff. That just messed with my workflows and I don't appreciate that." #3 - PI was built with an appreciation for simple and reliable tools: "If I commit to a development tool, I want it to be a stable, reliable thing like a hammer. I don't want my hammer to break a different spot every day. That's terrible. We need somebody who goes the full velocity kind of way. But I don't want to work with a tool like that."

The Pragmatic Engineer

63,020 просмотров • 5 месяцев назад

I got curious how compaction works as a PM, so I did some brain surgery on Claude Code: (Anthropic's been doing really interesting work on context editing - they showed Claude Opus playing Settlers of Catan for 75+ minutes in a single thread by constantly editing the context instead of starting fresh. When I saw that Claude Code has a compaction command with optional custom instructions, I wanted to understand what's actually happening.) Abhishek Katiyar and Aman Khan gave me the key tip: Claude Code stores all your conversation history as text files on your computer. Open a new directory and give Claude Code a task. Here's how to watch compaction happening: 1. Go to your user's root directory 2. Press Command+Shift+Period (Mac) to show hidden folders 3. Navigate to ~/.claude/projects/ 4. Find your project folder and use Cursor/VSCode to open it (there's a reason) 5. Install the JSONL Gazelle plugin (open source, thank you Gabor Cselle!) 6. Open the most recent JSONL file - each row is a message in your conversation 7. Run the compact command in Claude Code with custom instructions 8. Watch what happens in the file What I learned: When you compact, Claude Code doesn't just summarize and delete everything. It creates a "compact boundary" in the conversation file, writes a summary of what happened before, but keeps the full original conversation (!!!!) The new thread can still retrieve any details from before compaction if needed. That is so damn cool. Why this matters: What you're getting in Claude Code is similar to what Anthropic ships in their developer SDK - so inspecting your daily tools is how you build real product intuition. The best way to understand AI systems is to open them up and look inside. Everything is text files.

Tal Raviv

58,082 просмотров • 9 месяцев назад