Skip to main content
skill Claude Code

karpathy-coder — Claude Code skill: what it does, how to install

Enforces Andrej Karpathy's 4 coding principles to prevent LLM over-engineering. Catches assumptions, keeps diffs surgical, and strips out unrequested abstractions.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add alirezarezvani/claude-skills
/plugin install karpathy-coder@claude-code-skills
Open on GitHub

What karpathy-coder does

This skill guides model behavior during writing, reviewing, and committing code. It stops the LLM from making silent assumptions, bloating architecture with single-use abstractions, or altering untouched lines. It cuts down bloated code. For multi-step tasks, it demands explicit success criteria and tests before proceeding.

Under the hood, the skill ships four Python scripts relying only on standard library modules. The complexity_checker.py script catches over-engineered classes, while diff_surgeon.py flags drive-by edits. It also bundles the karpathy-reviewer sub-agent, /karpathy-check slash command, and a hooks/karpathy-gate.sh hook.

You need standard Python to run the scripts. Install it for non-trivial diffs over 20 lines or multi-step tasks. Skip it for typo fixes.

What it helps with

  • clean noise and unrelated refactoring from git diffs
  • detect hidden assumptions before generating multi-step plans
  • flag premature abstractions and high cyclomatic complexity
  • verify staged code quality before committing

Example prompts for the agent

  • /karpathy-check
  • review my diff
  • am I overcomplicating this

How to install karpathy-coder

1Plugin marketplace

/plugin marketplace add alirezarezvani/claude-skills
/plugin install karpathy-coder@claude-code-skills

This installs the whole karpathy-coder plugin with all its skills

2Skills CLI (Vercel)

npx skills add alirezarezvani/claude-skills --skill karpathy-coder -a claude-code

3Manually: put the files in place

~/.claude/skills/karpathy-coder/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/karpathy-coder/

From the same set349

The whole set →
engineering-skills Alireza Rezvani An engineering skill index for Claude Code that helps you select one specialist SKILL.md for the task at hand. It covers architecture, testing, DevOps, and data work. Claude Code 2,387installs finance-skills Alireza Rezvani Routes ambiguous finance prompts to the right bundled skill: financial-analyst, saas-metrics-coach, or month-end-close. Claude Code 2,312installs marketing-skills Alireza Rezvani A directory and router for marketing skills in Claude Code. It picks the right specialist skill for SEO, content, CRO, channels, and related tasks. Claude Code 2,264installs business-growth-skills Alireza Rezvani Routes growth and revenue prompts to the right specialized skill across customer success, sales engineering, RevOps, and proposals in Claude Code. Claude Code 2,189installs engineering-advanced-skills Alireza Rezvani An index of 37 engineering skills for architecture, automation, reliability, and platform work. Use it when a project needs task-specific engineering workflows. Claude Code 2,019installs product-skills Alireza Rezvani Product work orchestrator for Claude Code. Routes queries across 16 domain lanes and validates discovery trees with deterministic scripts. Claude Code 1,994installs pm-skills Alireza Rezvani Routes project-delivery requests across 8 PM sub-skills for Jira, Confluence, sprints, reporting, and team communication. Useful for controlled delivery work. Claude Code 1,975installs senior-backend Alireza Rezvani Scaffolds backend APIs, detects database bottlenecks, and runs load tests. Useful when designing Express routes, optimizing PostgreSQL, or preparing for production. Claude Code 1,674installs

Similar

ios-memgraph-leaks official OpenAI Captures and inspects iOS leaks from a simulator process or .memgraph. Useful for tracing retained objects and checking a fix with before-and-after evidence. CX Codex GP ChatGPT 1,054installs codebase-memory-mcp official github Explore unfamiliar code with Codebase Memory: find symbols, relationships and data flows, then check graph-based findings against source files. GitHub Copilot 259installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs triage Matt Pocock This skill moves issues and external PRs through triage states, verification, and agent briefs. It fits maintainers managing an issue queue. Claude Code 990,453installs codebase-design Matt Pocock This skill helps design modules with small interfaces and hidden complexity. Use it when refactoring code, choosing a seam, or making tests easier to write. Claude Code 850,344installs code-review Matt Pocock Reviews changes from a chosen reference point against repository standards and the originating spec. Use it for a branch, PR, or work in progress. Claude Code 789,521installs implement Matt Pocock Implements work from a specification or tickets, following a test-driven flow and ending with review and a commit. Use it when a coding task needs a defined delivery routine. Claude Code 774,700installs

Questions about karpathy-coder

How do I install karpathy-coder in Claude Code?

Run /plugin marketplace add alirezarezvani/claude-skills and then /plugin install karpathy-coder@claude-code-skills inside Claude Code.

What does the /karpathy-check slash command do?

It triggers the karpathy-reviewer sub-agent to inspect staged changes against Karpathy's four principles: assumptions, simplicity, surgical diffs, and goal verification.

Do the bundled Python verification tools require extra dependencies?

No, all scripts in scripts/ use Python standard library modules only, with no pip packages required.

Source text

SKILL.md · MIT
---
name: karpathy-coder
description: Use when writing, reviewing, or committing code to enforce Karpathy's 4 coding principles — surface assumptions before coding, keep it simple, make surgical changes, define verifiable goals. Triggers on "review my diff", "check complexity", "am I overcomplicating this", "karpathy check", "before I commit", or any code quality concern where the LLM might be overcoding.
context: fork
license: MIT
metadata:
  version: 2.9.0
  author: claude-code-skills
  tags: [code-quality, discipline, karpathy, simplicity, surgical-changes, anti-patterns, review]
  compatible_tools: [claude-code, codex-cli, cursor, antigravity, opencode, gemini-cli]
---

# Karpathy Coder — Active Coding Discipline

Derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) 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`.

| Script | What it detects |
|---|---|
| `complexity_checker.py` | Over-engineering: too many classes, deep nesting, high cyclomatic complexity, unused params, premature abstractions |
| `diff_surgeon.py` | Diff noise: lines that don't trace to the stated goal — comment changes, style drift, drive-by refactors |
| `assumption_linter.py` | Hidden assumptions in a plan: unasked features, missing clarifications, silent interpretation choices |
| `goal_verifier.py` | Weak 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:

| Tool | Schema file |
|---|---|
| Claude Code | `CLAUDE.md` (auto-loaded by plugin) |
| Codex CLI | `AGENTS.md` |
| Cursor | `AGENTS.md` or `.cursorrules` |
| Antigravity / OpenCode / Gemini CLI | `AGENTS.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

© claude-code-skills · MIT · alirezarezvani/claude-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor