Skip to content
Skillpedia
General coding220k Β· #628

karpathy-guidelines

What it does

This guide helps AI write better code by avoiding common mistakes. It teaches the AI to think before coding, keep code simple, make only necessary changes, and clearly define what a good result looks like.

When to use it

  • βœ“When the AI is writing new code.
  • βœ“When the AI needs to fix or improve existing code.
  • βœ“When you want the AI to avoid unnecessary complications.

Skill link

https://github.com/multica-ai/andrej-karpathy-skills/blob/main/skills/karpathy-guidelines/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/multica-ai/andrej-karpathy-skills/blob/main/skills/karpathy-guidelines/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

πŸ“¦ This skill is in these packs

Example of what to ask your AI

β€œAI, write a function to calculate the average of a list of numbers, but think carefully before starting and only add what's essential.”

5 new skills a week. 1 minute to read.

karpathy-guidelines: full guide

AI coding agents tend to make the same mistakes. They guess instead of asking. They write 200 lines where 50 would do. They rename things, tidy comments and "improve" code you never mentioned. Then you have to read a large change just to find the three lines that matter.

This skill is a short set of rules that pushes the agent the other way. It tells the agent to state its assumptions, write the minimum code, touch only what the request needs, and agree on a check that proves the job is done. It is for anyone who reviews AI-written code, including people who do not write code themselves. The skill says it favors caution over speed, so for a trivial one-line fix it may be more than you need.

Use cases

Fixing one bug in a shared project

A checkout page rounds prices wrongly. You want the agent to change that one calculation. With these rules it adds a test that shows the wrong price, fixes it, and leaves nearby formatting and old comments alone, so your teammates see a small, readable change.

Asking for a feature with a vague request

You type "add search to the product list." The agent should not pick an approach silently. It lists the possible readings, such as search by name only or by name and category, and asks which one you mean before writing code.

Cleaning up after an agent session

The agent added a helper function, then later stopped using it. These rules tell it to remove the imports and functions its own work left unused. It should only mention old dead code it finds, not delete it, so you keep control.

Refactoring with a safety net

You ask the agent to restructure a module. The skill turns that into a goal: make sure the tests pass before and after. If they fail afterwards, the agent knows the change broke something and keeps working.

Step by step

  1. 1Install the skill: in Claude Code, put the karpathy-guidelines folder in ~/.claude/skills/ or in your project's .claude/skills/.
  2. 2Start a coding task as usual. The agent applies the skill when you ask it to write, review or refactor code.
  3. 3Write the request with an outcome you can check, such as "the new test passes" instead of "make it work."
  4. 4Read the agent's stated assumptions and any questions first. Answer them before it writes code.
  5. 5Review the result: every changed line should trace back to your request. Ask the agent to undo anything that does not.

Example

What to ask

β€œFix the bug where the invoice total ignores the discount code. Only change what is needed, and show me how you will check it works.”

What you get

The agent first states its assumption that the discount is a percentage. It then proposes a short plan: 1. Write a test with a 10% code, which fails now. 2. Fix the total calculation. 3. Run all tests. It changes only that function and mentions an unused old function without deleting it.

Tips

  • βœ“Give the agent a goal it can verify. "Make it work" forces back-and-forth, while "this test should pass" lets the agent loop on its own.
  • βœ“Do not expect it to fix unrelated problems it finds. By design it only mentions them, so ask separately if you want them changed.
  • βœ“Using it for a tiny edit, such as fixing a typo, can slow you down with questions. The skill itself says to use judgment on trivial tasks.

Alternatives

  • code-review

    Pick it when you want your changes checked against your repo's coding standards and the original spec before merging, rather than guiding the agent while it writes.

  • executing-plans

    Pick it when you already have a written implementation plan and want the agent to carry it out step by step, testing each step.

  • diffs

    Pick it when you want to see exactly what the agent changed, as a shareable diff link or image instead of a written summary.

Questions and answers

Does this skill make the AI slower?

Sometimes. It asks questions and states a plan before coding, which adds a short pause. The skill accepts this tradeoff: it favors caution over speed, and the saved rework usually matters more on real tasks.

Will the AI refuse to change code outside my request?

It will avoid changing adjacent code, comments or formatting, and it matches the existing style. If it spots unrelated dead code, it should tell you about it instead of removing it.

Do I need to know how to code to use it?

No. You describe what you want in plain words. The skill makes the agent explain its assumptions and plan in readable steps, which helps you check the work without reading every line.

How it works

The AI follows steps: think before writing, focus on the minimum needed, change only what's necessary, and define how to know when the job is done.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Karpathy Guidelines

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.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State your assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them - don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it - don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into verifiable goals:

  • "Add validation" β†’ "Write tests for invalid inputs, then make them pass"
  • "Fix the bug" β†’ "Write a test that reproduces it, then make it pass"
  • "Refactor X" β†’ "Ensure tests pass before and after"

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.

FAQ

Why should the AI think before coding?

To avoid mistakes, fully understand the problem, and not create solutions that are more complicated than needed.

What does 'simple code' mean?

Writing the least amount of code possible to solve the problem, without adding extra features or unnecessary complexity.

How does the AI know if the code is good?

By setting clear, verifiable goals. For example, instead of 'fix the bug,' the goal is 'write a test that shows the bug, then make the test pass'.

Details

Original description by the author

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.

repo: multica-ai/andrej-karpathy-skills

Popularity

GitHub stars
220k
Ranking position
#628
License
β€”
Updated
4/20/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

Similar skills