/karpathy-guidelines:clean-codefrom karpathy-guidelines
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, unrequested refactors, drive-by style changes, vague success criteria. Use this whenever writing, reviewing, editing, refactoring, or debugging ANY code, no matter how small the task seems — a one-line fix, a "quick" feature, a bug report, a "clean this up" request, or a full new module. Always consult this skill before producing code, and read EXAMPLES.md (bundled alongside this file) for concrete before/after cases of each principle. Trigger even if the user doesn't mention "guidelines," "best practices," or "code quality" explicitly — any coding task qualifies.
Ships in karpathy-guidelines. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Behavioral guidelines to reduce common LLM coding mistakes, derived from Andrej Karpathy's observations on LLM coding pitfalls.
Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.
Companion file: EXAMPLES.md, bundled in this same skill folder, contains full worked examples (❌ wrong vs. ✅ right, real code, real diffs) for every principle below. Read it whenever you want a concrete pattern to check your work against — not just for ambiguous cases, but as a default step before finishing a coding task. Don't paraphrase it from memory; open and read the file itself so nothing is missed.
Don't assume. Don't hide confusion. Surface tradeoffs.
Before implementing:
See EXAMPLES.md § 1 for the "hidden assumptions" (data export) and "multiple interpretations" (search speed) cases.
Minimum code that solves the problem. Nothing speculative.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
See EXAMPLES.md § 2 for the "over-abstraction" (discount strategy pattern) and "speculative features" (preference manager) cases.
Touch only what you must. Clean up only your own mess.
When editing existing code:
When your changes create orphans:
The test: Every changed line should trace directly to the user's request.
See EXAMPLES.md § 3 for the "drive-by refactoring" (email validator bug fix) and "style drift" (logging addition) cases.
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
For multi-step tasks, state a brief plan:
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
See EXAMPLES.md § 4 for the "vague vs. verifiable" (auth fix), "multi-step with verification" (rate limiting), and "test-first verification" (sorting bug) cases.
If any box is unchecked, go back and fix it before presenting the result — don't just note it as a caveat.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub harshitmywork17/claude-mods --plugin karpathy-guidelines