[KongchangAI]
· 2 min read· 1,362 words

Claude Agent SDK vs Claude Code: Same Engine Showdown — Which Is Faster?

Claude Agent SDK vs Claude Code: Same Engine Showdown — Which Is Faster?

A 55-line SDK agent races Claude Code and fixes the bug faster with one-tenth the tokens.

A developer built a coding agent in 55 lines of JavaScript on the Claude Agent SDK and compared it with Claude Code on the same repo, model, and prompts. The key finding: the SDK drives the very same agent loop as Claude Code, while Claude Code adds system instructions, 24 tools, skills, subagents, CLAUDE.md, and git history — all sent with every request, burning about 14,000 tokens up front. In three test rounds Claude Code won on context understanding thanks to commit history, but in the main race the custom agent won at 53 seconds vs 1:22, ~35K vs ~327K input tokens, and 16 vs 41 cents, with both passing all hidden checks. The author advises using Claude Code for interactive development and the SDK for narrow, automated CI and bot scenarios.

A 55-line agent — how does it beat Claude Code?

A developer wrote his own coding agent in 55 lines of JavaScript and pitted it head-to-head against Claude Code in the same repo, with the same model and the same set of prompts. The result was surprising: this "go-kart" finished nearly 30 seconds faster than the "full car," using only one-tenth the tokens.

According to the demo in the developer's video, his agent received the task of fixing a VAT display error, and within 13 seconds it found the bug, completed the fix, added a test case, and got everything passing. There's no black magic behind it — the library he called downloads Claude Code itself: same program, same version (2.1.309).

The loop is the engine.

Anthropic's official documentation puts it plainly: the Agent SDK gives you the same tools, agent loop, and context management that power Claude Code. In other words, the loop is the engine, and Claude Code is the full car. What you pay for — or can skip — is everything beyond the engine.

The Difference Between Engine and Full Car

The core agent loop is extremely simple: ask the model → execute the tool it chose → send the result back → repeat until done. The author had previously hand-written this loop in 110 lines; with the SDK it shrank to 55.

Claude Code adds a whole set of equipment around the loop: its own system instructions, 24 tools, 18 skills, 5 subagents, your CLAUDE.md, git history — and all of this content is sent along with every single request. The author's go-kart carried only what was written in its own files: a three-line system prompt (read the code first, keep changes small, run tests), three tools (read file, edit file, run commands), and settingSources left empty (no CLAUDE.md or settings files loaded).

Under the default configuration, the SDK also carries many of the "car" parts — the high-spec mode alone burns about 14,000 tokens just at the start. The main job of those 55 lines is really subtraction.

Agent SDK (formerly the Claude Code SDK) is a development kit from Anthropic that wraps the same agent loop, built-in tools, and context management as Claude Code, letting developers build automated agents programmatically. Its core interface is a query() function — pass in a prompt and configuration and the loop starts. Key configuration options include: settingSources, which controls whether CLAUDE.md, settings files, skills, and other "memory" are loaded; allowedTools, which limits the available tool set; and systemPrompt, which overrides the default system instructions. The default high-spec mode carries a large amount of context, so a lean configuration (such as clearing settingSources and keeping only a few tools) is the main lever for reducing token consumption.

Token and cache pricing: LLMs bill by token, with different rates for input and output. The Anthropic API supports prompt caching, where repeated prefix content hits the cache and is billed at a steep discount — which is why Claude Code's repository-context understanding in this article "mostly comes from cache." Caching lowers the unit price, but every request still transmits and processes the full context, affecting latency and total cost.

Three Rounds of Testing: Can the Go-Kart Keep Up?

Test 1: Understanding repository context

Given the same word, Claude Code summarized recent commits and suggested next steps. The author's agent only knew the folder name. The cost: Claude Code burned about 34,500 tokens before opening any file, while the agent used only 3,300. Most came from cache, roughly 6.5 cents at API prices. In this round, the full car's context advantage was clear.

Test 2: Fixing the VAT bug

VAT was printed as £7.08 instead of £7.08, and the root cause was a cleanup commit that zeroed out the value. Because Claude Code had seen the commit history, its first step was to open the commit that introduced the problem. The agent, by reading code and tests, also found the same line — one-line fix, the same new test case, 4 requests each, about 13 seconds each, and both passed all the hidden checks.

The bug from the start.

The only difference: Claude Code printed a real receipt to verify, while the agent only ran tests and also falsely reported that £3.20 had a problem — it didn't.

Test 3: Following the house rules

This repo's CLAUDE.md contains five rules: receipts in uppercase only, every change gets a test, write a changelog, update the flags in the readme, and no commits. Claude Code read it automatically, finished in 23 seconds, and followed all five. The agent's configuration deliberately excluded CLAUDE.md — the rules weren't handed to it, but it looked around the folder on its own, found the file, and read it first, following all five within 20 seconds, at the cost of one extra request to find the file. The author then changed one line to settingSources: project, and the SDK loaded it automatically just like Claude Code — three requests, five out of five.

Every part on the full car is just one option away.

CLAUDE.md is Claude Code's conventional project-level instruction file, usually placed at the repository root, used for build commands, code conventions, commit restrictions, and other project conventions, and automatically injected into context at the start of each session. Alongside it are settings files such as .claude/settings.json, which configure permissions, hooks, and environment variables. The SDK uses settingSources to decide whether to read these sources: set to an empty array, no project configuration is loaded; set to ['project'], it behaves like Claude Code and automatically reads CLAUDE.md and project settings. This mechanism lets "house rules" be automatically followed by the full car or loaded on demand by the go-kart.

The Main Race: 53 Seconds vs. 1:22

Same task, same commit: add an offers flag, apply this week's deals, show the savings per item and deduct them from the total, with tests.

MetricCustom agentClaude Code
Time53 seconds1 min 22 sec
Requests58
Input tokens~35,000~327,000
Output tokens~5,500~8,500
API cost16 cents41 cents

Claude Code carried the full car on every request, with nearly ten times the tokens, and wrote about twice as much code — accounting for most of the time difference. Both passed all hidden checks, and the receipts matched to the penny (£37.45). Only one line differed: Claude Code wrote "You saved -£5" so the column added up; the agent wrote "You saved £5." The author's own words: pick your accountant.

One line differs. Claude Code says you saved minus five pounds.

It should be noted that this is a single-round comparison and should be treated as one race rather than a benchmark. But the author checked the billing of each run in the console, and the 43 cents matched the SDK estimate exactly.

Which to Use: The Scenario Decides

The author gave a clear decision framework at the end of the video:

Use Claude Code at the keyboard. It runs on the subscription plan you already pay for, understands your git history and CLAUDE.md from the very first message, and you can watch every edit land. In Test 2, it was the commit history that took it straight to the bug.

Build your own agent when the task is narrow and automated. CI checks, bots, a feature inside an app — in these scenarios you pay by token, and in this race the go-kart carried only one-tenth the tokens, reached the finish line first, and cost less than half.

One thing to know.

The essence this comparison reveals: Claude Code's "magic" doesn't come from some irreplaceable giant application, but from a loop you can drive in 55 lines, plus carefully packaged context, tools, and memory around it. Once you understand this, you can freely assemble and disassemble as the task requires — drive the full car when you want the full car, and strip the seats to build a go-kart when you want speed.

#Claude Agent SDK#Claude Code#AI coding agent#agent loop#prompt caching#CLAUDE.md#token cost#Anthropic
Share:

Related articles