New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Writing, reviewing, or committing code to enforce Karpathy's

Karpathy Coder — Active Coding Discipline

by alirezarezvani · MIT license · ★ 26,349 on GitHub · v2.9.0 · updated Aug 30

Karpathy Coder — Active Coding Discipline cover

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…

---
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
version: 2.9.0
author: claude-code-skills
license: MIT
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."

Overview

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.

Manual install (npx, ZIP)
Claude Codenpx skills add alirezarezvani/claude-skills --skill karpathy-coder -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/alirezarezvani/claude-skills/tar.gz/19392f7a0826 \ | tar -xz -C ~/.claude/skills --strip-components=4 claude-skills-19392f7a0826/engineering/karpathy-coder/skills/karpathy-coder
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/68b6d2ce62cef908de7d/karpathy-coder.zip" -OutFile "$env:TEMP\karpathy-coder.zip"; Expand-Archive "$env:TEMP\karpathy-coder.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md5.6 KB
  • expected_outputs/4 files · 2.5 KB
  • references/3 files · 12.2 KB
  • scripts/4 files · 31.6 KB
Read the files here
alirezarezvani/19392f712 files
Shared references2SKILL.md reads these from elsewhere in the repo. Not in the ZIP.Get them on GitHub ↗
SKILL.md
Show the full text132 lines

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.

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
  • 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
