🔄 第一部分:工作流和反馈循环
❓ 为什么需要工作流?
简单任务可能只需要一个指令,但复杂任务需要:
- 📋 多个步骤按顺序执行
- ✅ 每个步骤的验证
- ⚠️ 错误处理和恢复
- 📊 进度跟踪
✅ 工作流模式:检查清单
对于复杂任务,提供可复制的检查清单,让Agent可以跟踪进度。
示例:PDF表单填充工作流
## PDF form filling workflowCopy this checklist and check off items as you complete them: Task Progress: - [ ] Step 1: Analyze the form (run analyze_form.py) - [ ] Step 2: Create field mapping (edit fields.json) - [ ] Step 3: Validate mapping (run validate_fields.py) - [ ] Step 4: Fill the form (run fill_form.py) - [ ] Step 5: Verify output (run verify_output.py)**Step 1: Analyze the form**Run: `python scripts/analyze_form.py input.pdf`This extracts form fields and their locations, saving to `fields.json`.**Step 2: Create field mapping**Edit `fields.json` to add values for each field.**Step 3: Validate mapping**Run: `python scripts/validate_fields.py fields.json`Fix any validation errors before continuing.**Step 4: Fill the form**Run: `python scripts/fill_form.py input.pdf fields.json output.pdf`**Step 5: Verify output**Run: `python scripts/verify_output.py output.pdf`If verification fails, return to Step 2.为什么有效?
- 🎯 清晰的步骤防止Agent跳过关键验证
- 📋 检查清单帮助Agent和用户跟踪进度
- 🔄 明确的错误处理路径
🔁 反馈循环模式:验证-修复-重复
对于质量关键的任务,实现反馈循环。
示例:文档编辑流程
## Document editing process1. Make your edits to `word/document.xml`2. **Validate immediately**: `python ooxml/scripts/validate.py unpacked_dir/`3. If validation fails: - Review the error message carefully - Fix the issues in the XML - Run validation again4. **Only proceed when validation passes**5. Rebuild: `python ooxml/scripts/pack.py unpacked_dir/ output.docx`6. Test the output document为什么有效?
- ⚡ 早期发现错误,避免后续问题
- 🤖 机器可验证,提供客观检查
- 📝 清晰的错误消息指导修复
🔀 条件工作流:根据情况选择路径
## Document modification workflow1. Determine the modification type: **Creating new content?** → Follow "Creation workflow" below **Editing existing content?** → Follow "Editing workflow" below2. Creation workflow: - Use docx-js library - Build document from scratch - Export to .docx format3. Editing workflow: - Unpack existing document - Modify XML directly - Validate after each change - Repack when complete💻 第二部分:代码和脚本的最佳实践
❓ 何时提供脚本?
提供脚本的情况:
- ⚠️ 操作脆弱且容易出错
- 🔄 需要一致性(每次执行相同)
- 💰 节省token(脚本执行不加载到上下文)
不提供脚本的情况:
- 🎯 任务灵活,需要根据上下文调整
- 🤖 Agent可以轻松生成代码
- 📝 代码很简单,不值得维护
📋 脚本设计原则
1️⃣ 原则1:解决问题,不要推给Claude
❌ 错误:推给Claude
def process_file(path): # Just fail and let Claude figure it out return open(path).read()✅ 正确:处理错误
def process_file(path): """Process a file, creating it if it doesn't exist.""" try: withopen(path) as f: return f.read() except FileNotFoundError: # Create file with default content instead of failing print(f"File {path} not found, creating default") withopen(path, 'w') as f: f.write('') return'' except PermissionError: # Provide alternative instead of failing print(f"Cannot access {path}, using default") return''2️⃣ 原则2:避免"魔法数字"
❌ 错误:未解释的常量
TIMEOUT = 47 # Why 47?RETRIES = 5 # Why 5?✅ 正确:自文档化
# HTTP requests typically complete within 30 seconds# Longer timeout accounts for slow connectionsREQUEST_TIMEOUT = 30# Three retries balances reliability vs speed# Most intermittent failures resolve by the second retryMAX_RETRIES = 33️⃣ 原则3:提供清晰的错误消息
❌ 错误:模糊的错误
if not field: raise ValueError("Invalid field")✅ 正确:具体的错误消息
if not field: raise ValueError( f"Field 'signature_date' not found. " f"Available fields: {', '.join(available_fields)}" )📋 计划-验证-执行模式
对于复杂、开放式的任务,使用这个模式来早期捕获错误。
场景:更新PDF中的50个表单字段
问题:没有验证,Agent可能:
- ❌ 引用不存在的字段
- ⚠️ 创建冲突的值
- 📋 遗漏必需字段
- 🔧 错误应用更新
解决方案:添加中间验证步骤
## Batch form update workflow1. Analyze the form: `python scripts/analyze_form.py input.pdf`2. **Create plan file**: Create `changes.json` with all updates3. **Validate plan**: `python scripts/validate_changes.py changes.json`4. If validation fails: - Review error messages - Fix issues in changes.json - Validate again5. **Only proceed when validation passes**6. Execute: `python scripts/apply_changes.py input.pdf changes.json output.pdf`7. Verify: `python scripts/verify_output.py output.pdf`为什么有效?
- ⚡ 早期捕获错误,在应用更改之前
- 🤖 机器可验证,提供客观检查
- 🔄 可逆规划,可以迭代计划而不影响原始文件
- 🐛 清晰的调试,错误消息指向具体问题
⚙️ 脚本执行 vs 参考
在Skill中明确说明脚本的用途:
执行脚本(最常见):
## Utility scripts**analyze_form.py**: Extract all form fields from PDFpython scripts/analyze_form.py input.pdf > fields.json作为参考(复杂逻辑):
## Field extraction algorithmSee `scripts/analyze_form.py` for the complete field extraction algorithm.Use this as reference when you need to understand the extraction logic.📊 第三部分:评估驱动开发
❓ 为什么先评估?
常见错误:先写大量文档,再测试
正确方法:先创建评估,再写最小化指令
为什么?
- 🎯 确保解决真实问题,而不是想象的问题
- 📈 建立基线,衡量改进效果
- 🚫 避免过度工程
评估结构
{ "skills":["pdf-processing"],"query":"Extract all text from this PDF file and save it to output.txt","files":["test-files/document.pdf"],"expected_behavior":[ "Successfully reads the PDF file using an appropriate PDF processing library", "Extracts text content from all pages without missing any pages", "Saves the extracted text to a file named output.txt in a clear, readable format"]}🔄 评估驱动开发流程
🔍 识别差距
:在没有Skill的情况下运行Claude,记录失败
📝 创建评估
:构建3个测试这些差距的场景
📊 建立基线
:测量没有Skill时的性能
✏️ 编写最小指令
:只写足够通过评估的内容
🔄 迭代
:执行评估,与基线比较,改进
示例:
1️⃣ 步骤1:识别差距
- 📋 任务:提取PDF文本
- ❌ 问题:Claude使用了错误的库,提取不完整
2️⃣ 步骤2:创建评估
{ "query": "Extract text from document.pdf", "expected": [ "Uses pdfplumber library", "Extracts all pages", "Handles encoding correctly" ]}3️⃣ 步骤3:建立基线
- 📊 成功率:40%(2/5测试通过)
4️⃣ 步骤4:编写最小指令
## Extract textUse pdfplumber:import pdfplumberwith pdfplumber.open("file.pdf") as pdf: for page in pdf.pages: text = page.extract_text()5️⃣ 步骤5:迭代
- 🧪 测试:成功率提升到80%
- 🔧 改进:添加错误处理
- ✅ 再测试:成功率100%
🤝 第四部分:与Claude协作开发Skills
❓ 为什么与Claude协作?
Claude理解:
- 📝 如何编写有效的Agent指令
- 📚 Agent需要什么信息
- 🗂️ 如何组织内容以便Agent使用
🔄 开发流程
1️⃣ 阶段1:完成任务(无Skill)
与Claude A一起完成任务,使用正常提示。注意:
- 🔁 你反复提供什么信息?
- 💡 你解释了什么偏好?
- 📚 你分享了什么流程知识?
示例:BigQuery分析任务
- 📊 提供了表名、字段定义
- 🔍 解释了过滤规则(“总是排除测试账户”)
- 📝 分享了常见查询模式
2️⃣ 阶段2:识别可复用模式
完成任务后,识别哪些上下文对类似任务有用:
- 📊 表模式
- 🏷️ 命名约定
- 🔍 过滤规则
- 📝 查询模式
3️⃣ 阶段3:让Claude创建Skill
直接要求Claude创建Skill:
"Create a Skill that captures this BigQuery analysis pattern we just used. Include the table schemas, naming conventions, and the rule about filtering test accounts."Claude理解Skill格式,会生成正确结构的内容。
4️⃣ 阶段4:审查简洁性
检查Claude是否添加了不必要的解释:
"Remove the explanation about what win rate means - Claude already knows that."5️⃣ 阶段5:改进信息架构
组织内容更有效:
"Organize this so the table schema is in a separate reference file. We might add more tables later."6️⃣ 阶段6:测试
使用Claude B(加载了Skill的新实例)测试相关用例:
- 🎯 Skill是否在预期时激活?
- 📝 指令是否清晰?
- ❓ 是否缺少什么?
7️⃣ 阶段7:迭代
如果Claude B遇到问题,返回Claude A改进:
"When Claude used this Skill, it forgot to filter by date for Q4. Should we add a section about date filtering patterns?"🔄 迭代现有Skills
同样的模式适用于改进现有Skills:
🧪 使用Skill
:给Claude B(加载了Skill)实际任务
👀 观察行为
:注意它在哪里挣扎、成功、做出意外选择
💬 返回改进
:与Claude A分享观察,请求改进
✅ 应用和测试
:更新Skill,再次测试
示例观察:
"When I asked Claude B for a regional sales report, it wrote the query but forgot to filter out test accounts, even though the Skill mentions this rule."改进请求:
"I noticed Claude B forgot to filter test accounts when I asked for a regional report. The Skill mentions filtering, but maybe it's not prominent enough?"Claude A的建议:
- 重新组织,使规则更突出
- 使用更强的语言(“MUST filter"而不是"always filter”)
- 重构工作流部分
👀 观察Claude如何使用Skills
注意:
🔍 意外的探索路径
:Claude是否以你未预期的顺序读取文件?
🔗 错过的连接
:Claude是否未能遵循重要文件的引用?
📖 过度依赖某些部分
:如果Claude反复读取同一文件,考虑是否应该放在主SKILL.md中
🚫 忽略的内容
:如果Claude从未访问某个文件,可能是不必要的或信号不足
基于这些观察迭代,而不是假设。
💡 第五部分:真实案例
📄 案例1:PDF处理Skill(完整示例)
结构:
pdf-processing/├── SKILL.md├── references/│ ├── FORMS.md│ ├── REFERENCE.md│ └── EXAMPLES.md└── scripts/ ├── analyze_form.py ├── validate_fields.py ├── fill_form.py └── verify_output.pySKILL.md:
name: pdf-processingdescription: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files.# PDF Processing## Quick startExtract text:import pdfplumberwith pdfplumber.open("file.pdf") as pdf: text = pdf.pages[0].extract_text()Advanced features
Form filling: See FORMS.md
API reference: See REFERENCE.md
Examples: See EXAMPLES.md
Workflow
See FORMS.md for complete form filling workflow.
📊 案例2:BigQuery数据分析Skill
结构:
bigquery-skill/├── SKILL.md└── reference/ ├── finance.md ├── sales.md └── product.md设计亮点:
- 🗂️ 按领域组织,按需加载
- 🎯 用户询问销售指标时,只加载
sales.md - 💰 节省token,保持上下文聚焦
🧠 案例3:Digital Brain Skill(复杂系统)
这是一个完整的个人操作系统,展示了Skills的高级应用。
三级加载模式:
L1: SKILL.md(总是加载,~50 tokens) ↓L2: MODULE.md(任务时加载,~80 tokens) ↓L3: data files(需要时加载,~200 tokens)模块隔离:
- 📦 6个独立模块(identity, content, knowledge, network, operations, agents)
- 🔄 每个模块独立加载
- 🛡️ 防止上下文污染
Token优化效果:
- 📊 优化前:~5000 tokens(加载所有内容)
- ⚡ 优化后:~650 tokens(按需加载)
- 💰 节省87%的token使用
关键设计决策:
- 📝 使用JSONL格式存储数据(append-only,易于解析)
- 📋 Schema-first设计(第一行定义结构)
- 📚 渐进式披露(三级加载)
- 🔒 模块隔离(防止上下文污染)
如何学习大模型 AI ?
由于新岗位的生产效率,要优于被取代岗位的生产效率,所以实际上整个社会的生产效率是提升的。
但是具体到个人,只能说是:
“最先掌握AI的人,将会比较晚掌握AI的人有竞争优势”。
这句话,放在计算机、互联网、移动互联网的开局时期,都是一样的道理。
我在一线互联网企业工作十余年里,指导过不少同行后辈。帮助很多人得到了学习和成长。
我意识到有很多经验和知识值得分享给大家,也可以通过我们的能力和经验解答大家在人工智能学习中的很多困惑,所以在工作繁忙的情况下还是坚持各种整理和分享。但苦于知识传播途径有限,很多互联网行业朋友无法获得正确的资料得到学习提升,故此将并将重要的AI大模型资料包括AI大模型入门学习思维导图、精品AI大模型学习书籍手册、视频教程、实战学习等录播视频免费分享出来。
第一阶段(10天):初阶应用
该阶段让大家对大模型 AI有一个最前沿的认识,对大模型 AI 的理解超过 95% 的人,可以在相关讨论时发表高级、不跟风、又接地气的见解,别人只会和 AI 聊天,而你能调教 AI,并能用代码将大模型和业务衔接。
- 大模型 AI 能干什么?
- 大模型是怎样获得「智能」的?
- 用好 AI 的核心心法
- 大模型应用业务架构
- 大模型应用技术架构
- 代码示例:向 GPT-3.5 灌入新知识
- 提示工程的意义和核心思想
- Prompt 典型构成
- 指令调优方法论
- 思维链和思维树
- Prompt 攻击和防范
- …
第二阶段(30天):高阶应用
该阶段我们正式进入大模型 AI 进阶实战学习,学会构造私有知识库,扩展 AI 的能力。快速开发一个完整的基于 agent 对话机器人。掌握功能最强的大模型开发框架,抓住最新的技术进展,适合 Python 和 JavaScript 程序员。
- 为什么要做 RAG
- 搭建一个简单的 ChatPDF
- 检索的基础概念
- 什么是向量表示(Embeddings)
- 向量数据库与向量检索
- 基于向量检索的 RAG
- 搭建 RAG 系统的扩展知识
- 混合检索与 RAG-Fusion 简介
- 向量模型本地部署
- …
第三阶段(30天):模型训练
恭喜你,如果学到这里,你基本可以找到一份大模型 AI相关的工作,自己也能训练 GPT 了!通过微调,训练自己的垂直大模型,能独立训练开源多模态大模型,掌握更多技术方案。
到此为止,大概2个月的时间。你已经成为了一名“AI小子”。那么你还想往下探索吗?
- 为什么要做 RAG
- 什么是模型
- 什么是模型训练
- 求解器 & 损失函数简介
- 小实验2:手写一个简单的神经网络并训练它
- 什么是训练/预训练/微调/轻量化微调
- Transformer结构简介
- 轻量化微调
- 实验数据集的构建
- …
第四阶段(20天):商业闭环
对全球大模型从性能、吞吐量、成本等方面有一定的认知,可以在云端和本地等多种环境下部署大模型,找到适合自己的项目/创业方向,做一名被 AI 武装的产品经理。
- 硬件选型
- 带你了解全球大模型
- 使用国产大模型服务
- 搭建 OpenAI 代理
- 热身:基于阿里云 PAI 部署 Stable Diffusion
- 在本地计算机运行大模型
- 大模型的私有化部署
- 基于 vLLM 部署大模型
- 案例:如何优雅地在阿里云私有部署开源大模型
- 部署一套开源 LLM 项目
- 内容安全
- 互联网信息服务算法备案
- …
学习是一个过程,只要学习就会有挑战。天道酬勤,你越努力,就会成为越优秀的自己。
如果你能在15天内完成所有的任务,那你堪称天才。然而,如果你能完成 60-70% 的内容,你就已经开始具备成为一名大模型 AI 的正确特征了。