Halmurat T.
Halmurat T.

Senior SDET

Home Blog Books ask About

The Dispatch

Weekly QA notes from the trenches.

Welcome aboard!

You're on the list. Expect real-world QA insights — no fluff, no spam.

© 2026 Halmurat T.

Automation 28
  • Selenium
  • Playwright
  • Appium
  • Cypress
AI Testing 67
CI/CD 12
  • GitHub Actions
  • Slack Reporting
QA Strategy 10
Case Studies 8
Blog/AI Testing
AI TestingHalmurat T./July 21, 2026/14 min

Context Engineering vs Prompt Engineering: Karpathy's Method

Filed underai-testing/llm/ai-agents/copilot/test-generation
Context Engineering vs Prompt Engineering: Karpathy's Method

Table of Contents
  • Context engineering vs prompt engineering: what did Karpathy say?
  • Why do LLMs need context engineering?
  • Karpathy’s method, distilled
  • Own the window
  • Show, don’t describe
  • Buy computation, don’t beg for it
  • What does context engineering mean for test automation?
  • Keep the AI on a leash — where Karpathy landed in 2026
  • Your next step: write the context file

On this page

  • Context engineering vs prompt engineering: what did Karpathy say?
  • Why do LLMs need context engineering?
  • Karpathy’s method, distilled
  • Own the window
  • Show, don’t describe
  • Buy computation, don’t beg for it
  • What does context engineering mean for test automation?
  • Keep the AI on a leash — where Karpathy landed in 2026
  • Your next step: write the context file

Somewhere right now an SDET is rewriting the same prompt for the fifth time, convinced the right wording will finally make Copilot stop inlining CSS selectors. Andrej Karpathy settled the context engineering vs prompt engineering debate back in June 2025, and his verdict says that engineer is tuning the wrong layer entirely: the prompt was never the problem. What the model knows when it answers is.

Karpathy has better credentials for this call than almost anyone — OpenAI founding member, former Director of AI at Tesla, and the educator behind more than six hours of YouTube instruction on how LLMs actually work. He’s also the person who coined “vibe coding,” then spent 2025 publicly walking back its scope. By February 2026 he was calling agent-driven development “agentic engineering” — “an art & science and expertise… something you can learn and become better at.” If you’re an SDET reviewing AI-generated tests every day, that expertise is now part of your job description. This post distills his method from the primary sources — the tweets, the talks, the 3.5-hour deep dives — and maps it onto test automation, where I think it lands harder than anywhere else.

Context engineering vs prompt engineering: what did Karpathy say?

On June 25, 2025, Karpathy posted “+1 for ‘context engineering’ over ‘prompt engineering’” on X, defining it as “the delicate art and science of filling the context window with just the right information for the next step.” The post drew over 14,000 likes and effectively renamed the discipline — a year on, “context engineering” is the term you’ll meet in framework docs and job postings.

His reasoning: people associate prompts with the short task descriptions you type into a chat box. But in any industrial-strength LLM application, the prompt is a small slice of what actually enters the model. The rest is engineered context — task descriptions and explanations, few-shot examples, retrieved documents, multimodal data, tool definitions, state and history, compaction of all of the above.

[ NOTE ]

Karpathy frames context engineering as a two-sided optimization, not a “more is better” rule: “Too little or of the wrong form and the LLM doesn’t have the right context for optimal performance. Too much or too irrelevant, and the LLM costs might go up and performance might come down. Doing this well is highly non-trivial.”

That second failure mode is the one teams miss. Researchers now call it context rot — model recall degrades as the window fills with irrelevant tokens. A bigger context window is not a license to paste everything; it’s a bigger surface to engineer.

Why do LLMs need context engineering?

Because an LLM’s weights are, in Karpathy’s words, “a zip file of the internet” — a lossy, roughly 100x compression of its training data. Parameters give the model a vague recollection of everything and a reliable memory of almost nothing. The context window is the only memory you control, and his entire method follows from treating it as the scarce resource it is.

Across his Software 3.0 keynote and the Deep Dive into LLMs like ChatGPT video, he cataloged the “psychology” of these models — and every trait maps directly to a working rule:

Trait (Karpathy’s term)What it meansWhat you do about it
Lossy memoryVague recall of specifics from trainingPaste the source; never ask from memory
Anterograde amnesiaNothing persists between chats — weights are fixedCommit context to files your tool reads every run
Jagged intelligenceSolves hard problems, fails trivial ones (9.11 > 9.9)Verify every output, regardless of difficulty
Needs tokens to thinkFinite computation per token generatedAsk for steps; never force one-token answers
GullibilitySusceptible to prompt injectionTreat untrusted text entering the window as an attack surface

The amnesia point deserves emphasis because it’s the one with the biggest workflow implication. A human colleague consolidates knowledge — they learn your framework once. An LLM’s working memory, as Karpathy puts it, “gets wiped every single morning,” like the protagonist of Memento. You don’t fix that by explaining your conventions again in chat number forty-seven. You fix it by writing the explanation down once, in a file the tool loads on every invocation. (The gullibility row is its own topic — I covered the CI implications in prompt injection through Playwright MCP.)

