New to Claude Skills? Learn how to install them →

Kalirezarezvani on GitHub

Karpathy Coder

Free

Enforce coding discipline with Karpathy's principles.

Get this skill

Free · Opens the source repo

What Karpathy Coder does

Karpathy Coder is a skill designed to enhance code quality by enforcing Andrej Karpathy's four coding principles: surfacing assumptions, prioritizing simplicity, making surgical changes, and ensuring goal-driven execution. This skill is particularly useful for developers looking to improve their coding practices, especially when working with language models that may introduce unnecessary complexity or assumptions in code generation. By integrating this skill into your workflow, you can maintain a disciplined approach to coding that emphasizes clarity and effectiveness.

The skill includes several Python tools that help detect common pitfalls in code. The complexity checker identifies over-engineering issues, while the diff surgeon filters out irrelevant changes in code diffs. The assumption linter ensures that developers explicitly state their assumptions before coding, and the goal verifier helps define clear success criteria for tasks. These tools work in tandem to create a robust environment for writing, reviewing, and committing code, reducing the likelihood of introducing errors due to miscommunication or overcomplication.

Karpathy Coder is ideal for both individual developers and teams who want to adopt a more structured approach to coding. It can be particularly beneficial during code reviews or when preparing code for production, as it encourages developers to think critically about their changes and the implications of their code. The skill can also be integrated with various coding environments, making it versatile for different workflows.

By using Karpathy Coder, developers can foster a culture of quality and simplicity in their codebases, ultimately leading to more maintainable and understandable code. This skill is not just about following guidelines; it provides actionable tools that help enforce best practices in real-time, making it a valuable addition to any developer's toolkit.

When to use it

Use this skill when writing, reviewing, or committing code to ensure adherence to Karpathy's coding principles.

When not to use it

Avoid using this skill for trivial changes, such as simple typo fixes, where its principles may be unnecessarily stringent.

What you can build with it

Code Review Process

Integrate Karpathy Coder during code reviews to ensure all changes adhere to best practices, reducing complexity.

Pre-commit Checks

Use the pre-commit hook to automatically check for complexity and diff noise before finalizing code changes.

Team Coding Standards

Adopt Karpathy Coder as part of your team's coding standards to maintain a high level of code quality across projects.

How to install Karpathy Coder

View source

1. Install with the skills CLI

npx skills add alirezarezvani/claude-skills/karpathy-coder --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by alirezarezvani

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

Frequently asked questions about Karpathy Coder

Similar skills