Add Karpathy-inspired Claude Code guidelines

Behavioral guidelines to reduce common LLM coding mistakes:
1. Think Before Coding - surface assumptions and tradeoffs
2. Simplicity First - minimum code, nothing speculative
3. Surgical Changes - touch only what you must
4. Goal-Driven Execution - define success criteria, loop until verified

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jiayuan Zhang
2026-01-27 11:53:00 +08:00
co-authored by Claude Opus 4.5
commit 8462496b34
2 changed files with 101 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
# Karpathy-Inspired Claude Code Guidelines
A single `CLAUDE.md` file to improve Claude Code behavior, derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/1886192184808149383) on LLM coding pitfalls.
## The Problems
From Andrej's post:
> "The models make wrong assumptions on your behalf and just run along with them without checking. They don't manage their confusion, don't seek clarifications, don't surface inconsistencies, don't present tradeoffs, don't push back when they should."
> "They really like to overcomplicate code and APIs, bloat abstractions, don't clean up dead code... implement a bloated construction over 1000 lines when 100 would do."
> "They still sometimes change/remove comments and code they don't sufficiently understand as side effects, even if orthogonal to the task."
## The Solution
Four principles in one file:
| Principle | Addresses |
|-----------|-----------|
| **Think Before Coding** | Wrong assumptions, hidden confusion, missing tradeoffs |
| **Simplicity First** | Overcomplication, bloated abstractions |
| **Surgical Changes** | Orthogonal edits, touching code you shouldn't |
| **Goal-Driven Execution** | Leverage through tests-first, verifiable success criteria |
## Usage
Copy `CLAUDE.md` to your project root. Claude Code reads it automatically.
## Key Insight
From Andrej:
> "LLMs are exceptionally good at looping until they meet specific goals... Don't tell it what to do, give it success criteria and watch it go."
The "Goal-Driven Execution" principle captures this: transform imperative instructions into declarative goals with verification loops.