跳到正文
Skillpedia
通用编程48k · #3740

andrej-karpathy

它能做什么

这份指南可以帮助 AI 写出更好的代码,避免常见错误。它强调做小而清晰的改动、先思考再行动,并确保代码完全按照预期运行。

适用场景

  • ✓当你让 AI 编写新代码时。
  • ✓当你让 AI 审查或改进现有代码时。
  • ✓当你希望 AI 不要把简单的任务复杂化时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/andrej-karpathy/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/andrej-karpathy/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“AI,帮我写一个把两个数相加的简单函数,请想清楚最清晰、最直接的写法,不要额外添加多余的东西。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会按照一些步骤来工作:先想清楚再动手写代码,只关注解决问题所需的最小范围,只做你明确要求的修改,并定义怎样判断结果是否正确。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Karpathy Guidelines

Behavioral guidelines to reduce common LLM coding mistakes, derived from Andrej Karpathy's observations on LLM coding pitfalls.

Tradeoff: These guidelines bias toward caution over speed. For trivial tasks, use judgment.

When to Use This Skill

  • Use when writing, reviewing, or refactoring code with an LLM.
  • Use when a change needs to stay surgical and avoid speculative abstractions.
  • Use when assumptions, tradeoffs, and verification criteria should be made explicit.
  • Use when code has become overcomplicated and needs to be simplified.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State your assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them - don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it - don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into 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"

For multi-step tasks, state a brief plan:

1. [Step] -> verify: [check]
2. [Step] -> verify: [check]
3. [Step] -> verify: [check]

Strong success criteria let you loop independently. Weak criteria such as "make it work" require constant clarification.

Examples

User request: "Add validation to this form."

Better response:
1. Assumption: validation should run before submit and show inline errors.
2. Plan: add a small validator, add tests for invalid inputs, then verify existing submit behavior.
3. Scope: only touch the form component and its test file.
User request: "Refactor this service."

Better response:
1. Ask what behavior must remain unchanged.
2. Identify a concrete smell, such as duplicated parsing logic.
3. Make the smallest refactor and run the existing service tests.

Limitations

  • These guidelines are behavioral guardrails, not a replacement for project-specific architecture or style rules.
  • For emergency fixes, prioritize the smallest verified correction over extensive planning.
  • For exploratory prototypes, some caution can be relaxed, but assumptions and verification should still be explicit.
常见问题

为什么 AI 要先思考再写代码?

这样可以避免瞎猜、掩盖困惑,或者写出比实际需要复杂得多的方案。与其硬着头皮做,不如先提问、把需求讲清楚。

“精准修改”是什么意思?

意思是只改动完成请求所严格必需的部分,不去动代码中其他与请求无关的地方。

AI 怎么判断代码是不是好的?

AI 会先定义清晰的标准,用来判断目标是否达成。比如,它不会只说“修复这个 bug”,而是会定义成“先写一个能复现这个 bug 的测试,再让这个测试通过”。

详情

作者的原始描述

Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#3740
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能