关于 karpathy-agentic-engineering
面向使用 Agent 编码的开发者,强调明确任务、可验证的成功标准、渐进式修改与人工审查。内容包含项目指令模板和可重复执行的编码循环。
主要功能
- 01七步渐进式编码循环
- 02含可验证标准的任务提示词
- 03CLAUDE.md 与 AGENTS.md 模板
- 04差异审查与验证指引
- 05常见失误防范措施
适用场景
- 01开始 Agent 辅助编码任务
- 02为代码库编写 Agent 指令
- 03借助 Agent 调试复杂问题
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ learnprompt/ andrej-karpathy-skills --skill karpathy-agentic-engineering安装后在 Claude Code 中输入/karpathy-agentic-engineering确认已加载。
详细介绍
技能 1:Agentic Engineering(代理工程)
来源:https://x.com/karpathy/status/2004607146781278521 | https://x.com/karpathy/status/2015883857489522876 | https://x.com/karpathy/status/2026731645169185220 “很难让人理解编程已经发生了多大的变化。” — 约 3.7 万个赞
核心原则
你不再编写代码,而是在指挥一支不知疲倦的初级工程师团队。
转变过程:write code → write tasks with success criteria → agent loops → human taste review
7 步内循环(Karpathy 的渐进式编码节奏)
这是每次编码会话的微循环:
- 填充上下文 — 将整个项目载入上下文(
files-to-prompt、相关文档、近期 diff) - 讨论计划 — 在编写任何代码之前,让 Agent 提出高层方案并说明优缺点
- 请求初稿 — 选定一种方案,让 Agent 给出最简初步实现
- 边做边学 — 手动检查 diff;遇到不熟悉的 API,就让 Agent 解释
- 测试 — 运行测试、检查输出、验证成功标准
- 提交 — 只提交自己理解并验证过的内容
- 询问下一步 — 让 Agent 建议下一个渐进步骤
绝不要跳过第 4 步。 如果对每个 diff 都不加检查地直接认可,理解能力就会退化。
CLAUDE.md / AGENTS.md 模板
在项目根目录编写此文件,以防止 Agent 最常见的失败模式:
# Agent Instructions for [Project Name]
## Behavior Rules
- Make one incremental change at a time. Do NOT refactor unrelated code.
- Always explain WHY you're making a change before the diff.
- If unsure about intent, ASK before implementing.
- Do NOT add new dependencies without explicit approval.
- Prefer simple, readable solutions over clever ones.
## Success Criteria (task-specific — fill in per session)
- [ ] Tests pass: `[test command]`
- [ ] No new lint errors: `[lint command]`
- [ ] Behavior matches: [description of expected output]
## Project Context
- Stack: [language, framework, key libs]
- Entry point: [file]
- Test command: [command]
- Forbidden: [list things agent must never do]
主提示词模板
You are an agentic engineer on this project.
Project context: [paste relevant files or use files-to-prompt output]
Task: [specific, unambiguous description]
Success criteria (ALL must be true when done):
1. [verifiable check 1]
2. [verifiable check 2]
3. [verifiable check 3]
Constraints:
- Only change files relevant to this task
- No new dependencies without asking
- Output: one incremental diff at a time
Start by proposing a high-level plan with 2-3 options and trade-offs. Wait for approval before writing code.
需要预防的常见失败模式
| Agent 的问题 | 预防方法 |
|---|---|
| 过度重构 | “只修改与任务直接相关的文件” |
| 迎合式确认 | “告诉我这个计划可能会出什么问题” |
| 臆造 API | “使用任何 API 时,都引用文档中的确切行” |
| 依赖不断增加 | “未经询问,不要新增 pip/npm 安装” |
| 缺少成功标准 | 开始前始终定义完成标准 |
工作流
所属工作流:从想法到上线(开发者)
| 位置 | 上游 | 下游 |
|---|---|---|
| 第 2 步 | karpathy-idea-files(先定义想法) | karpathy-minimalism(极简实现) |
完整链路:idea-files → agentic-engineering → minimalism → supply-chain-hygiene → vibe-to-agentic
它也常作为反偏见决策工作流中的执行层出现——决策完成后需要落实时,切换到此技能。
提示词约定
You are an agentic engineer. Project context: <files, constraints, current state>. Task: <specific goal>. Success criteria: <verifiable checklist>. First propose a high-level plan with tradeoffs. Then make only the next incremental change. After each change, run the relevant verification and report: changed files, evidence of success, remaining risk, and next step.
验证清单
- 成功标准已写成可检查的项目(而非模糊描述)
- 每轮变更都有实际验证证据:测试通过、lint clean、diff 范围正确
- Agent 未修改任务范围之外的文件
- 人类已 review 每个 diff 中不理解的部分(不跳过步骤)
- 最终提交前,能够用一句话向同事解释修改了什么以及原因
何时应用此技能
- 开始任何超过 30 分钟的编码任务
- 在 Agent 的协助下搭建新项目
- 调试复杂问题(让 Agent 充当橡皮鸭和实现者)
- 为代码仓库编写 CLAUDE.md / AGENTS.md
评论
支持 Markdown