Skip to navigation

Claude Code Context Audit: Inspect Loaded Files Before Adding More

In short: Use Claude Code's context view to identify loaded files and categories before adding another document or instruction to the session.

Published 19 min read
On this page

Direct answer

Run /context before adding another document, excerpt, or instruction. Official documentation says the command provides a live category breakdown, optimization suggestions, and visibility into specific loaded files (F058, F059). Use that inventory to find duplicates, stale task evidence, and missing sources.

The audit does not score reasoning quality, and a smaller category is not automatically a better one. Keep evidence that can change the current decision. Replace material that belongs to an earlier task. This is a relevance check on what is present now, not a guide to capacity, memory behavior, or compaction.

Why audit before adding more

A session accumulates material through work. A file is mentioned for diagnosis. Command output is pasted to confirm a symptom. A project instruction loads at the start. A previous phase leaves behind a contract that the current phase no longer uses.

Adding one more item can feel harmless because each item had a reason when it entered. The problem appears later, when those reasons conflict. The agent must reconcile an old fixture with a current caller, or a broad instruction with a narrow task boundary.

An audit makes the accumulation visible. It lets you ask a different question from “What else should I include?” The better question is “What is already here, and does it still serve this task?”

The file reference guide explains how to add targeted evidence. The audit supplies the preceding check. A focused reference is useful only if the session does not already contain a stale or contradictory version of the same evidence.

Audit work also has a cost. Reading the inventory, classifying files, and resolving duplicates takes human attention. The cost per verified change framework supports counting that review effort rather than assuming every extra control pays for itself.

Use the audit at meaningful boundaries: after diagnosis, before implementation, and after a major change in direction. A check after every trivial tool call would create noise without improving the evidence set.

What the official evidence establishes

Official (F058). The context-window documentation says /context provides a live category breakdown and optimization suggestions. It reports session composition. It does not produce a reasoning-quality score.

Official (F059). The same documentation says /context reveals specific loaded files, including CLAUDE.md and auto-memory documents. That visibility supports a file-level relevance check. This article does not infer how those documents are retained or compacted.

Official, search-index evidence only (F060). The how-Claude-Code-works excerpt lists conversation history, files, command output, CLAUDE.md, skills, and system instructions as context inputs. The full page was not fetched, so the list is used only at that high level.

Official (F040). The project memory documentation says CLAUDE.md is loaded into every session and that larger files take more context and attention. The loading fact gives a reason to inspect relevance, not evidence of a measured quality penalty.

The official commands reference and Claude Code best practices are included as further reading. No detailed command behavior beyond F058 is attributed to a canonical-link-only source.

Context audit evidence map linking visible categories and loaded files to a relevance decision
Editorial map based on official facts F058-F060. The view exposes composition, not a quality score.

Open the context view

Run /context at the start of the audit. Record the current task question before looking at the output. That question is the standard against which each category and file will be judged.

A simple audit note has three fields:

Current question: What must change, and what evidence is missing?
Visible categories: Copy the category names shown by /context.
Visible files: Record the specific loaded files that bear on the question.

Do not turn the note into a second transcript. Its job is to preserve the audit decision long enough to act on it. If a later task changes the question, update the note rather than treating the old inventory as permanent.

The view’s optimization suggestions are prompts for review, not automatic proof that a category should be removed. A system instruction may be essential even when it is large. A tool result may be small but irrelevant. Size and relevance are different properties.

The context relevance guide provides the decision rule: include evidence that can change the answer. Apply it item by item instead of optimizing for a visually tidy category list.

Identify the largest categories

Begin with the largest visible categories, but do not end there. A small stale instruction can matter more than a large body of useful source code. Size helps prioritize inspection; the task determines importance.

For each category, identify its source and its current role. Conversation history may contain the accepted decision. Files may contain the implementation. Command output may contain the observed failure. Project instructions may contain a durable boundary. The high-level input list in F060 supports asking those source questions without asserting a detailed internal taxonomy.

Context category Likely source to inspect Relevance question Possible action
Conversation history Earlier task messages and decisions Does this decision still govern the work? Keep, summarize outside the model, or start a focused phase
Files Mentioned or inspected artifacts Does this file answer the current question? Keep, narrow, or replace
Command output Commands and their visible results Is this the observation the decision needs? Keep the relevant excerpt or discard the copy
Project instructions Loaded instruction files Is the rule durable and applicable here? Keep, scope, or resolve conflict
Skills Conditionally relevant instruction material Does the current task need this capability? Keep only if the task invokes it
System instructions Harness-provided context Is this foundational rather than task evidence? Do not treat it as optional task context

