karpathy-guardrails

A set of four rules for disciplined coding: think through the change first, choose the simplest solution, make small targeted edits, and verify the result.

In plain words
What is it for?
Use it to define the goal, trace where a change starts and ends, limit the files affected, and keep implementation focused on passing tests.
Why use it?
It reduces unnecessary changes, new dependencies, and guesswork before code is edited.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/aksoftcode/aicrew/karpathy-guardrails
Clone the repo
git clone --depth 1 https://github.com/AKSoftCode/aicrew
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 648 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00648
Opus 5 $0.00000 $0.00324
Sonnet 5 $0.00000 $0.00130
Haiku 4.5 $0.00000 $0.00065

Measured 2d ago against content hash fcb9bc191fc0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

karpathy-guardrails scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agents/karpathy-guardrails.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

karpathy-guardrails

Four principles for disciplined, goal-driven coding — derived from forrestchang/andrej-karpathy-skills (MIT). Adapted and extended for the aicrew pipeline.

Apply these principles throughout any session. They merge cleanly with project rules and other aicrew agents; nothing here conflicts with TDD, security review, or specialist routing.


The Four Principles

1. Think Before Coding

Before touching any file:

  • State the goal in one sentence
  • Identify the entry point and call chain
  • Name the files that will change (and those that must NOT change)
  • Confirm you understand why the change is needed

Forbidden: jumping straight to an edit without a scout pass.

2. Simplicity First

Always prefer the simpler solution:

  • Fewer files touched is better
  • Fewer new abstractions is better
  • Shortest path from current code to passing tests
  • If two approaches achieve the same outcome, pick the one with less surface area
  • No new dependencies unless the scout confirmed they are required

Ask: "Is there a version of this change with one fewer file?"

3. Surgical Changes

Edits must be diff-sized, not rewrite-sized:

  • Change only what is required to meet the goal
  • Do not reformat, rename, or reorganize code outside the affected region
  • Do not fix unrelated issues unless they block the current goal (log them instead)
  • Keep the diff reviewable: a human should be able to read it in under 2 minutes

Red flags: editing files not mentioned in the scout, adding imports not needed by the change, deleting comments or whitespace in unrelated sections.

4. Goal-Driven Execution

Every action must trace back to the stated goal:

  • Before each edit, ask: "Does this directly advance the goal?"
  • When a new sub-problem appears, note it and continue on the main path
  • Stop when the acceptance criterion is met — do not gold-plate
  • Report done clearly: what changed, what tests passed, what risks remain

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 81 lines · 0 tokens per session scan A fcb9bc191fc0

Subscribe to this mod's changes

karpathy-guardrails is an agent published in the GitHub repository AKSoftCode/aicrew (3 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 648 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.