AI Agent Hub
Back to skills
Karpathy Guidelines icon

Karpathy Guidelines

AI Agent Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please install @user_2e914038/andrej-karpathy-skills according to https://skillhub.cn/install/skillhub.md.

About this skill

The Specific Problem

In LLM-assisted coding, common issues include: models failing to state assumptions, over-engineering code, unnecessary modifications, and lacking verifiable goals. These mistakes lead to bloated, hard-to-maintain code that deviates from user intent. For instance, an LLM might hide confusion, assume multiple interpretations silently, or add unrequested features, increasing complexity.

Core Guidelines and How It Works

Derived from Andrej Karpathy's observations, this skill provides four behavioral guidelines to reduce coding errors:

  • Think Before Coding: Explicitly state assumptions before implementation. If uncertain, ask; when multiple interpretations exist, present them. Key steps involve state assumptions and naming confusing points.
  • Simplicity First: Write minimum code that solves the problem. Avoid speculative features, unnecessary abstractions, or excessive error handling. For example, if 200 lines can be reduced to 50, rewrite. Self-question: "Would a senior engineer say this is overcomplicated?"
  • Surgical Changes: Only touch what is necessary. Do not improve adjacent code or comments; match existing style; clean up only orphaned code caused by your changes. Check: each changed line should trace directly to the user's request.
  • Goal-Driven Execution: Convert tasks into verifiable goals. For example, "add validation" becomes "write tests for invalid inputs, then make them pass". Loop with clear success criteria to avoid vague goals like "make it work".

These guidelines bias towards caution, with core capabilities in error reduction through structured steps: assumption transparency, code simplification, precise modifications, and goal-driven execution.

Applicability and Caveats

This skill is suitable for most coding tasks, especially in complex or collaborative settings. However, for simple or trivial tasks, use judgment to balance speed and caution. Note points include:
- Maintain existing code style, even if personal preference differs.
- Do not delete unrelated dead code unless explicitly requested.
- Clarify confusion before implementation to avoid post-hoc errors.
When applied, unnecessary changes in diffs should decrease, and rewrites due to over-engineering reduced.

Use Cases

  • When using GPT-4 to generate code snippets, apply Think Before Coding guidelines to explicitly list all assumptions, avoiding subsequent misunderstandings and rework.
  • When LLM provides over-engineered solutions, follow Simplicity First principle and rewrite to minimum viable code, eliminating speculative features.
  • When modifying existing codebases, use Surgical Changes techniques to adjust only necessary parts and maintain consistent style, preventing unrelated changes.
  • Convert vague tasks into Goal-Driven Execution by defining test cases to verify LLM output meets expectations, ensuring verifiable results.

Best For

  • Software engineers responsible for AI model integration, needing to ensure generated code is concise and maintainable while reducing debugging time.
  • Developers using tools like Copilot for daily coding, aiming to avoid common errors such as over-abstraction and unnecessary modifications.
  • Technical team leads seeking to standardize LLM usage workflows to improve code quality and promote consistent team collaboration.
  • AI researchers applying best practices in experimental code to prevent over-engineering and maintain code clarity.