The table is an editorial classification aid, not a claim that /context uses exactly these labels. F060 supplies the high-level input types. The live view supplies the actual category names for the session.

A large category deserves a sample, not an automatic deletion. Inspect a few representative items and trace their origin. If most of the category supports the current question, preserve it. If it belongs to a finished investigation, stop relying on it for the new phase.

The prompt caching economics discussion may matter for a separate cost review. It does not establish that a category is irrelevant. Keep cost analysis and relevance analysis connected but distinct.

Inspect loaded project files

F059 makes this step concrete: /context can reveal specific loaded files such as CLAUDE.md and auto-memory documents. Inspect the files that bear on the task, especially when their instructions could conflict with the current brief.

For each loaded file, ask three questions. Who is expected to follow it? When does it apply? What observable behavior does it request? A rule that applies only to one path can become noise in an unrelated task. A durable decision may remain valuable across many tasks.

Official (F041). Claude Code best practices recommends keeping CLAUDE.md short and focused on non-discoverable information. Use that as a review principle, not as a hard limit. The essential project instructions guide explains how to separate durable context from task-specific detail.

A file-level audit should not become a configuration exercise. The progressive disclosure guide covers path-scoped organization. Here, the immediate task is to identify what is loaded and whether it belongs in the current reasoning path.

Loaded file Task relevance Conflict check Action
Root project instructions Broad boundary may apply Compare with the current task brief Keep if durable and applicable
Nested instructions Relevant to one path Check whether that path is involved Keep only for the scoped work
Auto-memory document May contain prior project facts Check date and decision status in the task record Treat as evidence to verify, not automatic truth
Task-specific excerpt Useful during diagnosis May be superseded by implementation evidence Replace when the task shifts
Generated reference May describe current output Compare with the source of generation Keep only when the generated artifact matters

The term auto-memory appears because F059 names it as visible. This article does not describe its retention, compaction, or precedence semantics. The audit concerns the document’s relevance to the present question.

If a loaded file contains sensitive material that the task does not need, stop using it and follow the project’s handling rules. The secrets and transcript guide covers the broader exposure problem. Context hygiene is not a substitute for access control.

Spot duplicated instructions

Duplication is not limited to repeated text. Two instructions can express the same rule in different words, or one can repeat a task brief in permanent project context. The audit should identify both exact copies and overlapping intent.

Start with the current task brief. Compare its constraints with loaded project instructions. If the same exclusion appears in both, decide which location owns the durable rule and which owns the temporary task detail. Do not add a third copy to emphasize the point.

The conflicting instructions guide explains why loading order is not guaranteed behavioral precedence. The practical response is to remove or scope the conflict, not to make the wording louder.

Useful duplicate patterns include:

  • A task brief repeats a standing project rule verbatim.
  • A nested file repeats the root rule without adding path-specific detail.
  • An old answer restates a contract that has since changed.
  • A command output repeats an excerpt already present in a source file.
  • A skill description overlaps a project instruction without clarifying when it applies.

The tool schema guide applies a related clarity principle to tool definitions. Names and descriptions should reduce ambiguity rather than repeat each other. Context instructions need the same discipline.

When two instructions conflict, preserve the conflict in the audit note until it is resolved. Record which source is current and why. A clean-looking prompt that hides disagreement is less useful than an explicit decision with evidence.

Spot stale task evidence

Stale evidence was once useful. Its problem is temporal, not textual. A fixture from an earlier branch, an output from before an edit, or a rejected plan can remain visible after the task has moved on.

Mark evidence by phase. Diagnosis evidence explains the original symptom. Implementation evidence describes the proposed change. Verification evidence records the observed result after the change. Mixing these phases can make an old failure look current or an old success look final.

The task checkpoint guide offers a place to record the phase transition. The plan revision guide helps when new evidence changes the approved direction. Neither source guarantees that the session will discard old material automatically.

A stale-evidence table keeps the decision reviewable:

Evidence item Original phase Current status Audit action
Original error excerpt Diagnosis Still explains the symptom Keep as historical evidence
Rejected mapping sketch Planning No longer under consideration Stop using it as a candidate
Pre-edit command output Diagnosis Superseded by later output Keep only for before-and-after comparison
Proposed contract Planning Accepted with a changed field Replace with the accepted contract
Post-edit result Verification Incomplete Keep and name the missing check

Official, search-index evidence only (F056). Interactive-mode documentation says commands and output enter conversation context. That supports watching for stale outputs. It does not establish a specific command for removing them.

