TimoBy Amotion AI

Large codebase context: CCAR-F task statement 5.4

CCAR-F · Context Management & Reliability (15% of the exam)

Task statement 5.4 sits in Context Management & Reliability, 15% of the CCAR-F exam. It tests how to keep a long exploration of a large codebase accurate as the context fills: delegate searching to subagents, write findings to files, compact with instructions, and resume cleanly after a crash.

What the official guide covers

The Claude Certified Architect Foundations exam guide (version 1.0, effective July 2026) lists this under task statement 5.4, "Manage context effectively in large codebase exploration":

Knowledge ofSkills in
Context degradation in long sessions: answers become inconsistent and refer to "typical patterns" instead of the specific classes found earlierSpawning subagents for specific questions ("find all test files", "trace refund flow dependencies") while the main agent keeps the overall picture
Scratchpad files keep key findings across context boundariesHaving agents keep scratchpad files of key findings and consult them for later questions
Subagents isolate verbose exploration output while the main agent coordinatesSummarising one phase's findings before spawning subagents for the next phase, and putting that summary in their initial context
Structured state for crash recovery: each agent exports state to a known location and the coordinator loads a manifest on resumeDesigning crash recovery with state exports (manifests) that the coordinator loads and injects into agent prompts
Using /compact to reduce context during long exploration sessions full of verbose discovery output

What fills the context

In Claude Code, the context window holds the whole conversation: every message, every file Claude reads and every command output. One exploration can use tens of thousands of tokens. Claude Code's documentation warns that performance degrades as the context fills, and Claude may start to forget earlier instructions or make more mistakes.

The guide names the symptom to look for: Claude stops naming the InvoiceLedger class it found an hour ago and starts describing "a typical service layer". Answers to the same question begin to differ. Run /context to see what is using the space.

Subagents keep exploration out of the main context

A subagent runs in its own context window with its own system prompt and tools. It can read 40 files, and only its summary returns to the main conversation.

OptionWhereNotes
Built-in Explore subagentClaude CodeRead-only (Write and Edit denied). Claude picks a thoroughness level: quick, medium or very thorough. Skips CLAUDE.md to stay fast
Custom subagent file.claude/agents/ (project) or ~/.claude/agents/ (personal)Frontmatter sets name, description, tools and optionally model
AgentDefinitionAgent SDK, agents optionThe main agent calls subagents through the Agent tool, so include "Agent" in allowed_tools. Older SDK versions, and the exam guide, call it Task

A project subagent for tracing flows might look like this:

---
name: flow-tracer
description: Traces how a request moves through the codebase. Use for questions like "trace the refund flow" or "which modules call PaymentGateway".
tools: Read, Grep, Glob
---
Trace only the flow you are asked about. Return at most 30 lines:
- entry points as file:line
- classes and functions in call order
- external services touched
- questions you could not answer
Do not paste whole files.

One rule catches many candidates: a subagent does not see the parent conversation. Its context starts with its own system prompt, its tools, usually the project CLAUDE.md, and the prompt written for that call. The parent's history, tool results and loaded skills do not come with it (list skills in the subagent's skills field if it needs them). So when phase 2 depends on what phase 1 found, summarise phase 1 and put that summary in each phase 2 prompt.

Two details sit on either side of that rule:

  • Explore and Plan skip CLAUDE.md. A project rule such as "never read files under vendor/" is not in their context. When project constraints must apply, use a custom subagent or the general-purpose one.
  • A fork is the exception. Claude Code can also start a fork, a subagent that inherits the whole conversation so far (/subtask starts one). Its tool calls still stay out of your context, but it gives up the clean start. Use a fork for a side task that needs everything said so far; use a normal subagent when a clean, focused context is the point.

Scratchpad files

A scratchpad is a plain file where the agent writes what it has confirmed: class names, file paths, decisions, open questions. Before answering a later question, the agent reads it again. The file survives /compact, /clear and a new session, because it lives on disk, not in the context. Anthropic's context engineering guidance calls this structured note-taking, for example an agent keeping a NOTES.md file.

/compact and /clear

  • /compact Focus on the refund flow findings summarises the session and tells Claude what to keep. Use it when the task continues but the context is full of discovery output.
  • A "Compact instructions" section in CLAUDE.md sets what every compaction keeps, such as "always keep the list of files changed and the test commands".
  • Claude Code also compacts automatically as the context approaches its limit.
  • /clear starts fresh. Use it between unrelated tasks, not in the middle of one.

Rewind: summarise part of the session, or drop a dead end

/compact compresses everything. The rewind menu (/rewind, or Esc twice on an empty prompt) works on part of the session. Pick an earlier prompt, then choose:

OptionUse it when
Summarize from hereA long debugging detour after that point is filling the context; your setup and instructions before it stay word for word
Summarize up to hereA long setup phase before that point can be compressed; the recent work stays intact
Restore conversationClaude went down a wrong path; drop that stretch of conversation and try again
Restore code, or code and conversationThe edits from the wrong path should go too

As with /compact, you can type what the summary should focus on. Restoring code covers edits made with Claude's file editing tools, not files changed through Bash commands, and usually not edits a subagent made.

Put findings back after every compaction