Karpathy’s method, distilled

Across “How I use LLMs” (2h11m, February 2025), “Deep Dive into LLMs like ChatGPT” (3h31m), and the Software 3.0 keynote, the same handful of rules keep resurfacing.

Own the window

Karpathy starts a new chat for every topic switch. Stale tokens from the previous task distract the model, degrade accuracy, and make every subsequent token slower and more expensive to process. He pastes source material directly into the window instead of trusting recall — a book chapter, an API doc, a stack trace — and uploads documents rather than summarizing them. For images with data that matters (his example: a blood test), he runs a two-step flow: transcribe to text first, verify the transcription, then analyze. Generation you can check beats analysis you can’t.

Show, don’t describe

For any repeatable task, Karpathy gives the model concrete input/output examples rather than describing the task — few-shot prompting, delimited with XML-style tags so the model knows exactly where the example ends and the work begins. For a test-generation agent, that looks like this:

.github/copilot-instructions.md
# Test conventions
- Locators: getByTestId or role-based only — never CSS selectors
- Every test imports fixtures from `src/fixtures`; never inline auth
- Assert on business values (totals, names), not just visibility
<example>
test('checkout shows the discounted total', async ({ checkoutPage }) => {
await checkoutPage.applyCoupon('SAVE20');
await expect(checkoutPage.orderTotal).toHaveText('$103.20');
await expect(checkoutPage.discountBadge).toHaveText('-20%');
});
</example>

One committed example does more work than a paragraph of adjectives, because the model is a pattern-completion machine: it will clone the shape of what it sees. That’s also why a vague prompt fails in a specific way — Karpathy’s keynote framing is that vague prompts fail verification, which sends you back to re-prompt, and “you’re going to start spinning.” Spending an extra minute making the request concrete is cheaper than three round trips.

Buy computation, don’t beg for it

“Models need tokens to think” is the most mechanically grounded rule in the set: a transformer performs a finite amount of computation per token, so an answer demanded in one token gets one token’s worth of thought. Ask for the setup, the intermediate steps, the calculation — you’re literally buying compute with output tokens. For anything involving arithmetic, counting, or exact string manipulation, Karpathy adds “use code” to the prompt, forcing a Python interpreter call instead of trusting what he calls the model’s mental arithmetic. And he reserves thinking models for genuinely hard problems — difficult bugs, math, deep logic — while defaulting to fast models for 80–90% of his queries. For anything high-stakes, he runs an “LLM council”: the same prompt across several providers, answers compared. That treat-tokens-as-money instinct scales straight to CI, which is why I put a token budget on Playwright AI agents before letting them loop.

What does context engineering mean for test automation?

Every AI testing tool you touch is a context pipeline, and almost every “the AI wrote a bad test” complaint is a context failure upstream of the prompt. That’s not a metaphor — it’s literally how the tools are built.

GitHub Copilot reads committed instruction files on every interaction; I walked through the three files that fixed our enterprise setup in Your Copilot Isn’t Dumb — You’re Starving It of Context. Playwright’s generator agent assembles its context from an agent definition, a seed spec, and the plan — engineer those three files and quality stops being a coin flip, as I showed in Your Playwright Generator Is Only as Good as Its Seed. I learned the cost of skipping this the slow way: on one enterprise suite, a single convention the generator never saw multiplied across 300 generated specs into a quarter of cleanup. The fix wasn’t a better prompt — it was a seed file. Karpathy’s method is the theory those posts are the practice of.

There’s a sharper enterprise point hiding in his October 2025 interview with Dwarkesh Patel. Karpathy hand-wrote his ~8,000-line nanochat project and found coding agents “net unhelpful” on it — his diagnosis: “possibly the repo is too far off the data distribution.” He also complained that models kept pushing him back toward standard PyTorch patterns he’d deliberately avoided. Sound familiar? Your in-house test framework — the custom fixtures, the wrapper around Playwright, the naming conventions a decade of enterprise scar tissue produced — is off-distribution in exactly the same way.

[ WARNING ]

The model’s weights have seen a million vanilla Playwright specs and zero of yours. It drifts toward generic patterns not because it’s dumb, but because generic is what it knows. Your conventions have to ride in through the window — they are not in the weights.

And the verification half of his method should feel like home. Karpathy’s core loop is “AI does the generation, the human does the verification” — and verification is the skill SDETs have been sharpening for decades. A recent Ask HN thread on agentic coding is full of engineers discovering what we already knew: agents happily produce tests that pass while asserting nothing — one commenter’s example was the expect(true).to.be(true) genre of test. Catching that is a solved problem in QA — mutation testing exposes fake AI tests mechanically, and keeping the model in a triage role rather than a deciding role — the autonomy-slider position I argued for in Let AI Triage Your Playwright Failures, Not Decide Them — is exactly Karpathy’s “partial autonomy” applied to CI.

Keep the AI on a leash — where Karpathy landed in 2026

14,000+

Likes on the context engineering post

June 25, 2025 — the tweet that renamed a discipline

~8,000 lines

nanochat, written by hand