When a current answer relies on old output, ask for the source and the phase. If the output predates the relevant edit, it cannot by itself establish the new behavior. The verification evidence guide supports requesting evidence rather than trusting a summary.

Remove or replace low-value context

Removal here means changing what the current work relies on. It does not mean claiming that /context deletes an item. The documented fact is visibility (F058, F059), not a universal removal control.

For a pasted excerpt, stop repeating it and point to the source. For an obsolete task assumption, state the replacement explicitly. For a broad exploration that has finished, begin a focused phase with the accepted decision and the evidence still needed.

A fresh session can separate unrelated work, but it also loses useful history. The session handoff guide explains how to carry decisions without treating the transcript as the only record. Use a handoff when continuity matters more than separation.

Replacement should name both sides: what is being superseded and what replaces it. “Use the current caller contract” is weaker than “The caller contract in the current branch supersedes the fixture used during diagnosis.” The second sentence gives the agent a reviewable reason to ignore the old source.

Do not remove evidence merely because it contradicts the preferred answer. Contradictory material can reveal a missing decision. The context relevance guide explicitly treats evidence selection as a decision question, not a contest to collect the most files.

Add only the missing evidence

Once the inventory is classified, identify the actual gap. A missing caller contract requires a different action from a duplicated project rule. A stale output requires a new observation, not another copy of the old file.

Use the file reference method for a named artifact. Use a targeted output excerpt when the question concerns observed state. Explain why each addition can change the answer.

A useful addition note looks like this:

Missing evidence: The caller's accepted status values.
Why it matters: The writer alone cannot establish the returned contract.
Planned addition: The direct caller and its status mapping.
Evidence not needed: Unrelated billing reports and old fixtures.

This is an editorial template, not a product feature. It forces the audit to end in a specific action rather than an unbounded reading list.

If the missing item is a product decision, more files will not settle it. The ambiguous requirements guide separates discoverable code facts from choices that need a human answer.

The tool choice investigation guide can help request the next evidence-gathering step. It does not make every Messages API control available in interactive Claude Code, so keep the execution surface explicit.

Close the gap with a replacement decision

An audit finding becomes useful when it names a replacement. “Old fixture” is only a label. “The current caller contract replaces the fixture because the fixture describes the retired response shape” is a decision that can guide the next read and survive review.

Write the replacement beside the finding. Include the reason, the source, and the task phase. If the reason is uncertain, keep the item available but mark the uncertainty instead of silently promoting the newer source. A newer file is not automatically a better authority.

Negative evidence also deserves a place in the note. A search that finds no second caller supports a narrower claim than a search that was never run. Record the inspected scope so a later reviewer can tell the difference. The verification evidence guide supports that kind of traceability without claiming complete coverage from a single search.

When the gap remains after replacement, stop the audit and act on the gap. Add the caller, ask the product owner, or request a current observation. Continuing to categorize already-classified material would delay the decision without adding evidence.

Context audit workflow from opening the live view to classifying loaded files and adding missing evidence
Editorial workflow applying F058 and F059. Classification and replacement are human review steps, not documented automatic controls.

Worked example: before-and-after context audit

Consider a fictional task that began with an invoice-status investigation and then moved to implementation. The session contains the original symptom, a candidate writer, a caller excerpt, a project instruction, and a rejected mapping sketch.

The current question is no longer “Where might the bug live?” It is “Does the accepted mapping satisfy every direct consumer?” That change makes the original broad exploration less important and the caller contract more important.

Before the audit, the evidence set looks like this:

Item Current relevance Problem
Original symptom output Historical diagnosis Does not show post-edit behavior
Candidate writer Directly relevant May not include the caller contract
Caller excerpt Directly relevant Needs confirmation against the current branch
Project instruction Broadly relevant May duplicate the task boundary
Rejected mapping sketch Not current Can confuse the accepted direction

Run /context and confirm which files are actually loaded. Then classify the rejected sketch as historical and replace the old caller excerpt if a current contract is available. Add a targeted post-edit observation only when it can answer the remaining consumer question.

After the audit, the working set is smaller in purpose, not necessarily smaller in every category:

Item after audit Role in the current task Next check
Accepted caller contract Defines expected status values Inspect each direct consumer
Current writer Implements the mapping Compare with the contract
Project boundary Prevents unrelated redesign Check for duplicated task wording
Missing consumer evidence Blocks completion Add the consumer as targeted evidence
Original symptom Historical baseline Use only for comparison

The parallel tool call guide can help request independent consumer reads together. If one consumer path is discovered by another read, keep that dependency sequential.

