Independent PREVENTIVE GUARDRAILS

Karpathy Guidelines

Surgical changes, assumption verification, scope discipline — prevent common LLM mistakes before and during coding.

01 ▸ Workflow Position

[Plan] │ ▼ ┌─────────────────────────────┐ │ Karpathy (ACTIVE) │ │ Preventive Guardrails │ └──────────────┬──────────────┘ │ ▼ [Execute] │ ▼ [Verify]

02 ▸ When to use?

Always active before implementation and during coding. Prevents LLMs from ignoring existing code or attempting excessive changes.
Key Triggers
  • Before starting feature implementation
  • When attempting to generate code without reading existing context
  • During code modification (including exception handling)

03 ▸ How it works?

Core Principle: "Verify, don't guess." Every decision made during implementation must be based on evidence from the actual codebase.
Guardrail Process
  • Context Sync: Before starting modifications, read the file and its related dependencies to understand conventions.
  • List & Verify Assumptions: Immediately verify assumptions like "This function will return X" using grep or read_file.
  • Lock Change Scope: Limit the scope to prevent unrelated refactoring or "future-proofing" code.

04 ▸ 5 Hard Rules

Mandatory Rules
  1. Surgical Changes (Minimum Edit Needed): Only make the minimum changes required to meet the goal. Separate refactoring into a different task.
  2. No Modification Before Reading: Understand the style and conventions of the file to be modified first. Never code based on guesses.
  3. Verify All Assumptions: Always directly check APIs, function signatures, and data structures. Guesses are the root of all bugs.
  4. Define Specific Success Criteria: Clearly define "what state constitutes completion" before starting to code.
  5. No Solving Imaginary Future Problems: Strictly exclude abstractions, generalizations, or extra configurations added "because they might be needed later."

05 ▸ Related Skills

Clean AI Slop Systematic Debugging ← Back to Home