Exam CCAR-F Topic 4 Question 57 Discussion

Actual exam question for Anthropic's CCAR-F exam
Question #: 57
Topic #: 4
You are building developer-productivity tools using the Claude Agent SDK. The agent helps engineers explore unfamiliar codebases, understand legacy systems, generate boilerplate code, and automate repetitive tasks. It uses the built-in tools-Read, Write, Bash, Grep, and Glob-and integrates with Model Context Protocol (MCP) servers.
Your agent needs to insert a new helper function into the middle of a 150-line utility module, between two existing functions. The Edit tool fails because its old_string parameter cannot find unique text to match-the file has repetitive docstrings, variable names, and structural patterns.
What is the most reliable way to complete this insertion?

Suggested Answer: D Vote an answer

Option D is the closest match to Claude Code's documented editing procedure. The Claude Code tools reference explains that Edit performs exact string replacement and requires old_string to appear exactly once.
When the text occurs multiple times, the prescribed response is to include sufficient surrounding context to identify one occurrence uniquely. For this insertion, the match should span a distinctive boundary between the preceding function and the following function. It does not literally need 30 lines; it needs the smallest exact block that is demonstrably unique, but option D is the only answer expressing that method.
Option A would modify every occurrence of a repeated pattern and could insert the helper function multiple times. Option B places the function at the end rather than at the required architectural location. Option C can technically work, but Write replaces the complete file and increases the change surface. Anthropic explicitly states that Write creates or overwrites full files, while partial modifications should use Edit. A targeted, uniquely anchored Edit preserves all unrelated content and produces a smaller, safer diff.

by zakmarli at Aug 14, 2026, 05:03 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
zakmarli
2026-08-14 05:03:11
Selected Answer: C
The Edit tool is designed for exact string replacement and requires the old_string to uniquely identify the target location. If the file contains repetitive docstrings, repeated variable names, and similar function structures, the edit can fail because the location is ambiguous. Sources describing Claude Code’s Edit behavior also note that old_string must be unique to avoid ambiguous edits.

✅ Correct Answer: C. Use Read to load the file, add the function at the appropriate location, and then use Write to overwrite the file with the updated content.
upvoted 1 times
...
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10