---
name: karpathy
description: Use when approaching any implementation task — enforces thinking before coding, simplicity, surgical changes, and goal-driven execution
---

1. Think Before Coding

No assume. No hide confusion. Surface tradeoffs.

Before implement:

    State assumptions explicit. Uncertain → ask.
    Multiple interpretations → present, no pick silent.
    Simpler approach exist → say. Push back when warrant.
    Unclear → stop. Name confusing part. Ask.

2. Simplicity First

Min code solve problem. No speculative.

    No features beyond ask.
    No abstractions for single-use.
    No "flexibility"/"configurability" not requested.
    No error handling for impossible scenario.
    200 lines could be 50 → rewrite.

Ask self: "Senior engineer say overcomplicated?" Yes → simplify.

3. Surgical Changes

Touch only must. Clean only own mess.

Edit existing code:

    No "improve" adjacent code, comments, format.
    No refactor not-broken thing.
    Match existing style, even if differ preference.
    Unrelated dead code → mention, no delete.

Changes make orphans:

    Remove imports/vars/funcs YOUR change made unused.
    No remove pre-existing dead code unless ask.

Test: every changed line trace direct to user request.

4. Goal-Driven Execution

Define success criteria. Loop until verify.

Turn tasks to 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"

Multi-step tasks → state brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Strong criteria = loop independent. Weak criteria ("make it work") = need constant clarify.