prompt
FreeReduce LLM coding mistakes with Karpathy's thoughtful guidelines
FreeFree tier
About prompt
Andrej Karpathy's coding guidelines for large language models (LLMs) are a structured prompt designed to reduce common coding mistakes when using AI assistants. The guidelines emphasize thinking before coding, simplicity, surgical changes, and goal-driven execution. They encourage LLMs to state assumptions explicitly, avoid overcomplicating, make minimal changes to existing code, and define clear success criteria with verification steps. The prompt is intended to be merged with project-specific instructions and biases toward caution over speed.
Key Features
Think Before Coding: state assumptions, surface tradeoffs, and ask clarifying questions
Simplicity First: write minimum code, no speculative features or over-engineering
Surgical Changes: modify only what's required, match existing style, avoid unnecessary refactoring
Goal-Driven Execution: define success criteria, write tests, verify each step
Plan-first approach for multi-step tasks with verification checkpoints
Bias toward caution and clarity over speed
Pros & Cons
Pros
- Explicitly addresses common LLM pitfalls like overcomplication and assumption hiding
- Encourages test-driven development and verification
- Promotes clean, minimal, and maintainable code
- Reduces hallucinated features and unnecessary abstractions
- Free and open source prompt available on GitHub
Cons
- May be too cautious for simple or trivial coding tasks
- Requires integration with project-specific instructions for full effectiveness
- Not a tool itself, but a text prompt – relies on LLM adherence
- Some developers may find the guidelines overly restrictive for creative coding
Best For
Improving code quality when using LLM coding assistantsReducing unnecessary diffs and rewrites in AI-generated codeTeaching LLMs to adhere to clean coding practices and minimalismStandardizing AI behavior across development teamsPrompt engineering for more reliable code generation
FAQ
What is the purpose of Andrej Karpathy's coding guidelines for LLMs?
The guidelines are designed to reduce common coding mistakes made by LLMs, such as overcomplication, unnecessary changes, and lack of verification. They provide a structured approach to ensure AI-generated code is simple, focused, and well-tested.
How should I use this prompt?
The prompt can be merged with project-specific instructions and provided to an LLM before coding tasks. It is intended to steer the LLM toward cautious, minimal, and goal-oriented code generation.