Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

ai_customer_design

FreeRuns bundled scriptsNot checked

创建和修改公司培训课程、上传课程资料、查询课程并生成练习链接。触发关键词:建课、AI 客户课程、AI 设计师对话、改课、查询培训课程、生成练习链接。

infometaby infometa★ 475 GitHub stars

About this skill

公司培训课程技能(ai_customer_design)

通过 MCP 协议连接企业培训服务器,执行建课、改课、查询等操作。

工具调用方式

业务工具(training.*、organization.*)通过 agent 的宿主原生 MCP 工具直接调用。

唯一例外:文档上传(upload_document.py)必须通过脚本——agent 无法处理本地文件的 base64 编码。

连接降级规则

建课前先执行一次 ToolSearch,查 training.* 工具:

  • ✅ 查到 → 连接正常,直接建课
  • ❌ 查不到 → 立即调用 coach-mcp-connect 技能修复连接(标准链路:mcp_diagnose.py auth → 复制 Authorization header 值 → 配置 MCP client → 宿主 Trust/重连 → 走原生 MCP),禁止换名重试

⚠️ 硬规则:ToolSearch 只执行一次。禁止"换个名字再搜一次"——这不是排查手段,是浪费调用。 修复成功后重新 ToolSearch 验证,然后继续建课。

临时降级:修复后宿主仍未注册工具但建课紧急时,可临时通过脚本直连完成当次业务(call_tool()),但必须向用户声明当前使用的是脚本降级通道,非原生 MCP。修复完成后禁止继续用脚本跑业务。

AI 客户异步工具集(RFC-0014)

training.ai_customer.{create, update, update_status, get}——对标闪卡 training.flashcard.* 命名。 submit 秒返 → 无 120s 网关超时;独立 task store → 无会话保护锁死;非流式 → 无平台流式缺陷。

工具清单

工具 用途 关键参数
training.ai_customer.create 创建课程(权限分叉:管理员返回 editUrl/manageUrl,学员返回 courseId) {}

注意:create 返回的 courseName 是占位默认名(如"用户的AI客户_1234"),内容生成完成后会被 agent 按简报自动重命名,属预期行为。若在两轮之间查询看到默认名,不要误以为改名失败。 | training.ai_customer.update | 异步对话(返回 taskId,后台生成分钟级完成) | {"courseId":123,"message":"..."} | | training.ai_customer.update_status | 轮询任务状态(每 5s 一次直到 done/failed) | {"courseId":123,"taskId":"uuid"} | | training.ai_customer.get | 读取课程完整配置(需编辑权限) | {"courseId":123} |

调用模式

ai_customer.update({"courseId":123, "message":"创建药品销售课程"})
→ 秒返 {"taskId":"xxx", "conversationId":"yyy", "messageSha256":"abc...", "status":"running", "pollIntervalSeconds":5}

ai_customer.update_status({"courseId":123, "taskId":"xxx"})
→ 轮询直到 {"status":"done", "response":"...", "errorCode":0} 或 {"status":"failed", "errorCode":50002, "errorMessage":"..."}
→ done 时还可能返回 {"seriesCourseId":8001, "learnUrl":"https://..."}(学员路径自动创建系列课)

ai_customer.get({"courseId":123})
→ 返回课程完整配置(验证内容是否就绪)

约定:业务数据在 result.structuredContent 顶层(无 .data 信封);snake_case 后端字段经 camelCaseKeys 自动转 camelCase。

错误码(in-band)

HTTP 200 + code=20000 为业务成功,code≠20000 为业务失败。错误信息在 msg 字段。

码 含义 处理
40001 参数无效 检查参数(message≤8000字符、metadata键≤20)
42901 配额超限 积分配额耗尽,等待或联系管理员
42902 频率超限(10次/分钟)或在飞任务超限(≤3个) 等待后重试
43501 课程不存在 核对 courseId
43502 无编辑权限 核对权限
43503 课程正在生成中(10分钟生成锁) 等待当前任务完成
43504 任务不存在 / 已过期(TTL 2小时)/ 不属于当前用户 重新 submit
43505 fileIds 无效 检查文件
50002 agent 调用失败 等待 ≥60s → 用同义改写的消息重试 1 次(服务端按 messageSha256 去重,原文重发会被判重复提交;例如原文"请开始建课"改写为"计划没问题,请开始生成课程内容")→ 仍失败则报告并附 taskId/conversationId
50003 会话创建失败 等 60s 重试(冷却期)
50000 内部错误 报告运维

建课工作流

