Karpathy Coding Guidelines

Karpathy Coding Guidelines

Gives a coding agent four behavioural rules to avoid common LLM mistakes: think first, keep it simple, make surgical changes and define verifiable success criteria.

Skill files1 file
SKILL.md62 lines
1
---
2
name: karpathy-guidelines
3
description: Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.
4
license: MIT
5
---
6
7
# Karpathy Guidelines
8
9
Behavioral guidelines to reduce common LLM coding mistakes, derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) on LLM coding pitfalls.
10
11
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
12
13
## 1. Think Before Coding
14
15
**Don't assume. Don't hide confusion. Surface tradeoffs.**
16
17
Before implementing:
18
- State your assumptions explicitly. If uncertain, ask.
19
- If multiple interpretations exist, present them - don't pick silently.
20
- If a simpler approach exists, say so. Push back when warranted.
21
- If something is unclear, stop. Name what's confusing. Ask.
22
23
## 2. Simplicity First
24
25
**Minimum code that solves the problem. Nothing speculative.**
26
27
- No features beyond what was asked.
28
- No abstractions for single-use code.
29
- No "flexibility" or "configurability" that wasn't requested.
30
- No error handling for impossible scenarios.
31
- If you write 200 lines and it could be 50, rewrite it.
32
33
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
34
35
## 3. Surgical Changes
36
37
**Touch only what you must. Clean up only your own mess.**
38
39
When editing existing code:
40
- Don't "improve" adjacent code, comments, or formatting.
41
- Don't refactor things that aren't broken.
42
- Match existing style, even if you'd do it differently.
43
- If you notice unrelated dead code, mention it - don't delete it.
44
45
When your changes create orphans:
46
- Remove imports/variables/functions that YOUR changes made unused.
47
- Don't remove pre-existing dead code unless asked.
48
49
The test: Every changed line should trace directly to the user's request.
50
51
## 4. Goal-Driven Execution
52
53
**Define success criteria. Loop until verified.**
54
55
Transform tasks into verifiable goals:
56
- "Add validation" -> "Write tests for invalid inputs, then make them pass"
57
- "Fix the bug" -> "Write a test that reproduces it, then make it pass"
58
- "Refactor X" -> "Ensure tests pass before and after"
59
60
For multi-step tasks, state a brief plan:
61
\
62
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 6,373 prompts

More by @OpenSourceBuffGuy

See all
Website Clone Architect prompt image

Website Clone Architect

Reverse-engineers a website section by section, writes component specs, and hands them to parallel builder agents in git worktrees to rebuild it.

agent-skill, orchestrator, parallel-agents, multi-agent, plan-then-execute, web-development, frontend, codebase-analysis, scaffolding, css, html, nextjs, typescript, git, mcp, claude-code, for-developers, for-designers, long-form, advanced, technical-spec, task-decomposition, structured-output, design-systems, ui-ux, tool-use, checklist, report, vibe-coding

Italian Terrace Cafe Candid Portrait prompt image

Italian Terrace Cafe Candid Portrait

Generates a photorealistic candid shot of a woman in a white corset dress laughing at a sunny hotel terrace cafe, written as detailed JSON.

image-prompt, json-prompt, structured-output, photorealistic, portrait, woman, candid, fashion, cottagecore, natural-light, golden-hour, bokeh, summer, travel, cityscape, mountains, medium-shot, vibrant-colors, for-photographers, nano-banana, fashion-shoot, luxury

Night Street Photo With Leashed Cat prompt image

Night Street Photo With Leashed Cat

Generates a flash-lit night street photo of a blonde woman in a retro track jacket walking a hissing tabby cat on a leash.

image-prompt, json-prompt, nano-banana, structured-output, portrait, woman, animals, pet-portrait, night-scene, street-photography, candid, editorial, fashion, dramatic-lighting, photorealistic, vertical-format, medium-shot, graffiti, for-photographers, for-content-creators

1 view

Reviews

Loading reviews…

Discussion

Loading comments…