agents were 'net unhelpful' on off-distribution code

10,000 lines

Diff size Karpathy refuses to review

'I always go in small incremental chunks'

80–90%

His queries served by fast models

thinking models reserved for genuinely hard problems

Karpathy’s 2025 keynote advice was to keep the AI “on the leash”: small incremental chunks, single concrete tasks, a generation-verification loop spinning as fast as possible, and no 10,000-line diffs — because the human reviewer is the bottleneck, and an unreviewable diff is a liability with a green checkmark. Watch his trajectory since, though, because the leash length changed while the loop didn’t. February 2025: vibe coding, scoped in his own retrospective to “fun throwaway projects.” October 2025: calling industry agent hype “slop” and preferring autocomplete for expert work — while still copy-pasting his entire repo into GPT-5 Pro as an oracle for hard questions, which is context maximalism in its purest form. February 2026: agentic engineering as the professional default, orchestrating agents “99% of the time” with oversight.

[ TIP ]

The constant across all three phases isn’t a position on agents — it’s the loop. Generation is cheap and getting cheaper; verification is the scarce resource. Optimize the window going in and the verification coming out, and the model in the middle can be swapped, upgraded, or distrusted as needed.

That’s why I’d argue his method matters more for SDETs than for anyone else: we’re the discipline that industrialized verification, and that’s exactly where the SDET role is heading in the age of AI. The teams winning with AI test generation aren’t the ones with the cleverest prompts — they’re the ones with committed context files and merciless review gates.

Your next step: write the context file

Pick the repo where AI writes tests for you and give it a memory this week. One file is enough to start: CLAUDE.md, .github/copilot-instructions.md, or Playwright’s agent definition plus seed spec — whatever your tool reads on every run. Put three things in it: your locator standard, your fixture imports, and one complete example test inside <example> tags. Then delete the paragraph of instructions you’ve been re-pasting into chat, and let the file do the remembering — the model can’t consolidate knowledge, but your repo can.

If you want the full implementation walkthroughs, start with the Copilot instruction files and then the Playwright generator seed.

§ Frequently Asked FAQ
+ Is context engineering just a rebrand of prompt engineering?

No. Prompt engineering optimizes how you phrase a request; context engineering governs everything the model sees — instructions, examples, retrieved documents, tool definitions, and history. Karpathy’s point is that in production LLM systems, the prompt is a small slice of the window, and the rest of the window decides output quality.

+ How much context is too much for an LLM?

Karpathy calls it a two-sided optimization: too little context degrades output, but too much irrelevant context raises cost and can also degrade output — a failure mode researchers call context rot. Curate for relevance to the next step instead of maximizing volume.

+ When should I start a new chat with an AI assistant?

Whenever you switch topics. Karpathy treats leftover tokens from the previous task as a distraction that lowers accuracy and slows processing. A fresh window with pasted, relevant context beats a long chat history almost every time.

+ Does context engineering apply to GitHub Copilot and Playwright AI agents?

Directly. Copilot reads committed instruction files on every interaction, and Playwright’s test agents assemble context from an agent definition, seed spec, and plan. Engineering those files is context engineering — it fixes convention drift that no per-chat prompt can.

+ What's the difference between vibe coding and agentic engineering?

Both are Karpathy’s terms. Vibe coding (February 2025) is casual natural-language coding without reviewing the output, which he scoped to throwaway projects. Agentic engineering (February 2026) is the professional version: orchestrating coding agents with oversight, verification, and no compromise on quality.

§ Further Reading 03 of 03
01AI Testing

Agentic AI Said the Test Passed. It Didn't.

An agent called our checkout green while the tax was wrong by $4.10. On agentic AI test pass/fail reliability, the verdict is the one job an agent can't have.

Read →
02AI Testing

AI-Generated Code Ships 1.7x More Bugs Your Tests Miss

AI-generated code ships 1.7x more bugs while AI-written tests stay green. How to test AI-generated code in 2026 with assertions that catch real logic errors.

Read →
03AI Testing

Your Agent's Confirm Dialog Is Safety Theater

Your Playwright test checks the confirm dialog renders — not that the irreversible action was blocked. Test the human-in-the-loop approval gate properly.

Read →

Don't miss a thing

Subscribe to get updates straight to your inbox.

HT

No spam · Unsubscribe anytime

Welcome aboard!

You're on the list. Expect real-world QA insights — no fluff, no spam.

§ Colophon

Halmurat T. — Senior SDET writing about test automation, CI/CD, and QA strategy from 10+ years in the enterprise trenches.

Set in
IBM Plex Sans, Lora, and IBM Plex Mono.
Built with
Astro, MDX, Tailwind CSS & Expressive Code. Served by Vercel.
Privacy
No cookies. No tracking scripts on the main thread — analytics run sandboxed via Partytown.
Source
github.com/Halmurat-Uyghur
Terminal
Try /ask to query Halmurat's notes in a shell prompt.

© 2026 Halmurat T. · Written in plain text, shipped in plain time.

Search
Esc

Search is not available in dev mode.

Run npm run build then npm run preview:local to test search locally.