Karpathy Coder skill for Claude

Check a diff for overbuilt code: hidden assumptions, needless abstraction, non-surgical changes, unverified goals (Karpathy's four principles). Load whenever the user thinks they overcomplicated something or wants a pre-commit check.

Karpathy Coder SKILL.md

The full skill file from alirezarezvani/claude-skills (MIT).

Karpathy Coder — Active Coding Discipline

Derived from Andrej Karpathy's observations on LLM coding pitfalls. This is not just guidelines — it ships Python tools that detect violations, a review agent, a slash command, and a pre-commit hook.

"The models make wrong assumptions on your behalf and just run along with them without checking. They don't manage their confusion, don't seek clarifications, don't surface inconsistencies, don't present tradeoffs, don't push back when they should."

"They really like to overcomplicate code and APIs, bloat abstractions, don't clean up dead code... implement a bloated construction over 1000 lines when 100 would do."

"LLMs are exceptionally good at looping until they meet specific goals... Don't tell it what to do, give it success criteria and watch it go."

— Andrej Karpathy

The four principles

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

  • State assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them — don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

The test: Would a senior engineer say this is overcomplicated? If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it — don't delete it.
  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Instead of...Transform to...
"Add validation""Write tests for invalid inputs, then make them pass"
"Fix the bug""Write a test that reproduces it, then make it pass"
"Refactor X""Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Slash command

/karpathy-check — Run the full 4-principle review on your staged changes.

Python tools (scripts/)

All tools are stdlib-only. Run with --help.

ScriptWhat it detects
complexity_checker.pyOver-engineering: too many classes, deep nesting, high cyclomatic complexity, unused params, premature abstractions
diff_surgeon.pyDiff noise: lines that don't trace to the stated goal — comment changes, style drift, drive-by refactors
assumption_linter.pyHidden assumptions in a plan: unasked features, missing clarifications, silent interpretation choices
goal_verifier.pyWeak success criteria: vague plans without verifiable checks, missing test assertions

Sub-agent

karpathy-reviewer — Runs all 4 principles against a diff. Dispatched by /karpathy-check or manually before committing.

Pre-commit hook

hooks/karpathy-gate.sh — runs complexity_checker.py and diff_surgeon.py on staged files. Warns (non-blocking) when violations are found. Wire it via .claude/settings.json or Husky.

References

  • references/karpathy-principles.md — the source quotes, deeper context, when to relax each principle
  • references/anti-patterns.md — 10+ before/after examples across Python, TypeScript, and shell
  • references/enforcement-patterns.md — how to wire hooks, CI integration, team adoption

When to relax

These principles bias toward caution over speed. For trivial tasks (typo fixes, obvious one-liners), use judgment. The principles matter most on:

  • Non-trivial implementations (>20 lines changed)
  • Code you don't fully understand
  • Multi-step tasks with unclear requirements
  • Anything that will be reviewed by humans

Cross-tool compatibility

Installs via plugin for Claude Code. For other tools, copy the principles into your schema file:

ToolSchema file
Claude CodeCLAUDE.md (auto-loaded by plugin)
Codex CLIAGENTS.md
CursorAGENTS.md or .cursorrules
Antigravity / OpenCode / Gemini CLIAGENTS.md

Related skills (chains via context: fork)

  • self-eval — honest quality scoring after completing work
  • code-reviewer — broader code review; karpathy-coder focuses on the 4 LLM-specific pitfalls
  • llm-wiki — compound knowledge; karpathy-coder ensures you don't overcomplicate while building it

How to install Karpathy Coder

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit alirezarezvani/claude-skills/engineering/karpathy-coder/skills/karpathy-coder#main ~/.claude/skills/karpathy-coder

Codex

npx degit alirezarezvani/claude-skills/engineering/karpathy-coder/skills/karpathy-coder#main ~/.codex/skills/karpathy-coder

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Karpathy Coder skill do?

Check a diff for overbuilt code: hidden assumptions, needless abstraction, non-surgical changes, unverified goals (Karpathy's four principles). Load whenever the user thinks they overcomplicated something or wants a pre-commit check.

+How do I install Karpathy Coder in Claude Code?

Copy the skill folder into ~/.claude/skills/karpathy-coder, for example with "npx degit alirezarezvani/claude-skills/engineering/karpathy-coder/skills/karpathy-coder#main ~/.claude/skills/karpathy-coder". Claude Code loads it automatically and uses it when a task matches.

+Does Karpathy Coder work with ChatGPT or Codex?

Yes. Karpathy Coder uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/karpathy-coder. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Karpathy Coder free?

Karpathy Coder is published on GitHub by alirezarezvani under the MIT license, which allows free use.

Related software development skills

  1. Code Review

    Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's…

    mattpocock/skills★ 327k
  2. Using Agent Skills

    Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of…

    addyosmani/agent-skills★ 119k
  3. Build

    Fully automate a coding task with make-plan, do, and babysit.

    thedotmack/claude-mem★ 118k
  4. Loop Library

    Discover, find, compare, audit, repair, adapt, and design repeatable AI-agent loops with explicit triggers, actions, verification, stopping…

    alirezarezvani/claude-skills★ 30k
  5. Merge

    Use to land the winning AgentHub branch, archive the others and clean up worktrees.

    alirezarezvani/claude-skills★ 30k
  6. Mobile Release

    Use when shipping an iOS or Android app update to the App Store or Google Play - Apple or Google rejected or warned about a build…

    alirezarezvani/claude-skills★ 30k
  7. Monorepo Navigator

    Use for Turborepo, Nx, pnpm-workspace or Lerna setup, affected-only builds, remote caching or a multi-repo to monorepo move.

    alirezarezvani/claude-skills★ 30k
  8. Ms365 Tenant Manager

    Use for Microsoft 365 tenant administration (Entra ID users, Exchange Online, Teams, licenses, Conditional Access, compliance reports).

    alirezarezvani/claude-skills★ 30k
  9. Partnerships Architect

    Use when deciding whether to sign a partner, at which tier (referral, reseller, OEM, SI, alliance), with what joint GTM and revshare.

    alirezarezvani/claude-skills★ 30k

See all software development skills →

More skills from alirezarezvani

  1. Knowledge Ops

    Use when writing, checking or cleaning up SOPs and runbooks. Generates them with sop_generator.py, checks 5W2H completeness and links with…

    alirezarezvani/claude-skills★ 30k
  2. Kubernetes Operator

    Use when building a Kubernetes operator or CRD (controller-runtime, kubebuilder, operator-sdk, KOPF), before writing the controller.

    alirezarezvani/claude-skills★ 30k
  3. Landing Page Generator

    Use when asked for a landing, marketing or campaign page as a Next.js TSX component with Tailwind.

    alirezarezvani/claude-skills★ 30k

All skills by alirezarezvani →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.