Levr
All articles

Claude Code context management: what to keep or cut

AI layer ablation is a controlled evaluation that removes instructions, skills, hooks, or delegated agent configurations to measure whether they still improve a coding agent’s results. For teams using Claude Code, the goal is not to blindly erase working project knowledge.

MMichael SwindellAugust 5, 202616 min read
Claude Code Context Management | Agentic Software Development L-62 | Levr

AI layer ablation is a controlled evaluation that removes instructions, skills, hooks, or delegated agent configurations to measure whether they still improve a coding agent’s results. For teams using Claude Code, the goal is not to blindly erase working project knowledge. It is to identify outdated guidance that constrains modern models and retain context that encodes your architecture, conventions, commands, safety boundaries, and acceptance criteria. A practical program compares the same representative tasks with a full configuration and a reduced baseline, then judges outputs for correctness, project fit, cost, and review effort. This article explains where to cut aggressively and where durable project-specific instructions still matter.

At a Glance

Ablation is an evaluation method, not a ritual of deleting every agent instruction.

  • Start with global rules: Always-loaded instructions create the greatest risk of context bloat and over-specification.
  • Preserve local knowledge: Project conventions, test commands, and safety constraints often remain valuable even as models improve.
  • Use matched tasks: Compare full and reduced configurations on the same issues, with consistent acceptance criteria.
  • Measure more than output: Include token cost, elapsed time, defects, review friction, and convention compliance.
  • Repeat selectively: Reassess global instructions after meaningful model changes, not necessarily every component every six months.

What does AI layer ablation mean for coding agents?

AI layer ablation means deliberately removing parts of an agent configuration, then testing whether task outcomes become worse, stay the same, or improve. It reveals which instructions provide real project value and which only consume context, add rigidity, or duplicate capabilities the current model already has.

An AI layer can include several kinds of context and operational logic:

  • Global rules: Instructions loaded into every session, such as a CLAUDE.md file, repository guidance, or organization-wide policies.
  • Skills and workflows: On-demand procedures for recurring work, such as release preparation, migrations, testing, or incident triage.
  • Hooks: Automated actions or guardrails that run before, during, or after agent work.
  • Subagents: Specialized workers delegated focused research, implementation, review, or validation tasks.
  • External documentation: Architecture notes, runbooks, API references, and internal conventions that agents retrieve when relevant.

The important distinction is between removing configuration as a test and removing it permanently. A useful ablation process starts with a hypothesis: “Does this instruction still change results?” If the answer is no across representative tasks, removing it may make the agent simpler and cheaper to operate.

That approach aligns with official guidance to keep Claude Code memory concise. Anthropic’s documentation on memory and CLAUDE.md files warns that overly long instruction files can bury important guidance in noise. Concision is not an aesthetic preference. It is a way to preserve attention for the instructions that truly affect behavior.

Why can too many coding-agent rules reduce performance?

Too many rules can reduce coding-agent performance because every always-loaded instruction competes for attention, creates constraints that may no longer be necessary, and can force an agent into obsolete workflows. Modern models often need clear outcomes and boundaries more than exhaustive step-by-step implementation prescriptions.

Over-specification often looks reasonable in isolation. A team adds a rule after an earlier model made a mistake. Then it adds another rule for a different edge case. Over time, a concise operating guide becomes a long collection of historical workarounds.

Some rules explain general software engineering behavior that stronger models can now infer. For example, an instruction that repeatedly explains how to inspect nearby code, think through dependencies, or create a migration plan may not add enough value to justify its persistent context cost.

Other rules are actively harmful when they dictate a single implementation sequence regardless of the task. If an agent is told exactly which abstractions to use before it has inspected the repository, it may follow the instruction rather than adapting to the codebase it actually finds.

A better global instruction usually specifies:

  • The desired outcome.
  • The non-negotiable safety or compatibility constraints.
  • The definition of done.
  • The required verification steps.
  • Where to find project-specific details when they are needed.

This mirrors the difference between defining a contract and micromanaging an implementation. Agents should have room to reason, but they still need boundaries around what counts as acceptable work.

Which parts of an AI layer should you ablate first?

Start with global rules because they are injected most often and therefore have the highest ongoing cost and strongest influence on agent behavior. Test broad reasoning instructions first, then retain concise rules that encode unique repository conventions, operational constraints, or critical validation requirements.

