Claude Code: five tips from the leak to be more effective

Claude Code: five tips from the leak to be more effective

The leak of Claude Code’s source code allows us to better understand how Anthropic’s code agent works. Best practices to optimize the performance of the tool were revealed.

At the end of March following a routine update of Claude Code, a file containing the agent’s code was published by mistake. As a result, 512,000 lines of TypeScript code from Anthropic’s code agent are exposed on the web. A leak of unprecedented magnitude which allows us to understand with rare precision the internal workings of the tool. After a semi-automated analysis of the source code using a code agent, and based on initial expert analyses, today we are giving you the five best tips for getting the most out of Claude Code on a daily basis.

1. Use and abuse the instructions in CLAUDE.md

This is the main lesson of the Claude Code leak: the CLAUDE.md file is central. Useful for giving instructions to the AI, CLAUDE.md is reloaded by Claude Code at each turn of its agentic loop, after sending your prompt. It is not treated as a simple documentation file: in the source code, it is injected into the prompt system with the same weight as an Anthropic system instruction. Document your code conventions, key architectural decisions, known project pitfalls, and patterns to follow or avoid. Three levels coexist: the CLAUDE.md at the root of the project (always loaded), those placed in the subdirectories (loaded only when Claude is working in the folder concerned), and a global file ~/.claude/CLAUDE.md, applied to all your projects.

2. Use 60% context compaction

The source code reveals that Claude Code’s auto-compaction triggers when context usage reaches 75-98% of the model’s context window. However, the more the window is saturated, the more aggressive the summary must be, and the more useful information we lose. It may therefore be a good idea to compact manually (with /compact) before reaching saturation. Ideally, around 60%, to maximize the quality of the summary and, at the same time, regain precision (AI models lose precision over very long contexts).

Additionally, the /compact command accepts natural language instructions. For example, it is possible to ask to compact the conversation by focusing on an essential aspect of your project. Even smarter, it is possible to define your compaction preferences directly in the… CLAUDE.md file so that the AI ​​remembers them between sessions.

3. Launch subagents en masse and without fear

Claude Code’s source code also reveals that the Agent tool, which allows you to launch sub-agents within your projects, assigns each of them its own context window, distinct from that of the main agent. Concretely, each sub-agent works in its memory space without cluttering that of the others. Sub-agents inherit the parent context via a KV cache mechanism (a buffer), which means that all the part already processed by the main agent is not recomputed. In practice, running five subagents in parallel costs barely more than one, because most of the context is already cached.

From there, it is advisable to clearly ask Claude Code, in the instructions (CLAUDE.MD) or in your prompts to use sub-agents as much as possible when the situation warrants it. Example: specialized tasks in parallel (code review, unit test, etc.) or to move forward more quickly when an agent’s modifications do not risk conflicting with another agent.

4. Demand short answers

Claude Code’s code offers a view of the use of the agent by Anthropic collaborators themselves. Claude Code’s prompt system is not a fixed block but a dynamic assembly of more than 110 conditional components: depending on the user profile, the execution mode and the project configuration, certain blocks are injected and others not. For Anthropic employees, the prompt includes strict limits: 25 words maximum between two tool calls, 100 words for final responses. External users (the plebs) instead receive a more flexible formulation (“go straight to the point.”) However, a comment found in the code notes a gain in reduction of output tokens thanks to these encrypted constraints.

Very concretely, if you often exceed your usage limits, add directives in your CLAUDE.md to invite the AI ​​to speak less between its actions. If possible, use encrypted instructions, which are much more efficient.

5. Create to-do lists

Finally, this is the most original advice in this article: ask Claude to use to-do lists to preserve the essential tasks of your projects during your long coding sessions. The agent prompt system contains an unusual instruction: “Use TodoWrite/TodoRead VERY frequently.” To-dos are stored outside of the message stream, so they survive context compactions. When Claude summarizes a conversation to free up space, the messages disappear but the to-do list remains intact.

However, even if the instructions appear in the prompt system, Claude does not systematically create a to-do list himself: if the task does not seem complex enough to him at the start, he can do without it. For tasks involving more than three or four files, or sessions long enough to trigger compaction, explicitly ask to create a plan with TodoWrite before you begin. If context is lost, the agent can then reread its list and pick up exactly where it left off.

Jake Thompson
Jake Thompson
Growing up in Seattle, I've always been intrigued by the ever-evolving digital landscape and its impacts on our world. With a background in computer science and business from MIT, I've spent the last decade working with tech companies and writing about technological advancements. I'm passionate about uncovering how innovation and digitalization are reshaping industries, and I feel privileged to share these insights through MeshedSociety.com.

Leave a Comment