How “Karpathy Skills” massively improve Claude Code’s accuracy
Karpathy Skills is a powerful set of strict rules and guidelines that drastically improve the accuracy and reliability of your coding agents.
It gives your agent a set of guidelines based on Andrej Karpathy’s observations about LLM coding behavior — tackling common problems like overengineering, unnecessary code changes, hidden assumptions and unverified implementations.
You get much higher-quality code and stop wasting so much time and tokens on re-prompting your agents for better results.
Declarative vs. imperative goals: Code that actually works
Instead of telling the AI exactly how to do something, tell it what success looks like and let it verify its own work.
Imperative instruction:
Add a login check to the API.
Declarative instruction:
Write a test that fails when an unauthorized user tries to use the API. Then modify the code until that test passes.
The first instruction tells the AI what to do. The second gives it a measurable goal to work toward.
This creates a verification loop:
Define success → Implement → Test → Evaluate → Refine.
Instead of writing code and assuming it works, the AI keeps testing and refining its implementation against clear acceptance criteria.
It essentially takes on part of the role of a QA engineer. We still need to review its work, but the AI now has a better way to know when a task is actually complete.
The surgical strike rule: Smaller diffs and easier code reviews
AI coding agents have a habit of cleaning up code as they work. They fix unrelated typos or change formatting in nearby files without you asking them to.
Karpathy’s guidelines push against this behavior.
The rule: Every changed line should trace directly to your request.
The AI should follow your existing coding conventions and only touch the code it needs to complete the task. If it finds an unrelated problem, it should tell you about it rather than fix it on its own.
This helps prevent what we call diff bloat. When reviewing an AI-generated PR, you shouldn’t have to dig through hundreds of lines of unnecessary changes to find the actual logic changes.
The fewer unnecessary changes the AI makes, the easier it is for us to review the code and avoid regressions.
Mandatory confusion injection: Less guesswork and rework
When an AI is 80% sure about what you want, it often guesses the remaining 20% and starts coding.
Karpathy’s approach flips this behavior.
The rule: Don’t assume. Don’t hide confusion. Surface tradeoffs.
If the AI doesn’t fully understand your requirements, it should make its uncertainty known and ask questions. It should also push back when it sees a simpler way to solve the problem.
The idea behind confusion injection isn’t to make the AI confused. It’s to stop it from hiding its confusion.
We want an engineering partner that challenges our assumptions rather than a yes-man that agrees with everything we say and makes up requirements along the way.
A quick clarification can save us hours of unnecessary work.
Anti-future-proofing: Simpler code and less technical debt
AI coding agents love to overengineer things. They add unnecessary abstractions and build flexibility into software for requirements that don’t even exist yet.
The rule: If 200 lines could be 50, rewrite it.
Karpathy’s guidelines discourage abstractions for single-use code and speculative features. They also discourage unnecessary configurability and error handling for impossible scenarios.
This is essentially YAGNI (You Aren’t Gonna Need It) applied to AI coding agents.
As AI makes writing code cheaper, we need to pay more attention to the cost of maintaining it.
This principle helps us fight AI slop and keeps our codebases readable without filling them with unnecessary just-in-case logic.
Just because AI can write more code doesn’t mean it should.
Self-improving memory: Fewer repeated mistakes across sessions
Another useful practice that builds on Karpathy’s four core principles is creating a Learnings File (learnings.md).
Whenever the AI makes a meaningful mistake or you correct it, instruct it to record that lesson in the file. The entry should explain what went wrong and what the AI should do differently next time.
When you start a new session, instruct the AI to read this file before it starts working.
This creates a continuous learning loop:
Make a mistake → Receive correction → Record the lesson → Apply it in future sessions.
We’re not retraining the model. We’re giving it persistent context that survives beyond a single chat window.
Over time, this file becomes an engineering journal that helps the AI learn your project’s conventions and avoid repeating past mistakes.
Karpathy Skills helps us keep the speed of AI-assisted development without sacrificing engineering discipline. The goal isn’t to get AI to write more code but to get it to make better engineering decisions.
How “Karpathy Skills” massively improve Claude Code’s accuracy Read More »



