A practical priority order follows the context footprint and reuse frequency.

1. Global instructions and repository memory

Global rules are the best place to look for low-hanging fruit. They are typically present at the beginning of every coding session, whether the task needs them or not. Remove or shorten instructions that teach generic reasoning, prescribe unnecessary sequences, repeat repository information, or conflict with current practices.

Keep instructions that describe facts the model cannot reliably infer from source code alone, including:

  • Required test commands and environment setup.
  • Release, migration, or compatibility restrictions.
  • Security boundaries and prohibited actions.
  • Local code style conventions that are not consistently represented in the repository.
  • Ownership boundaries and approval requirements.

2. Large, rarely used skills

Skills and procedural documents are generally less urgent because they are retrieved or invoked only for relevant work. A 300-line deployment skill is not necessarily harmful if it is loaded only for deployments. Still, test whether the procedural detail improves outcomes or merely repeats information already available in scripts and documentation.

3. Hooks and automation

Hooks should be evaluated carefully. A hook that formats code, prevents secret exposure, runs required tests, or blocks dangerous commands is not equivalent to a verbose prompt instruction. Its value may be deterministic and independent of model quality. Test it only if you can preserve safety and validation controls during the experiment.

4. Subagents and delegation patterns

Subagents can be expensive to test because they affect orchestration, latency, and token use. Do not remove them only because a newer model is more capable. First identify their explicit purpose: parallel research, isolated review, long-running work, specialized context, or independent verification. If the main agent reliably handles that purpose without quality loss, simplify the workflow. For active sessions where token accumulation is unavoidable, employing dynamic context compaction ensures the model retains critical decisions without overflowing the active context.

Give coding agents context that stays connected to the work.

Levr provides a shared project control plane where coding agents can work from issues, acceptance criteria, tests, and workflow gates instead of relying on an ever-growing prompt alone.

Explore agent-first project workflows

How should you run an AI layer ablation experiment?

Run an AI layer ablation experiment by comparing full and reduced configurations on the same representative tasks, then grading both outcomes against consistent criteria. A useful experiment measures implementation correctness, project-convention compliance, test evidence, review effort, runtime, and token consumption rather than judging generated code by appearance alone.

Use a staged approach so you can isolate what actually helped.

Step 1: Inventory the current AI layer

List every source of context and control that affects the agent. Include global instruction files, skills, hooks, subagent prompts, MCP tools, architecture documents, and injected issue context. For each component, record when it loads, its approximate size, and its intended purpose.

This exercise often identifies accidental duplication. A testing command may appear in global rules, a skill, repository documentation, and a CI guide. Repetition does not necessarily improve compliance.

Step 2: Classify instructions by purpose

Sort content into two groups:

  • Reasoning repair: Instructions intended to compensate for a model’s general weaknesses, such as reminders to plan, inspect types, or use incremental changes.
  • Attention direction and customization: Instructions that point to project-specific conventions, required commands, acceptance criteria, security boundaries, or team preferences.

Reasoning-repair rules are strong candidates for removal as models improve. Customization rules deserve a higher bar because they carry information that no general model can know about your repository without being told.

Step 3: Select representative tasks

Choose tasks that resemble real engineering work. Include a bug fix, a feature requiring architectural decisions, a change that must follow local conventions, and a task involving tests or integration boundaries. Avoid evaluating only trivial edits, because they can hide differences between configurations.

Use the same issue statement, repository revision, available tools, and acceptance criteria for both runs. If one run receives extra context or a better task description, the comparison is no longer meaningful.

Step 4: Build a minimal baseline

Do not begin by deleting every layer at once. Create a reduced baseline that preserves essential access and safety controls while removing a targeted category of instructions. For example, reduce a 1,000-line global rule file to a short statement of the project purpose, required test command, and critical boundaries.

Step 5: Score the outputs

Use a written scorecard. Inspect the change set, run the tests, and evaluate whether the implementation followed repository conventions. A model can make a technically plausible architectural choice while still failing to register tests correctly, use the expected imports, or follow local naming patterns.

  • Correctness: Does the change meet the issue requirements?
  • Verification: Did relevant tests run, and do they demonstrate the intended behavior?
  • Convention fit: Does the work follow local patterns for files, imports, tests, and APIs?
  • Reviewability: How much cleanup, explanation, or rework does the pull request require?
  • Cost: How many tokens, tool calls, retries, and elapsed minutes did the task require?