A scratchpad only helps if Claude reads it. After every compaction, manual or automatic, a SessionStart hook whose matcher is compact runs, and any plain text it prints joins Claude's context. Point it at the findings file:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "compact",
        "hooks": [
          { "type": "command", "command": "cat \"${CLAUDE_PROJECT_DIR}\"/FINDINGS.md" }
        ]
      }
    ]
  }
}

Now the confirmed class names and file paths come back after every summary, whether or not Claude remembers to check the file. The compaction events also have their own hooks (PreCompact, PostCompact), but SessionStart with compact is the one whose output goes back into the conversation.

Crash recovery with a manifest

For a long multi-agent run, each agent writes its state to a known place, and the coordinator reads a manifest when it restarts.

import json
from pathlib import Path

STATE_DIR = Path(".agent-state")
MANIFEST = STATE_DIR / "manifest.json"

def load_manifest() -> dict:
    return json.loads(MANIFEST.read_text()) if MANIFEST.exists() else {}

def save_state(agent: str, status: str, findings: list[str], next_step: str) -> None:
    STATE_DIR.mkdir(exist_ok=True)
    state = {"status": status, "findings": findings, "next_step": next_step}
    (STATE_DIR / f"{agent}.json").write_text(json.dumps(state, indent=2))
    manifest = load_manifest()
    manifest[agent] = {"status": status, "state_file": f"{agent}.json"}
    MANIFEST.write_text(json.dumps(manifest, indent=2))

def resume_prompt(agent: str, task: str) -> str:
    entry = load_manifest().get(agent)
    if entry is None or entry["status"] == "done":
        return task
    state = json.loads((STATE_DIR / entry["state_file"]).read_text())
    found = "\n".join(f"- {f}" for f in state["findings"])
    return f"{task}\n\nYou are resuming earlier work. Confirmed so far:\n{found}\nContinue from: {state['next_step']}"

Each agent calls save_state after every finding it confirms. On restart, the coordinator skips agents marked done and builds each unfinished agent's prompt with resume_prompt, so no agent starts from nothing.

Which technique fits

SituationChooseWhy
A question needs many files read ("find all test files")Subagent (Explore or custom)Verbose output stays out of the main context
Answers drift to generic patterns after a long sessionScratchpad file, then /compact with instructionsFindings are kept on disk and in the summary
Phase 2 subagents repeat phase 1 mistakesSummarise phase 1 into each phase 2 promptSubagents do not inherit the parent's history
Moving to an unrelated task/clearOld context only adds noise
A long multi-agent run may crashState files plus a manifest loaded on resumeWork restarts from the last confirmed point
A debugging detour mid-session filled the contextRewind, then Summarize from hereCompresses the detour, keeps earlier instructions intact
Findings vanish after automatic compactionSessionStart hook with the compact matcher prints the findings fileRe-injects them every time, by code
An Explore search ignored a project ruleGeneral-purpose or custom subagentExplore and Plan do not load CLAUDE.md

Rules that decide exam answers

  • Delegate discovery, keep coordination. Subagents answer narrow questions; the main agent holds the overall picture.
  • Subagents start without the parent's history. Pass findings in the prompt. Options that assume the subagent "already knows" are wrong.
  • Files outlast context, hooks bring them back. A scratchpad or state file survives compaction, clearing and crashes; a SessionStart hook with the compact matcher puts it back in context without relying on Claude to look.
  • Compact with instructions mid-task, clear between tasks. Naming what to keep is what makes /compact safe.
  • A bigger context window does not stop degradation. Pasting more code in makes it worse.

Where it appears in the exam

Context Management & Reliability is a primary domain in four of the six exam scenarios: Customer Support Resolution Agent, Code Generation with Claude Code, Multi-Agent Research System and Structured Data Extraction. Codebase exploration questions fit the Code Generation with Claude Code scenario. Manifests and phase summaries also fit the multi-agent research scenario. The guide's preparation exercises 1, 3 and 4 list Domain 5 among the domains they reinforce.

Two sample questions

These are original Timo practice questions. They are not official exam questions.

Question 1

After two hours exploring a legacy billing system in one Claude Code session, a developer notices that Claude now describes "a typical service layer" instead of the InvoiceLedger and RefundCoordinator classes it found earlier. Its answers also contradict earlier ones. What is the best way to continue?

Answer: A. The findings move to a file, the summary keeps what matters, and new discovery output stays in subagents. B adds more to an already degraded context, C fills it faster, and D blocks edits but does nothing about what is already in context.

Question 2

An Agent SDK coordinator runs phase 1 to find which payment modules are deprecated, then spawns phase 2 subagents to "find every caller of PaymentGateway". The phase 2 subagents keep listing callers inside deprecated modules. What should the architect change?

Answer: C. A subagent receives only its own prompt for that call, so the phase 1 summary must be in it. A gives a subagent its own notes from earlier runs, not the coordinator's findings, B floods the coordinator's context with search output, and D is not how subagents receive context.

Build exercise

  1. Open a repository with tens of thousands of lines in Claude Code. Ask it to explain three different flows in one session and check /context after each.
  2. Add the flow-tracer subagent above and repeat with "use the flow-tracer subagent". Compare the main context usage.
  3. Ask Claude to keep FINDINGS.md as it goes, add a "Compact instructions" section to CLAUDE.md, run /compact, then ask a question that needs an early finding.
  4. In an Agent SDK script, add save_state and resume_prompt, stop the process halfway through, restart it and check that each agent resumes from its last step.

Practise this topic

Sources