andrej-karpathy-skills-claude
```markdown
What this skill does
```markdown
---
name: andrej-karpathy-skills-claude
description: CLAUDE.md guidelines derived from Andrej Karpathy's LLM coding pitfalls observations — four principles to reduce AI coding mistakes
triggers:
- install karpathy claude guidelines
- add karpathy skills to my project
- improve claude code behavior
- reduce llm coding mistakes
- add claude md guidelines
- setup karpathy coding principles
- configure claude code best practices
- prevent ai overcomplicated code
---
# Andrej Karpathy Skills for Claude Code
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
A single `CLAUDE.md` file that installs four principles into Claude Code (or any AI coding agent) derived from Andrej Karpathy's observations on common LLM coding pitfalls — silent assumptions, overengineering, orthogonal edits, and vague task execution.
## What This Project Does
This repo provides a battle-tested `CLAUDE.md` configuration that addresses four core failure modes Karpathy identified in LLM-assisted coding:
| Problem | Principle Applied |
|---------|------------------|
| Silent wrong assumptions, no clarification | **Think Before Coding** |
| Overengineered, bloated abstractions | **Simplicity First** |
| Touching code unrelated to the task | **Surgical Changes** |
| Vague imperatives with no success criteria | **Goal-Driven Execution** |
## Installation
### Option A: Claude Code Plugin (recommended, all projects)
Run inside Claude Code:
```
/plugin marketplace add forrestchang/andrej-karpathy-skills
/plugin install andrej-karpathy-skills@karpathy-skills
```
This makes the guidelines available across every project without per-repo setup.
### Option B: Per-Project CLAUDE.md
**New project:**
```bash
curl -o CLAUDE.md https://raw.githubusercontent.com/forrestchang/andrej-karpathy-skills/main/CLAUDE.md
```
**Existing project (append to current CLAUDE.md):**
```bash
echo "" >> CLAUDE.md
curl https://raw.githubusercontent.com/forrestchang/andrej-karpathy-skills/main/CLAUDE.md >> CLAUDE.md
```
**Verify installation:**
```bash
cat CLAUDE.md
```
## The Four Principles
### 1. Think Before Coding
Force explicit reasoning before implementation. The agent must:
- State assumptions before writing code
- Present multiple interpretations when ambiguity exists
- Ask rather than guess when uncertain
- Push back if a simpler approach exists
**You'll see this working when** Claude asks clarifying questions before starting, not after producing wrong output.
### 2. Simplicity First
No speculative features, no premature abstractions, no unrequested flexibility.
**The senior engineer test:** Would a senior engineer call this overcomplicated? If yes, rewrite it simpler.
Examples the principle prevents:
- Adding `configurable` options when one hardcoded value was needed
- Wrapping a 3-line function in a class with 5 methods
- Error handling for scenarios that cannot happen in the given context
### 3. Surgical Changes
When editing existing code, touch only what the request requires:
```
✅ Remove imports YOUR changes made unused
✅ Delete functions YOUR changes orphaned
❌ Refactor adjacent code that wasn't broken
❌ Fix formatting in untouched files
❌ Delete pre-existing dead code (mention it instead)
```
**The diff test:** Every changed line must trace directly to the user's request.
### 4. Goal-Driven Execution
Transform imperative tasks into verifiable success criteria:
```
Instead of: "Add input validation"
Write: "Write tests for invalid inputs, then make them pass"
Instead of: "Fix the bug"
Write: "Write a test reproducing the bug, then make it pass"
Instead of: "Refactor X"
Write: "Ensure all tests pass before and after, no behavior change"
```
For multi-step tasks, the agent should produce a plan:
```
1. Add schema validation → verify: unit tests pass
2. Wire to API handler → verify: integration test passes
3. Update docs → verify: examples match new API
```
## Adding Project-Specific Rules
The CLAUDE.md is designed to merge with your existing instructions. After installing, append your project context:
```markdown
## Project-Specific Guidelines
- Use TypeScript strict mode everywhere
- All new API endpoints require an integration test in `tests/api/`
- Follow error handling patterns established in `src/utils/errors.ts`
- Database migrations go in `db/migrations/` with timestamp prefix
- Never mutate `req` or `res` objects directly — use the wrapper helpers
```
## Real Usage Examples
### Triggering Think Before Coding
When a request is ambiguous, the agent should respond:
```
I see two interpretations of "add caching":
A) In-memory cache per process (fast, no infra)
B) Redis cache shared across instances (persistent, needs Redis)
Which do you want? Or is there a third option I'm missing?
```
### Triggering Simplicity First
Bad (what the principle prevents):
```python
class ValidationStrategy(ABC):
@abstractmethod
def validate(self, value: Any) -> ValidationResult: ...
class EmailValidationStrategy(ValidationStrategy):
def validate(self, value: Any) -> ValidationResult:
# 40 more lines...
```
Good (what the principle produces):
```python
def is_valid_email(value: str) -> bool:
return "@" in value and "." in value.split("@")[-1]
```
### Triggering Surgical Changes
Given task: "Fix the off-by-one error in `calculate_total()`"
```python
# BEFORE
def calculate_total(items):
total = 0
for i in range(len(items) - 1): # bug: misses last item
total += items[i].price
return total
# AFTER (surgical — only the bug is fixed)
def calculate_total(items):
total = 0
for i in range(len(items)): # fixed
total += items[i].price
return total
```
The agent should NOT also rename variables, reformat, or switch to `sum()` unless asked.
### Triggering Goal-Driven Execution
```markdown
## Task
Refactor the authentication middleware.
## Success Criteria
1. All existing auth tests in `tests/test_auth.py` pass unchanged
2. No new public API surface (same function signatures)
3. `mypy --strict` reports no new errors
4. Response time for `/api/health` unchanged (< 5ms)
```
## Common Patterns
### Pattern: Clarify Before Long Tasks
For tasks estimated over 30 minutes, the agent should surface assumptions first:
```
Before I start, confirming my understanding:
- Scope: only the `UserService` class, not `AuthService`
- Test coverage: existing tests must still pass
- Breaking changes: none (same public interface)
Does this match your intent?
```
### Pattern: Mention, Don't Fix
When the agent spots unrelated issues:
```
Note: I noticed `utils/legacy_parser.py` appears unused — not touching
it as it's outside this task's scope, but flagging for your awareness.
```
### Pattern: Plan Then Execute
For multi-file changes:
```
Plan:
1. Update `schema.py` with new field → verify: `python -m pytest tests/test_schema.py`
2. Add migration file → verify: `alembic upgrade head` succeeds
3. Update API handler → verify: `python -m pytest tests/test_api.py`
4. Update OpenAPI spec → verify: spec validates against handler
Proceeding with step 1...
```
## Troubleshooting
### Guidelines not being followed
**Check:** Is the CLAUDE.md in the project root (where Claude Code is launched)?
```bash
ls -la CLAUDE.md
```
**Check:** Did the plugin install correctly?
```
/plugin list
```
**Check:** For existing CLAUDE.md files, did the append work?
```bash
grep -n "Think Before Coding" CLAUDE.md
```
### Agent still making unrequested changes
Add an explicit project-specific rule in your CLAUDE.md:
```markdown
## Hard Rules
- NEVER modify files not mentioned in the task
- NEVER change formatting or style in untouched files
- ALWAYS confirm scope before editing more than 3 files
```
### Agent not asking clarifying questions
Prompt engineering tip — rephrase tasks to invite questions:
```
Before implementing: "Add rate limiting — ask me any clarifying
questioRelated in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.