A practical guide to the two biggest Claude Code pain points: context window management and CLAUDE.md bloat. Draws from a widely-shared Chinese-language analysis by ็ฑๅฏๅฏ-็ฑ็ๆดป, the open-source Citadel orchestration framework, community discussions on Reddit about what happens when you stop adding rules and start building infrastructure instead, and Anthropicโs July 2026 context-engineering guidance.
July 2026 Update: Delete Rules, Design Interfaces
Anthropicโs July 24, 2026 context-engineering post makes the earlier โCLAUDE.md pruningโ lesson more explicit: as newer models improve, many old instructions become drag. Anthropic reports cutting a large majority of Claude Codeโs system prompt for newer Claude models, described as more than 80%, while preserving performance on its internal coding evaluations. The practical lesson is not โdelete everythingโ; it is โmove from rule piles to better context surfaces.โ
| Older habit | Better pattern |
|---|---|
| Give Claude many specific rules | Let it match the surrounding codeโs idiom |
| Put examples for every tool in the system prompt | Design expressive tool schemas and descriptions |
| Load all verification rules upfront | Put verification into a skill loaded when needed |
| Use CLAUDE.md as memory for everything | Keep CLAUDE.md lightweight; use memory, skills, and references |
| Store every plan as plain Markdown | Use richer references when the task needs them: tests, HTML mockups, rubrics, code |
The student-facing version: CLAUDE.md should be a map and a gotcha file, not a warehouse. If a rule only restates what the repo structure, linter, type checker, tests, or tool schema already says, it probably belongs outside the always-loaded context.
Context Management Is the Core Battlefield
The original articleโs opening line: โไธไธๆ็ฎก็ๆฏๆ ธๅฟๆๅบโ โ context management is the core battlefield. Once your context window hits ~50% capacity, Claude starts compressing earlier messages, and quality drops. The key insight:
The smaller each task, the more likely it finishes within 50% context. The smaller the task, the more stable Claude is.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Context Window (200K) โ
โ โ
โ โโโโโโโโโโโ Sweet spot: each task โ
โ โ Task A โ completes in <50% context โ
โ โโโโโโโโโโโ โ
โ โโโโโโโโโโโ โ
โ โ Task B โ After 50%: compression kicks โ
โ โโโโโโโโโโโ in, Claude loses earlier info โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Task C (too large) โ ๏ธ RISK โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Five Rules from the Trenches
| Rule | Why |
|---|---|
| Always start in plan mode | Let Claude understand what to do before it touches code. Finish one task, then commit โ donโt batch |
| Use iTerm, not IDE terminals | IDE built-in terminals crash more easily with heavy Claude Code sessions |
| Voice input multiplies efficiency | Dictating context is 2-3ร faster than typing; great for initial specs |
| Use git worktrees | Handle multiple branches simultaneously without context-switching |
Run compact manually at ~50% |
Donโt wait for auto-compression; take control of what gets kept |
The Three-Role Architecture
The article describes Claude Codeโs architecture as three distinct roles working together:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Claude Code Architecture โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโค
โ Commands โ Agents โ Skills โ
โ (Entry & โ (Orchestrate โ (Domain โ
โ Interaction)โ & Route) โ Knowledge) โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโค
โ CLI input โ Subagents โ Preloaded specs โ
โ Slash cmds โ Task routing โ Workflows โ
โ User prompts โ Parallel ops โ Best practices โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
"What to do" "How to route" "What to know"
This is a progressive disclosure design โ Claude loads domain knowledge only when needed, avoiding context overload from the start.
Debugging: Observe, Donโt Guess
Two underrated debugging techniques from the article:
-
Watch the terminal as a log observer โ Run Claudeโs background task output in a visible terminal. Watching the raw flow reveals patterns youโd miss by just reading the final answer.
-
Use MCP to connect Claude to your browser โ Instead of copy-pasting error messages, let Claude read browser console output directly. Much more efficient than the โcopy โ paste โ describeโ loop.
The CLAUDE.md Bloat Problem
The community consensus: bloated CLAUDE.md files are a rite of passage. Everyoneโs first instinct is to add more rules. The result?
- Claude starts ignoring rules because there are too many
- Cost per session increases (more prompt tokens loaded every time)
- Rules contradict each other
- Adding โdonโt do Xโ rules creates a negative instruction spiral
The Solution: Infrastructure, Not More Rules
The Reddit thread captures this insight perfectly: the answer isnโt more rules โ itโs building the right infrastructure.
| Instead ofโฆ | Build thisโฆ |
|---|---|
| โAlways run tests before committingโ | A pre-commit hook that runs tests automatically |
| โUse the right model for simple tasksโ | An agent layer that routes by complexity |
| โDonโt exceed budgetโ | Budget enforcement with automatic model downgrade |
| โFollow our coding styleโ | A linter config that Claude reads and respects |
| โCheck these files before editingโ | Skills that preload relevant context |
The Pruning Methodology
A concrete case study: one developer pruned 60% of their CLAUDE.md rules. The result: response speed improved 40% and hallucinations decreased noticeably.
The step-by-step method:
- Run an audit prompt โ ask Claude to scan your CLAUDE.md for contradictions. Youโll discover conflicts you never noticed, like a vague โmaintain natural toneโ rule overriding specific formatting rules.
- Delete the flagged rules โ but donโt blindly delete everything flagged.
- Test with your 3 most common tasks โ run them after deletion.
- Evaluate: output the same or better? โ those rules were dead weight. A feature broke? โ add that one rule back.
The deeper insight:
โThe real skill isnโt knowing rules โ itโs knowing what to delete. Your AI settings should get simpler over time. If theyโre getting more complex, youโre using rule accumulation to avoid thinking about โwhat do I actually want?โโ
Claude canโt solve this for you. If you donโt know what you want, no amount of CLAUDE.md rules will produce it.
Practical CLAUDE.md Guidelines
| Guideline | Detail |
|---|---|
| Keep it under 200 lines | For each line, ask: โWould removing this cause Claude to make mistakes?โ If not, cut it |
| Use progressive disclosure | Put domain-specific knowledge in skills, not CLAUDE.md |
| Use sub-folder CLAUDE.md files | /frontend/CLAUDE.md, /backend/CLAUDE.md for scoped instructions |
| Audit regularly | Use a CLAUDE.md review workflow or plugin to check for contradictions and stale rules |
| Treat it like code | Review it, prune it, test changes by observing behavior shifts |
| Simplify over time | Your CLAUDE.md should get shorter as you learn what matters โ not longer |
Memory Imports: Shared Standards Without One Giant File
CLAUDE.md can import other Markdown files with @path references. This is the clean way to share team standards while keeping local preferences private and project-specific context scoped.
Source: Claude Code docs โ Memory imports. Check the docs for current depth limits and approval behavior before using imports in a locked-down classroom or enterprise setup.
# CLAUDE.md
## Project Overview
@README.md
## Team Standards
@docs/coding-standards.md
@docs/security.md
## Personal Preferences
@~/.claude/my-preferences.md
| Import type | Use it for |
|---|---|
| Relative path | Project docs such as @docs/architecture.md or @../shared-standards.md |
| Home path | Personal rules shared across worktrees, such as @~/.claude/review-style.md |
| Absolute path | Shared machine-local standards where a team controls the path |
The pattern that scales best is shared standards plus local overrides:
# CLAUDE.md - committed
@docs/team-standards.md
@docs/project-architecture.md
# CLAUDE.local.md - gitignored
@~/.claude/my-local-preferences.md
That gives every student or teammate the same baseline while leaving room for local editor paths, sandbox URLs, and personal workflow preferences. Use /memory during a session to inspect what actually loaded.
Cost Control: The Agent Layer Approach
The article highlights a real-world example: someone burned $15 in 8 minutes because they had no cost controls. Adding โdonโt use Opus for this taskโ as a rule doesnโt work โ Claude has 30+ model selection rules and ignores them.
The effective approach is an agent layer that:
User Request
โ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Complexity Router โ
โ โ
โ Simple? โ Haiku โ
โ Medium? โ Sonnet โ
โ Complex? โ Opus โ
โ โ
โ Budget remaining? โ
โ Yes โ proceed โ
โ No โ downgrade โ
โโโโโโโโโโโโโโโโโโโโโโโ
โ
Execution with enforced budget
This moves cost control from โprompt suggestionsโ to โinfrastructure decisions.โ
Citadel: A Full Implementation
Citadel by Seth Gammon is an open-source framework that implements these ideas as a complete system:
| Tier | Role | When to use |
|---|---|---|
| Skills | Domain experts | Single-task, specific knowledge |
| Marshal | Session coordinator | Multi-step within one session |
| Archon | Autonomous strategist | Cross-session campaigns |
| Fleet | Parallel agents | Independent tasks in isolated worktrees |
Key features: campaign persistence across sessions, parallel agent coordination with discovery sharing, lifecycle hooks for quality enforcement, and a universal /do router that classifies intent and dispatches to the cheapest capable tier.
The Boris Template: CLAUDE.md as AI Onboarding Manual
A widely-shared infographic (็ฑๅฏๅฏ-็ฑ็ๆดป) reframes CLAUDE.md as an AI co-workerโs onboarding manual โ not just a config file, but a structured document that lets AI โremember the past, carry out the present, and evolve into the future.โ
Source: ็ฑๅฏๅฏ-็ฑ็ๆดป on Weibo (2026-03)
The Problem It Solves
Without CLAUDE.md:
Every session starts from zero โ inefficient loop
โ User โ explain context โ AI executes โ session ends โ repeat โ
With CLAUDE.md:
AI reads your "onboarding manual" โ picks up where it left off
โ Past errors โ Project rules โ Execution rules โ โ Claude AI
The analogy: CLAUDE.md is a letter to future collaborators โ not just a config tool.
Boris Template Design
The Boris template structures CLAUDE.md into task modes:
| Mode | Purpose | When to Use |
|---|---|---|
| Simple Task | Write spec first, start | Quick changes |
| Complex Analysis | Subagent-based | Keep context coherent across subtasks |
| Post-correction | Update tasks/lessons.md | Donโt repeat mistakes next time |
| Task Complete | Prove completion | Donโt just claim done โ show evidence |
| Decision Making | Explain trade-offs | Not just explain what, explain why not |
Evolution Mechanism
The template defines three maturity levels:
| Level | How CLAUDE.md is Used |
|---|---|
| Beginner | Static config file (copy-paste and forget) |
| Intermediate | Update after each session (effect compounding) |
| Advanced | Dynamic updates via .bashrc + agent hooks (auto-evolution) |
Core Principles (from terminal screenshot)
The accompanying terminal screenshot reveals the full operating principles:
- Plan Mode Default โ Enter plan mode for ANY non-trivial task. If something goes sideways, STOP and re-plan immediately.
- Subagent Strategy โ Use subagents liberally to keep main context window clean. For complex problems, throw more compute at it via subagents.
- Self-Improvement Loop โ After ANY correction from user, update
tasks/lessons.mdwith the pattern. Write rules for yourself that prevent the same mistake. - Verification Before Done โ Never mark a task complete without proving it works. Run tests, check logs, demonstrate correctness.
- Demand Elegance (Balanced) โ For non-trivial changes, pause and ask โis there a more elegant way?โ But donโt over-engineer.
- Autonomous Bug Fixing โ Given a bug report, first list the evidence. Point at logs, errors, failing tests โ then resolve them. Zero context switching required from the user.
The .bashrc insight: the real nature of CLAUDE.md isnโt to make AI smarter โ itโs to make it more like a domesticated role-specific interface for your company, where computing power and knowledge become free-flowing water.
Complete Project Structure โ The Directory Cheat Sheet
A visual reference (by Sandipan Bhaumik / agentbuild.ai) showing the full Claude Code project directory structure. Most people only use CLAUDE.md โ the real power is in the .claude/ directory.
Source: ้ปๅบตยท่ถ ็บงไธชไฝ on Xiaohongshu (2026-04)
your-project/
โโโ CLAUDE.md ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท Loaded at session start. Project overview,
โ tech stack, coding conventions, architecture.
โโโ CLAUDE.local.md ยทยทยทยทยทยทยทยทยทยทยท Personal preferences. Overrides CLAUDE.md.
โ Git-ignored โ your private config.
โโโ .mcp.json ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท MCP integration configs. Connect to GitHub,
โ Jira, Slack, databases. Shared across team via git.
โ
โโโ .claude/
โโโ settings.json ยทยทยทยทยทยทยทยทยท Permissions & tool access. Model selection,
โ settings.local.json hooks config. .local overrides shared settings.
โ
โโโ rules/ ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท Modular .md files by topic:
โ โโโ code-style.md - Covers style, testing, API design
โ โโโ testing.md - Can target specific files/paths
โ โโโ api-conventions.md - Loaded automatically by Claude
โ
โโโ commands/ ยทยทยทยทยทยทยทยทยทยทยทยทยท Custom slash commands (/project-name):
โ โโโ review.md - Used for repeatable workflows
โ โโโ fix-issue.md - Supports shell execution
โ
โโโ skills/ ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท Auto-triggered based on task context:
โ โโโ deploy/ - Loads only when needed
โ โโโ SKILL.md - Keeps context lightweight
โ โโโ deploy-config.md
โ
โโโ agents/ ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท Specialized sub-agents with roles:
โ โโโ code-reviewer.md - Isolated context windows
โ โโโ security-auditor.md - Custom tools and model preferences
โ
โโโ hooks/
โโโ validate-bash.sh ยทยท Event-driven scripts (pre/post tool use).
Automate validation, testing, formatting.
Block unsafe operations.
What Each Layer Does
| Layer | Purpose | Key Insight |
|---|---|---|
| CLAUDE.md | Project rules + context | The โonboarding manualโ โ loaded every session |
| CLAUDE.local.md | Personal overrides | Git-ignored; your preferences without polluting team config |
| rules/ | Coding standards | Modular โ split by topic instead of one giant CLAUDE.md |
| commands/ | Repeatable workflows | Custom /slash-commands for your teamโs processes |
| skills/ | Domain knowledge | Auto-loaded only when relevant โ keeps context lean |
| agents/ | Specialized workers | Each agent has its own role, tools, and context isolation |
| hooks/ | Automation gates | Deterministic enforcement โ linters, tests, safety checks |
The Real Takeaway
โMost people put one CLAUDE.md and call it done. The real power is the
.claude/directory โ rules for standards, commands for workflows, skills for knowledge, agents for delegation, hooks for safety.โ
Configure once, benefit every session. The more structured your .claude/ directory, the more reliable and consistent Claudeโs output becomes.
How LearnAI Team Could Use This
- Prune shared CLAUDE.md files using the Boris template: keep under 100 lines, move specifics to sub-folder files.
- Move deterministic rules into hooks instead of prompt instructions โ code enforcement over prompt suggestions.
- Use the three-role architecture (Researcher โ Planner โ Executor) for complex documentation and wiki update tasks.
- Audit CLAUDE.md quarterly: delete rules you canโt remember writing, convert verbose instructions into 3-word imperatives.
Real-World Use Cases
- Running
claude-md-managementplugin to audit and prune bloated CLAUDE.md files across projects. - Setting up Citadel-style agent routing to use cheaper models for simple tasks and Opus for complex reasoning.
- Converting project-specific rules from global CLAUDE.md into sub-folder
.claude/CLAUDE.mdfiles that only load in context. - Using hooks for deterministic enforcement (formatting, commit messages, security checks) instead of relying on prompt compliance.
Key Takeaway
The articleโs closing line sums it up: using AI coding tools well isnโt about finding the perfect configuration โ itโs about understanding how the tool works, then building systems that flow with it.