No token counts or quality scores are invented for this example. The result is a clearer evidence inventory. Whether the answer improves still depends on the code, the task, and the inspection of the final claim.

Repeat the audit after a major task shift

A major shift changes the question. Examples include moving from diagnosis to implementation, from one subsystem to another, or from a proposed approach to an approved replacement. These are the moments when old evidence is most likely to remain active by accident.

At each shift, write the new question in one sentence. Run /context again. Reclassify only the items whose role changed. Repeating the check at that boundary keeps the audit proportionate instead of restarting the entire review.

The tool result contract guide is useful when new observations arrive. A result should answer the question that caused the call. If the question has changed, an old success status may no longer close the current gap.

A shift also changes what counts as missing. A diagnostic task may need symptoms and candidate locations. An implementation task needs the accepted contract and edit target. A verification task needs observed results. The observable requirements guide helps keep those outcomes explicit.

The context-window versus memory article and compaction retention discussion cover different problems. Neither mechanism is required for this audit. It is a deliberate review of current inputs before adding more.

Practical audit matrix

Use the matrix when the session feels crowded but the next action is unclear.

Observation Interpretation Action Evidence to record
Same rule in two loaded files Duplication or scope conflict Choose the durable owner and scope the other File paths and applicable task
Old output cited as current Phase confusion Request a current observation Before-and-after results
Large useful source category High volume, high relevance Keep and sample for coverage Question each sample answers
Small irrelevant fixture Low decision value Stop relying on it Reason it is unrelated
Missing direct caller Evidence gap Add the caller Relationship to the producer
Product rule absent from all files Human decision needed Ask the owner Decision and accepted boundary
Contradictory contracts Unresolved requirement Preserve conflict and escalate Both sources and affected behavior

The model choice resource for coding agents can support a capability decision, but it cannot classify the session’s evidence. The context glossary can clarify terminology without turning the audit into a capacity calculation.

Context audit tradeoff comparing category size with task relevance and the risk of stale evidence
Editorial tradeoff based on F058-F060. Category size is a triage signal, not proof of low quality or low importance.

Win, loss, and practical implication

Concrete win. In the fictional invoice task, the audit reveals that the rejected mapping sketch is still visible while the current caller contract is missing. Replacing the sketch with the accepted contract gives the implementation step a clear standard and prevents an old candidate from reappearing in the answer.

Concrete loss. The audit itself can become a ritual. A team may spend time categorizing every message while missing the one missing consumer that blocks the task. The loss is review effort without a changed decision.

Practical implication. Audit at phase boundaries and stop when the next evidence gap is clear. The purpose is not a pristine context inventory. The purpose is a defensible answer built from current, relevant evidence.

Context audit control checklist for loaded files, duplicated instructions, stale evidence, and task shifts
Editorial checklist derived from F058 and F059. It does not assert that the view automatically removes or ranks task evidence.
Context audit verdict balancing current relevant evidence against stale files and unnecessary review
Editorial verdict based on F058-F060. A clear inventory supports review but does not prove answer quality.

Data gaps and future updates

No verified benchmark in the fact pack connects a context audit with answer quality, correction rate, or cost. The documentation establishes visibility and suggestions, not a universal threshold for when a category is too large.

F060 rests on a search excerpt rather than a full fetch. The commands reference is canonical-link-only. A future update should recheck those pages before adding detailed category mechanics or new commands.

Community reports: None are cited. The pack contains no verified issue with a reproducible method and outcome, so no community claim is promoted into product behavior.

One AI API Key option for OpenAI-format agents

For a separate OpenAI-format agent, One AI API Key offers one key at https://api.oneaiapikey.com/v1 and 46 live free IDs in the checked batch record. Its Claude IDs were unavailable on 2026-11-27, so those free IDs must not be presented as a Claude Code model source. Review the free model listing for the OpenAI-format option and the cost calculator for a separate workflow comparison.

FAQ

Does /context tell me whether an answer will be good?

No. F058 says it provides a live category breakdown and optimization suggestions. It does not score reasoning quality or prove that the agent will use the visible evidence correctly.

Should I remove the largest category first?

Not automatically. Size helps prioritize inspection, but relevance determines value. A large source category may be essential, while a small stale fixture may mislead the task.

Can /context remove old evidence?

The verified fact is that it reveals composition and loaded files (F058, F059). This article does not claim a deletion control. Replace reliance on stale material explicitly or begin a focused phase when separation is useful.

When should I repeat the audit?

Repeat it after a major task shift, before implementation, and when new evidence changes the accepted direction. Avoid auditing after every trivial action unless a specific discrepancy needs investigation.

More Claude Code troubleshooting

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →