插件低风险未认领

karpathy-coder

Active coding discipline enforcer based on Karpathy's 4 principles: surface assumptions, keep it simple, make surgical changes, define verifiable goals. Ships 4 Python tools (complexity_checker, diff_surgeon, assumption_linter, goal_verifier), a review agent, /karpathy-check slash command, and a pre-commit hook. All tools stdlib-only.

alirezarezvanialirezarezvani/karpathy-coder-plugin★ 30k版本 2.14.9更新于 2026年11月17日

说明

Active coding discipline enforcer based on Andrej Karpathy's observations on LLM coding pitfalls.

Not just guidelines — ships Python tools that detect violations, a review agent, a slash command, and a pre-commit hook.

The 4 principles

# Principle What it prevents Tool that checks it
1 Think Before Coding Hidden assumptions, silent choices assumption_linter.py
2 Simplicity First Over-engineering, premature abstractions complexity_checker.py
3 Surgical Changes Diff noise, drive-by refactors diff_surgeon.py
4 Goal-Driven Execution Vague plans, missing verification goal_verifier.py

Quick start

# Install as Claude Code plugin
/plugin marketplace add alirezarezvani/claude-skills
/plugin install karpathy-coder@claude-code-skills

# Run before committing
/karpathy-check

# Or use individual tools from the shell
python scripts/complexity_checker.py src/ --threshold strict
python scripts/diff_surgeon.py --diff HEAD~1..HEAD
echo "I'll just export all user data" | python scripts/assumption_linter.py -
python scripts/goal_verifier.py plan.md

What's in the box

Piece Count Detail
SKILL.md 1 The 4 principles with context: fork for skill chaining
Python tools 4 complexity_checker, diff_surgeon, assumption_linter, goal_verifier — all stdlib-only
Sub-agent 1 karpathy-reviewer — runs all 4 principles against a diff
Slash command 1 /karpathy-check — one-command pre-commit review
Pre-commit hook 1 karpathy-gate.sh — non-blocking awareness gate
Reference docs 3 Full Karpathy context, 10+ anti-pattern examples, 4-level enforcement guide

The tools

complexity_checker.py (Principle #2)

Detects over-engineering: cyclomatic complexity, class density, nesting depth, function length, premature ABC/Protocol usage, import coupling.

python scripts/complexity_checker.py src/auth/ --threshold strict --json
# → score 72/100, 3 findings: nesting depth 6, function 'validate' 62 lines, 2 classes in 80 lines

Three threshold levels: strict (new code), medium (default), relaxed (legacy).

diff_surgeon.py (Principle #3)

Analyzes a git diff and flags lines that don't trace to the stated goal: comment-only changes, whitespace noise, style drift (quote swaps), drive-by refactors, docstring additions to unchanged functions.

python scripts/diff_surgeon.py                    # staged changes
python scripts/diff_surgeon.py --diff HEAD~3..HEAD # last 3 commits
# → Noise ratio: 23% (NOISY), 7 comment-only changes, 2 quote-style swaps

assumption_linter.py (Principle #1)

Reads a plan or proposal and flags hidden assumptions: "just" (hides complexity), "obviously" (unstated assumption), "should work" (hopeful, not verified), vague action verbs, unscoped user references, missing format specifications.

echo "I'll just add a function to export all user data" | python scripts/assumption_linter.py -
# → 3 findings: assumption-just, missing-format, scope-absolute

goal_verifier.py (Principle #4)

Scores each step of a plan for verification quality (0-3 per step). Flags vague criteria ("should work"), checks for final end-to-end verification, and recommends concrete checks.

python scripts/goal_verifier.py implementation-plan.md --json
# → 6 steps, 8/18 (44%), WEAK — 3 steps have no verification

Enforcement levels

  1. Passive — install plugin, principles load as context (~60% compliance)
  2. Active review — run /karpathy-check before commits (~85%)
  3. Pre-commit hook — wire karpathy-gate.sh via Husky (~95%)
  4. CI gate — add tools to GitHub Actions PR checks (~99%)

See references/enforcement-patterns.md for setup instructions at each level.

Cross-tool compatibility

The tools are pure Python stdlib. The principles work in any AGENTS.md-aware CLI (Codex, Cursor, Antigravity, OpenCode, Gemini CLI).

Attribution

Derived from Andrej Karpathy's X post on LLM coding pitfalls. The principles are Karpathy's observations; the tooling, enforcement patterns, and anti-pattern gallery are original.

License

MIT.

宿主

宿主装上后有
Claude Code技能 1助手 1命令 1
Codex只装技能
OpenCode只装技能

成员1 个技能 · 1 个助手

  • karpathy-coderCheck a diff for overbuilt code: hidden assumptions, needless abstraction, non-surgical changes, unverified goals (Karpathy's four principles). Load whenever the user thinks they overcomplicated something or wants a pre-commit check.
  • karpathy-reviewer助手Reviews staged git changes against Karpathy's 4 coding principles. Runs complexity_checker on changed files, diff_surgeon on the diff, and produces a verdict with specific fix recommendations. Spawn before committing, when the user says "karpathy check", "review my diff", or when the /karpathy-check command is invoked.

权限

完整安装
2.14.9
声明检测
运行代码—pythonshell
安装—npx
安装时运行脚本—无
网络—alirezarezvani.comgithub.comx.com
需要的凭据—无
工作区外的路径—无
智能体工具—无

检查

低风险 · 没有发现需要提醒的地方。

未经人工审核 · 已做规则检查;模型审核尚未开启。

另有 1 处低风险标记:常见命令之类,只记录、不提醒
  • 规则 · command_injectionagents/karpathy-reviewer.md:8

文件17 个文件 · 62.9 KB

  • README.md4.3 KB
.claude-plugin/1
  • plugin.json724 B
agents/1
  • karpathy-reviewer.md3.0 KB
commands/1
  • karpathy-check.md1.8 KB
hooks/1
  • karpathy-gate.sh1.4 KB
skills/karpathy-coder/1
  • SKILL.md5.5 KB
skills/karpathy-coder/expected_outputs/4
  • assumption_linter.json933 B
  • complexity_checker.json584 B
  • diff_surgeon.json158 B
  • goal_verifier.json853 B
skills/karpathy-coder/references/3
  • anti-patterns.md4.8 KB
  • enforcement-patterns.md3.7 KB
  • karpathy-principles.md3.7 KB
skills/karpathy-coder/scripts/4
  • assumption_linter.py6.7 KB
  • complexity_checker.py10.7 KB
  • diff_surgeon.py7.7 KB
  • goal_verifier.py6.5 KB

版本

  1. #12.14.9最新2026年11月17日

在 Codeg 中打开

也可以复制地址,在 Codeg 的「发现」里搜索。

alirezarezvani/karpathy-coder-plugin

还没有 Codeg?下载