Step 6: Restore only proven value

Bring instructions back one at a time or by coherent group. If restoring a rule improves scores consistently, keep it. If it changes nothing or makes results worse, remove it. This is the core of ablation: measuring marginal impact instead of treating every existing rule as essential.

What should you keep even when newer models reason better?

Keep instructions that express organization-specific knowledge, constraints, and definitions of quality because stronger general reasoning does not reveal local intent. Models may make sound architectural decisions with little guidance while still missing the conventions, validation paths, and operational limits that distinguish acceptable work in your codebase.

Ablation testing on a mature application can produce a revealing pattern: stripped-down context may be enough for difficult architectural work, yet it can fail rapidly on local compliance. The agent understands how to design a feature, but it does not know exactly how a team registers tests, structures imports, writes helper functions, or organizes modules.

These rules are not merely training wheels for weaker models. They are a compact expression of how your team works.

Keep or preserve access to the following:

  • Repository-specific test practices: Commands, fixture patterns, test registration, and expected coverage requirements.
  • Architecture boundaries: Allowed dependency direction, public API contracts, data model ownership, and migration rules.
  • Security and compliance requirements: Secrets handling, destructive operation limits, data access constraints, and review gates.
  • Operational knowledge: Deployment procedures, rollback requirements, observability expectations, and environment differences.
  • Team conventions: Naming, file placement, import style, error-handling patterns, and documentation expectations.

GitHub reaches a similar conclusion in its repository custom instructions documentation: repository-level guidance gives coding assistants context specific to the project. The useful question is not whether custom instructions should exist. It is whether each instruction contains distinct, actionable information that improves work.

How can engineering teams keep agent context from growing again?

Engineering teams can keep agent context lean by treating instructions as versioned operational assets with owners, purposes, and evidence of value. Review global rules after major model or workflow changes, move specialized procedures into on-demand skills, and connect agents to structured project state instead of repeatedly pasting context into prompts.

Use these operating rules:

  • Assign an owner: Every large instruction file needs someone responsible for removing stale guidance.
  • State the reason: Add a brief purpose beside non-obvious rules so future maintainers know what behavior it protects.
  • Prefer references over duplication: Point agents to a single source of truth when they need detailed procedures.
  • Separate global and local context: Global rules should be short. Specialized workflows belong in skills or task-specific documents.
  • Make verification explicit: Keep deterministic tests, CI checks, and approval gates outside of natural-language guidance where possible.
  • Track outcomes: If an instruction was added after a failure, verify later whether it still prevents that failure.

One way to operationalize this is through Levr’s agentic workflow. Teams can define intent in natural language, give agents structured issues and acceptance criteria, connect automated verification to the work, and keep human approval at the appropriate gate. Context becomes part of the project record rather than a pile of global prompt rules.

Technical Deep Dive FAQ

What is an AI layer in agentic development?

An AI layer is the collection of instructions, context sources, tools, workflows, and controls that shape how a coding agent works. It can include repository memory files, global rules, skills, hooks, subagents, MCP connections, task templates, and documentation. Some components provide durable project knowledge, while others were added to compensate for weaknesses in earlier models. Treating the layer as a single block makes it hard to maintain. Inventorying and evaluating its parts makes it possible to reduce unnecessary context without discarding essential controls.

What is ablation testing for coding agents?

Ablation testing for coding agents is an experiment that removes one instruction, feature, or configuration component at a time and compares performance against a baseline. The purpose is to determine the marginal value of that component. In practice, you run matched implementation tasks with full and reduced context, then score both results for correctness, tests, convention compliance, review effort, latency, and cost. An ablation result is useful only when the tasks and evaluation criteria are consistent enough to isolate the effect of the removed component.

Should you delete your entire CLAUDE.md file?

You can temporarily remove a CLAUDE.md file as an experiment, but deleting it permanently without testing is risky. Start by creating a minimal replacement containing only the repository purpose, essential commands, safety restrictions, and critical definition-of-done requirements. Then compare representative tasks against the full file. If the reduced version performs just as well, remove the stale material. If it loses project-specific compliance, restore the exact information that made a measurable difference. The goal is evidence-based pruning, not minimalism for its own sake.

