卡帕蒂指南
- 作者仓库星标 166,534
- 许可证 MIT
- 作者仓库 andrej-karpathy-skills
- 领域
- 写作
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @multica-ai · MIT
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Karpathy Guidelines
Behavioral guidelines to reduce common LLM coding mistakes, derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) on LLM coding pitfalls.
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
## 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 ("make it work") require constant clarification.
章节与文件索引
按说明文件中的顺序排列。
1. 编码前思考
2.简单第一
3. 手术改变
4. 目标驱动的执行
文件/命令 -> x.com/karpathy/status/2015883857489522876 · imports/variables/functions
内容校验值 -> 0a89047040b0
当前原文的自动摘译,尚未人工审校。
1. 编码前思考
不要假设。不要隐藏困惑。表面的权衡。实施之前:明确陈述您的假设。如果不确定,请询问。如果存在多种解释,请提出它们 - 不要默默地选择。如果存在更简单的方法,请说出来。在有必要的时候进行反击。
2.简单第一
解决问题的最少代码。没什么投机的。没有超出要求的功能。没有一次性代码的抽象。没有不被要求的“灵活性”或“可配置性”。对于不可能的情况没有错误处理。
3. 手术改变
只触摸你必须触摸的部分。只清理你自己的烂摊子。编辑现有代码时: 不要“改进”相邻的代码、注释或格式。不要重构未损坏的东西。匹配现有的风格,即使你会采取不同的做法。
4. 目标驱动的执行
定义成功标准。循环直到验证为止。将任务转化为可验证的目标:“添加验证”→“为无效输入编写测试,然后使其通过”“修复错误”→“编写重现它的测试,然后使其通过”“重构 X”→“确保测试前后通过”