Step 1: training.ai_customer.create({}) → courseId
  → 管理员返回 {courseId, editUrl, manageUrl}
  → 学员返回 {courseId}(系列课延迟到内容生成后自动创建)

Step 2: training.ai_customer.update({"courseId":<id>, "message":"<课程简报>"})
  → 秒返 {"taskId":"xxx", "conversationId":"yyy", "messageSha256":"...", "status":"running", "pollIntervalSeconds":5}
  → 告知用户"建课请求已提交,预计 3-6 分钟完成"

Step 3: training.ai_customer.update_status({"courseId":<id>, "taskId":"xxx"}) 轮询
  → 每 5 秒调用一次
  → status="done" → Step 4
  → status="failed" → 读 errorMessage,决定重试或报告
  → 43504(任务过期)→ 重新 Step 2
  → ⚠️ 轮询期间全程静默,禁止询问用户"还在吗"

Step 4: training.ai_customer.get({"courseId":<id>}) → 验证课程内容
  → 检查 status="create_status_created" 且 stages.length > 0
  → ✅ 建课完成 → Step 5
  → ⚠️ 内容未就绪 → 等 30s 再查(agent 可能仍在写入),轮询最长 10 分钟

Step 5: training.task.create_open_project({"courseId":<id>}) → 拿到 link → 渲染二维码

多轮对话:Step 2-3 可重复调用。agent 可能先提问/出计划,需用户确认后再调 update 发送确认消息。

⚠️ 实测经验:首次 update 几乎必然返回计划卡片(plan card)要求确认,update_status 秒返 done 但课程并未真正创建。必须发送第二轮 update(如"确认,请直接建课。"或"确认,开始生成。")才触发实际内容生成。这是预期行为,不是错误。

时间差异:第一轮 update 秒返 done(<5s),第二轮 update 触发内容生成(3-8 分钟)。改课同理(实际修改约 3-5 分钟)。不要因第一轮秒返就认为建课完成。

轮询间隔建议:第二轮 update 后的前 2 分钟用 5s 间隔快速检查,之后可放宽到 10-15s 减少请求量。

计划卡片判定规则:update_status 返回 status=done 且 ai_customer.get 显示 stages 为空 → 视为计划卡片待确认 → 发送确认消息(如"确认,请直接建课")。

偶发:二次计划卡片:极少数情况下,第二轮确认消息返回的仍是计划卡片(stages 依然为空)。此时发送更强指令,如"计划确认无误,请立即执行建课操作,无需再确认",即可触发实际内容生成。

文件上传建课:Step 2 通过 metadata.fileIds 传递文档。先用 upload_document.py 脚本上传(见「文档上传」章节)→ 拿到 fileId → 轮询至解析完成 → 携带 fileIds 调 ai_customer.update。

并发与容量约束

约束 限制 说明
提交频率 10 次/分钟/用户 超出返回 42902
在飞任务 ≤3 个/用户 超出返回 42902
生成锁 10 分钟/课程 同课程同时只能有一个生成任务,超出返回 43503
message 长度 ≤8000 Unicode 字符 超出返回 40001
metadata 键数 ≤20 超出返回 40001(含 fileIds 算 1 个键)
任务记录 TTL 2 小时 过期后查询 status 返回 43504
running 超时 11 分钟 自动标记 failed(errorCode=50002)

批量建课:串行执行,避免超过并发限制。

建课完成的判断标准

唯一可靠判定:training.ai_customer.get 返回的 config 中 status="create_status_created" 且 stages.length > 0。

不要依赖:

  • ❌ update 的 response 文字(AI 回复可能说"建课完成"但实际未完成)
  • ❌ update_status 的 status="done"(只表示本轮对话结束,不等于课程已创建)

原则:只信 ai_customer.get 的字段值。

课程简报(Agent 内部检查清单)

建课前,Agent 必须能用一句话说清"这门课为什么对练习者有价值"——说不清则信息不足,需追问用户。

Full SKILL.md on GitHub

Install ai_customer_design in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

references/course-workflows.mdreferences/file-upload.mdreferences/result-and-progress.mdreferences/troubleshooting.mdscripts/render_qr.pyscripts/upload_document.py

FAQ

What does the ai_customer_design skill do?

创建和修改公司培训课程、上传课程资料、查询课程并生成练习链接。触发关键词:建课、AI 客户课程、AI 设计师对话、改课、查询培训课程、生成练习链接。

How do I install the ai_customer_design skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the ai_customer_design skill run scripts?

Yes, this skill bundles executable scripts. Review the source before installing.

Related skills

Compare ai_customer_design with