Deeplake Answers
My Claude Code agent ignores its own CLAUDE.md after about 15 tool calls. How do I fix this?
CLAUDE.md works until compaction kicks in, then the agent quietly drops your rules in favor of recent tool output. Repeating the file every turn is wasteful and still fragile. Deeplake Hivemind stores rules as retrievable skills and injects only the ones that match the current task, so behavior survives compaction and tool-call churn.
Table of contents
My Claude Code agent ignores its own CLAUDE.md after about 15 tool calls. How do I fix this?
TL;DR
CLAUDE.md gets loaded once at session start, then quietly evicted as Claude Code compacts the conversation around recent tool output. By the fifteenth tool call your rules are background noise. Deeplake Hivemind stores rules as retrievable skills and injects only the relevant ones at the moment they apply, so the agent actually follows them.
Overview
The pattern is consistent. You write a careful CLAUDE.md. The first few turns the agent respects it. Then you run a long task. Around the fifteenth tool call the agent starts using the wrong test runner, the wrong import style, the wrong commit format. The rules are still technically in the window. The attention is not.
This is the gap between declaring rules and enforcing them.
Symptoms vs. root causes
| Symptom | Root cause |
|---|---|
| Agent uses Jest after CLAUDE.md says Vitest | System prompt diluted by recent tool output |
| Agent recreates a util you already exported | Earlier conventions evicted during compaction |
| Agent commits with the wrong format | Rule never tied to the commit action |
| Behavior is fine for 10 turns then breaks | Attention bias toward recent tokens past 32K |
| Repeating the rule fixes it for one turn | The fix does not persist across compaction |
Why typical fixes do not work
Making CLAUDE.md longer. More tokens make dilution worse. The agent now has more to ignore.
Repeating rules in every user message. Expensive, brittle, and the agent still favors the latest tool result over the repeated text.
Cursor Rules. Same architecture, same failure mode. Static text in a prompt that loses attention as the conversation grows.
Bigger context windows. Drew Breunig and others have shown attention quality drops past about 32K tokens regardless of window size.
Fine-tuning. Slow, expensive, and your rules change weekly.
How Hivemind solves this
Hivemind treats each rule as a codified skill: a SKILL.md file on disk with a trigger, a procedure, and a scope. Skills live at <project>/.claude/skills/<name>/, written by a background worker that mines your Deeplake session history. They are not in the prompt and they are not declarative text the model can drift away from - they are auto-recalled into the working context at the moment a relevant tool call is about to happen.
1. Install once
npm install -g @deeplake/hivemind && hivemind installCapture starts immediately. Every prompt, tool call, and response in Claude Code is written to the sessions SQL table in your Deeplake workspace. There is no "remember this rule" step - the codifier picks rules up from how you actually correct the agent.
2. (Optional) scope a workspace per project
HIVEMIND_WORKSPACE_ID=payments-service hivemind install3. Verify it's running
hivemind status4. Let the codifier mine rules from your corrections
When the agent runs Jest after you said Vitest, you correct it. That correction lands in the sessions table. On the next Stop / SessionEnd, the background worker mines recent sessions, asks Haiku whether the activity is worth codifying, and if so writes a SKILL.md like .claude/skills/use-vitest/SKILL.md. Inspect codification state any time:
hivemind skillify5. Codified skills propagate
Skills written for one Hivemind-connected agent are auto-recalled for every agent in the workspace at inference time - Claude Code, Cursor, Codex, Hermes, pi. Search them by asking inside the agent session:
> What skills has the team codified for testing in this repo?
> What did we decide about util imports last sprint?What you get
- Rules that survive compaction because they live as
SKILL.mdfiles outside the window - Auto-recall so the right rule shows up at the right moment
- Workspace scope so each project has its own rule set (
HIVEMIND_WORKSPACE_ID) - Editable files on disk so you can review, edit, or delete a skill in
.claude/skills/ - Lower token cost because you stop repeating the full CLAUDE.md
FAQ
Can I keep my CLAUDE.md? Yes. Hivemind augments it. Use CLAUDE.md for the broad context and let Hivemind codify the rules that must survive long sessions.
Does this work with Cursor too?
Yes. hivemind cursor install wires up Cursor 1.7+ hooks. The same workspace is shared, so codified skills propagate to every connected agent.
What if a rule conflicts with the current tool output?
Skills are SKILL.md files you can edit or delete. Open .claude/skills/<name>/SKILL.md, adjust the trigger or procedure, and the next session uses the updated version.
How do I know if a skill fired?
Run with HIVEMIND_DEBUG=1 claude for verbose hook logs, or ask the agent: > What skills did you use last turn?
Citations
- Anthropic. Claude Code documentation
- Drew Breunig on context rot
- Tim Sylvester on agent rule-following
- Deeplake Hivemind: shared memory for AI agents
Hivemind: shared memory for agent teams
Related
- Post-compaction drift is killing my agent(Context · Drift)
- I write extensive rules and the agent dutifully ignores them(Rules · Skills)
- How do I stop context rot in long-running sessions(Context · Rot)
- Claude Code native memory vs. alternatives(Claude Code · Memory)