How long should a CLAUDE.md file be?

There is no universally correct line count because repositories differ in complexity, but global instruction files should be concise enough that key rules remain easy for the model to follow. Anthropic recommends keeping CLAUDE.md files focused, with guidance around staying under roughly 200 lines where possible. The stronger principle is more useful than a fixed number: move specialized detail out of always-loaded memory, remove repeated instructions, and retain only information that is necessary across most sessions. Long files need a clear justification for every section.

What is the difference between rules, skills, hooks, and subagents?

Rules are persistent instructions that guide agent behavior, often loaded at the start of a session. Skills are reusable, task-specific workflows invoked when relevant. Hooks are automated actions or checks that run at defined points in the workflow, often without depending on model judgment. Subagents are delegated workers that take on narrower tasks such as research, implementation, or review. Because they load and operate differently, they should not receive the same pruning schedule. Global rules usually deserve the earliest and most frequent review.

Why do coding agents fail project conventions after context is removed?

Coding agents can infer many general engineering practices from source code and training, but local conventions are often implicit, inconsistent, or absent from the specific files the agent inspected. The model may implement a correct feature yet miss the project’s expected test registration, import ordering, error format, or module placement. That does not mean the model cannot reason. It means repository conventions are organization-specific data. Keep that knowledge concise, accessible, and attached to the work where it is needed.

How do you compare full and reduced agent configurations fairly?

Use the same repository commit, issue description, acceptance criteria, available tools, and environment for both configurations. Choose tasks with enough complexity to expose differences, then grade each output against a shared rubric. Run tests independently, inspect the diff, and record cleanup required during review. If possible, repeat across several task types rather than relying on one result. Random variation in model output means a single task can be misleading. The purpose is to identify recurring patterns, not declare a winner after one run.

Can ablation reduce token costs?

Yes. Reducing always-loaded instructions can lower the initial context sent to a coding agent and may reduce the amount of conflicting detail it has to process. However, cost savings are not automatic. A smaller AI layer can lead to more retries, missed conventions, or longer debugging loops if important context was removed. Measure total task cost, not only prompt size. Include input and output tokens, tool calls, elapsed time, test failures, and reviewer rework. The cheapest configuration is the one that produces acceptable work reliably with the least overall effort.

How often should a team review coding-agent instructions?

Review global instructions after meaningful model upgrades, major repository changes, or recurring evidence that agents are ignoring or misapplying guidance. A six-month cadence can work as a lightweight maintenance checkpoint, but a full ablation of every skill, hook, and subagent on that schedule is often unnecessary. Prioritize context that loads on every task and costs the most. Review specialized workflows less frequently unless their associated work changes, they create failures, or they consume a disproportionate amount of time and tokens.

Can a project control plane replace all coding-agent instructions?

No. A project control plane does not eliminate the need for clear agent instructions, repository documentation, or safety boundaries. It can reduce prompt sprawl by storing intent, issues, acceptance criteria, tests, workflow state, and approvals in shared structured objects. That gives agents and humans a common source of truth. Coding agents still need task-relevant context and constraints, but they do not need every piece of project knowledge copied into a global instruction file for every session.

Key Takeaways

AI layer ablation is most valuable when it removes stale global guidance while protecting the context that captures how your team actually builds software.

Use ablation to simplify, not to erase institutional knowledge.

  • Prune global rules first: Always-loaded instructions have the greatest potential to create context bloat and outdated constraints.
  • Test with real work: Compare matched tasks and judge correctness, convention fit, verification, cost, and review effort.
  • Keep project-specific knowledge: Modern models may need less general reasoning guidance, but they still need your standards and constraints.
  • Preserve deterministic controls: Tests, CI/CD, hooks, and approval gates should not be replaced by confidence in a prompt.
  • Centralize structured context: Shared issues, acceptance criteria, and test evidence reduce the need for repeated prompt instructions.

The best AI layer is not the smallest one. It is the smallest one that consistently produces work your team can trust.

Further reading

Ship at agent speed

Give your coding agents a control plane, not just a prompt.

Levr connects Claude Code, Cursor, Codex, and Copilot to shared project context with issues, acceptance criteria, gates, test suites, and attributable workflow history.

Get early access

No credit card required during beta.