Andrej Karpathy Coding Guidelines: Behavioral Rules to Reduce Common LLM Coding Mistakes
A set of behavioral guidelines designed to minimize common errors in LLM-generated code, emphasizing caution, simplicity, surgical changes, and goal-driven execution.
Prompt Content
Copy and paste directly into your model or internal evaluation tool.
Follow these behavioral guidelines when coding to reduce common mistakes. Before implementing, state your assumptions explicitly; if multiple interpretations exist, present them all—do not choose silently. Prioritize the simplest solution: avoid speculative features, unnecessary abstractions, or error handling for impossible scenarios. Make only necessary changes: do not 'improve' adjacent code or formatting, and match existing style. When editing, remove only the unused imports/variables/functions your changes introduced. Transform tasks into verifiable goals: e.g., 'Add validation' becomes 'Write tests for invalid inputs, then make them pass.' For multi-step tasks, outline a brief plan with verification checkpoints. Ensure every changed line directly addresses the user's request.
Use Cases
Reference Output
A code implementation that adheres to simplicity, traceability, and verifiability—e.g., a minimal function with only required logic, a validation module with accompanying test cases, or a diff that modifies only relevant files.
Scoring Rubric
Excellent: Fully adheres to all four principles—code is simple, changes are surgical, goals are clear and verifiable; Good: Mostly follows guidelines with minor redundancies but no major deviations; Needs Improvement: Shows over-engineering, unrelated modifications, or lacks verification steps.
User Rating
0 ratingsYour rating
Log in to rate
Comments
0Log in to comment
Related Prompts
Product Marketing - Monochrome Avant-Garde Fashion Portrait
A high-fashion, monochrome editorial prompt for a sharp portrait with dramatic lighting and futuristic accessories, mimicking a luxury brand campaign.
Social Media Post - Magical Night Garden Fashion Portrait
A complex, high-quality prompt for a whimsical fantasy fashion editorial featuring glowing lights and a romantic atmosphere.
Social Media Post - Dreamy Woman in Wildflower Field
A cinematic, photorealistic prompt for a serene portrait of a woman in a field of daisies, emphasizing soft natural light and sharp focus on foreground details.
Social Media Post - Mediterranean Riviera Male Menswear
A comprehensive professional photography prompt for a sharp, high-contrast menswear editorial set against sun-drenched stone architecture.