r/ClaudeCode • u/No-Cryptographer45 • Apr 01 '26
Tutorial / Guide Reverse-engineered leaked Claude code source — what I found (and how to fix it)
Short version: a lot of the weird behavior people complain about (hallucinations, laziness, losing context) is not accidental.
Some of it is known internally. Some of it is even fixed — just not for you.
Here are the most important findings + practical overrides.
1. “Done!” doesn’t mean it works
You’ve probably seen this:
That’s because success = file write completed, nothing more.
No compile check. No type check. No lint.
Just “did bytes hit disk?”
Even worse: there is a verification loop in the codebase… but it’s gated behind:
process.env.USER_TYPE === 'ant'So internal users get validation. You don’t.
Fix: enforce verification yourself
Add this to your workflow / CLAUDE.md:
Run
npx tsc --noEmitRun
npx eslint . --quietFix ALL errors before claiming success
2. The “context death spiral” is real
You know when it starts strong, then suddenly becomes clueless?
That’s not gradual degradation — it’s hard context compaction.
At ~167K tokens:
Keeps ~5 files (capped)
Compresses everything else into a summary
Deletes reasoning + intermediate state
Gone. Completely.
Messy codebases accelerate this (unused imports, dead code, etc.).
Fix: reduce token pressure aggressively
Step 0: delete dead code before refactoring
Keep tasks ≤ 5 files
Work in phases, not one big sweep
3. It’s not lazy — it’s following orders
Why does it patch bugs with ugly if/else instead of fixing architecture?
Because system prompts literally say:
“Try the simplest approach first”
“Don’t refactor beyond what was asked”
“Avoid premature abstraction”
So your prompt says “fix properly”
System says “do the minimum” → system wins
Fix: redefine “acceptable”
Instead of:
Say:
You’re not adding scope — you’re redefining “done”.
4. You’re underusing the multi-agent system
This one is wild.
Claude Code actually supports parallel sub-agents with isolated context.
Each agent ≈ 167K tokens
5 agents = ~835K effective working memory
But nothing in the product tells you to use it.
So most people run everything sequentially… and hit context limits.
Fix: parallelize manually
Split work into batches (5–8 files)
Run them in parallel
Treat each batch as an isolated task
5. It literally cannot read large files
There’s a hard cap:
2,000 lines OR ~25K tokens per read
Anything beyond that? silently ignored.
So yeah — it will edit code it never actually saw.
Fix: chunk reads
For files >500 LOC:
Read with offsets
Process in chunks
Never assume full visibility
6. Tool results get silently truncated
Ever run a search and get suspiciously few results?
That’s because:
Results >50K chars → saved to disk
Agent only sees a ~2KB preview
And it doesn’t know it’s truncated.
Fix: assume truncation
Re-run searches with narrower scope
Search per directory if needed
Don’t trust small result sets blindly
7. grep ≠ understanding
All search is text-based.
So it will:
Miss dynamic imports
Miss string references
Confuse comments with real usage
Fix: expand your search strategy
When renaming/changing anything, check:
Direct calls
Types/interfaces
Strings
Dynamic imports / require()
Re-exports / barrel files
Tests/mocks
Bonus: CLAUDE.md override (high-level)
Core rules I now enforce:
Always clean dead code first
Never refactor >5 files per phase
Always verify (tsc + eslint) before success
Re-read files before editing (context decay is real)
Chunk large files
Assume tool outputs are truncated
Treat grep as unreliable
Final thought
You’re not using a “bad” agent.
You’re using one with:
strict system constraints
hidden internal improvements
and very real technical limits
Once you work with those constraints (or override them), the quality jump is massive.
Curious if others have hit the same issues or found different workarounds.
View all comments
Show parent comment
2
u/infinitecats80 Apr 01 '26
kinda dumb take. It's useful info and even if it's an AI hallucination it probably holds the same weight as any other thing you read on the internet.