1---
2name: karpathy-coder
3description: 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.
4context: fork
5version: 2.9.0
6author: claude-code-skills
7license: MIT
8tags: [code-quality, discipline, karpathy, simplicity, surgical-changes, anti-patterns, review]
9compatible_tools: [claude-code, codex-cli, cursor, antigravity, opencode, gemini-cli]
10---
11 
12# Karpathy Coder — Active Coding Discipline
13 
14Derived 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.
15 
16> "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."
17>
18> "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."
19>
20> "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."
21>
22> — Andrej Karpathy
23 
24## The four principles
25 
26### 1. Think Before Coding
27 
28**Don't assume. Don't hide confusion. Surface tradeoffs.**
29 
30- State assumptions explicitly. If uncertain, ask.
31- If multiple interpretations exist, present them — don't pick silently.
32- If a simpler approach exists, say so. Push back when warranted.
33- If something is unclear, stop. Name what's confusing. Ask.
34 
35### 2. Simplicity First
36 
37**Minimum code that solves the problem. Nothing speculative.**
38 
39- No features beyond what was asked.
40- No abstractions for single-use code.
41- No "flexibility" or "configurability" that wasn't requested.
42- No error handling for impossible scenarios.
43- If you write 200 lines and it could be 50, rewrite it.
44 
45**The test:** Would a senior engineer say this is overcomplicated? If yes, simplify.
46 
47### 3. Surgical Changes
48 
49**Touch only what you must. Clean up only your own mess.**
50 
51- Don't "improve" adjacent code, comments, or formatting.
52- Don't refactor things that aren't broken.
53- Match existing style, even if you'd do it differently.
54- If you notice unrelated dead code, mention it — don't delete it.
55- Remove imports/variables/functions that YOUR changes made unused.
56- Don't remove pre-existing dead code unless asked.
57 
58**The test:** Every changed line should trace directly to the user's request.
59 
60### 4. Goal-Driven Execution
61 
62**Define success criteria. Loop until verified.**
63 
64| Instead of... | Transform to... |
65|---|---|
66| "Add validation" | "Write tests for invalid inputs, then make them pass" |
67| "Fix the bug" | "Write a test that reproduces it, then make it pass" |
68| "Refactor X" | "Ensure tests pass before and after" |
69 
70For multi-step tasks, state a brief plan:
71 
72```
731. [Step] → verify: [check]
742. [Step] → verify: [check]
753. [Step] → verify: [check]
76```
77 
78## Slash command
79 
80`/karpathy-check` — Run the full 4-principle review on your staged changes.
81 
82## Python tools (`scripts/`)
83 
84All tools are stdlib-only. Run with `--help`.
85 
86| Script | What it detects |
87|---|---|
88| `complexity_checker.py` | Over-engineering: too many classes, deep nesting, high cyclomatic complexity, unused params, premature abstractions |
89| `diff_surgeon.py` | Diff noise: lines that don't trace to the stated goal — comment changes, style drift, drive-by refactors |
90| `assumption_linter.py` | Hidden assumptions in a plan: unasked features, missing clarifications, silent interpretation choices |
91| `goal_verifier.py` | Weak success criteria: vague plans without verifiable checks, missing test assertions |
92 
93## Sub-agent
94 
95`karpathy-reviewer` — Runs all 4 principles against a diff. Dispatched by `/karpathy-check` or manually before committing.
96 
97## Pre-commit hook
98 
99`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.
100 
101## References
102 
103- `references/karpathy-principles.md` — the source quotes, deeper context, when to relax each principle
104- `references/anti-patterns.md` — 10+ before/after examples across Python, TypeScript, and shell
105- `references/enforcement-patterns.md` — how to wire hooks, CI integration, team adoption
106 
107## When to relax
108 
109These principles bias toward **caution over speed**. For trivial tasks (typo fixes, obvious one-liners), use judgment. The principles matter most on:
110 
111- Non-trivial implementations (>20 lines changed)
112- Code you don't fully understand
113- Multi-step tasks with unclear requirements
114- Anything that will be reviewed by humans
115 
116## Cross-tool compatibility
117 
118Installs via plugin for Claude Code. For other tools, copy the principles into your schema file:
119 
120| Tool | Schema file |
121|---|---|
122| Claude Code | `CLAUDE.md` (auto-loaded by plugin) |
123| Codex CLI | `AGENTS.md` |
124| Cursor | `AGENTS.md` or `.cursorrules` |
125| Antigravity / OpenCode / Gemini CLI | `AGENTS.md` |
126 
127## Related skills (chains via `context: fork`)
128 
129- **`self-eval`** — honest quality scoring after completing work
130- **`code-reviewer`** — broader code review; karpathy-coder focuses on the 4 LLM-specific pitfalls
131- **`llm-wiki`** — compound knowledge; karpathy-coder ensures you don't overcomplicate while building it
132 
View all files on GitHub →

Details

Version
2.9.0
Updated
Aug 30, 2026
License
MIT
Stars on the repo
★ 26,349
Checked
Source
alirezarezvani/claude-skills ↗
Creator
alirezarezvani · 363 listings
View creator

Similar skills

See all →
SkillRequires technical rigor and verificationCode Review Receptionobra/superpowers · by obraUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation★ 290k GitHub starsSkillConduct high-quality, persona-driven code reviewsCode Review ExpertHoangNguyen0403/agent-skills-standard · by HoangNguyen0403Conduct high-quality, persona-driven code reviews. Use when reviewing PRs, critiquing code quality, or analyzing changes for team feedback.★ 569 GitHub starsSkillExplain something in the format that is fastestLLM output explainerJohnQinAMD/llm-output-explainer · by JohnQinAMDExplain something in the format that is fastest to understand, from controlled English (ASD-STE100 style), to a diagram, to an interactive HTML page, to a narrated explainer video. Check facts against their sources, using parallel subagents for independent evidence streams when the host supports them. Use when the user wants to understand a substantial concept, algorithm, code change, pull request, paper, benchmark result, or agent output, or asks for an explainer, diagram, HTML explanation, STE, or video. Not for one-line answers, drafting a pull request description, or code review.★ 4 GitHub starsSkillRequests code review before mergingRequesting code reviewobra/superpowers · by obraUse when completing tasks, implementing major features, or before merging to verify work meets requirements★ 290k GitHub starsPromptAct as a code review agent to evaluate and improve codef/prompts.chat · by Xiang FanAct as a code review agent to evaluate and improve code quality, style, and functionality.New listingPromptAct as an expert AI code reviewerCode review by coderabitf/prompts.chat · by Faisal BhuiyanYou are an expert AI code reviewer.New listing

More from alirezarezvani

SkillResume a paused experiment/ar:ar-resume — Resume Experimentalirezarezvani/claude-skills · by alirezarezvaniResume a paused experiment. Checkout the experiment branch, read results history, continue iterating. Use when the user runs /ar:ar-resume or asks to pick up a previously started autoresearch experiment.★ 26.3k GitHub starsSkillShow experiment dashboard with results, active loops/ar:ar-status — Experiment Dashboardalirezarezvani/claude-skills · by alirezarezvaniShow experiment dashboard with results, active loops, and progress. Use when the user runs /ar:ar-status or asks how an autoresearch experiment is going.★ 26.3k GitHub starsSkillStart an autonomous experiment loop with user-selected/ar:loop — Autonomous Experiment Loopalirezarezvani/claude-skills · by alirezarezvaniStart an autonomous experiment loop with user-selected interval (10min, 1h, daily, weekly, monthly). Uses CronCreate for scheduling. Use when the user runs /ar:loop or asks to run an autoresearch experiment continuously on a schedule.★ 26.3k GitHub starsSkillRun a single experiment iteration/ar:run — Single Experiment Iterationalirezarezvani/claude-skills · by alirezarezvaniRun a single experiment iteration. Edit the target file, evaluate, keep or discard. Use when the user runs /ar:run or asks for one manual autoresearch iteration.★ 26.3k GitHub starsSkillSet up a new autoresearch experiment interactively/ar:setup — Create New Experimentalirezarezvani/claude-skills · by alirezarezvaniSet up a new autoresearch experiment interactively. Collects domain, target file, eval command, metric, direction, and evaluator. Use when the user runs /ar:setup or asks to start optimizing a file with the autoresearch loop.★ 26.3k GitHub starsSkill/cs:boardroom <brief/cs:boardroom — Multi-Role Boardroom Deliberationalirezarezvani/claude-skills · by alirezarezvani/cs:boardroom <brief> — 6-phase multi-role deliberation across the C-suite with Phase 2 isolation, critic pre-screen, and synthesis. Outputs a board memo. Use when a decision spans multiple executive domains — e.g. a pricing change touching finance, positioning, and product, or a raise-vs-cut runway call.★ 26.3k GitHub stars