关于 ask-user-question
ask-user-question 是通过 UI 模态框向用户提问并接收回答的技能,适用于需要澄清需求、获取偏好或在继续前征求批准的 Agent。
主要功能
- 01在 UI 模态框显示问题
- 02提供可选回答
- 03接收自定义文本
- 04返回用户选择
适用场景
- 01澄清含糊的任务要求
- 02整理文件前收集偏好
- 03执行敏感或破坏性操作前确认
MCP 相关
该技能说明通过 MCP 工具向用户提问并接收回答。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ memtensor/ memos --skill ask-user-question安装后在 Claude Code 中输入/ask-user-question确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
package-lock.jsonpackage.jsontsconfig.jsonsrc/index.ts详细介绍
询问用户问题
使用此 MCP 工具向用户提问并获取回复。这是与用户沟通的唯一方式——他们看不到 CLI/终端输出。
重要规则
用户看不到你的文本输出或 CLI 提示!
如果你写下“让我问问你……”之类的话,然后只输出文本——用户将看不到这些内容。 你必须调用此工具,在 UI 中显示模态框。
使用时机
- 在开始有歧义的任务前提出澄清问题
- 询问用户的偏好(例如:“你希望如何组织文件?”)
- 执行操作前征求确认(尤其是具有破坏性或不可逆的操作)
- 为敏感操作获取批准(财务、消息发送、删除等)
- 任何需要用户输入才能继续的情况
参数
{
"questions": [{
"question": "Your question to the user",
"header": "Short label (max 12 chars)",
"options": [
{ "label": "Option 1", "description": "What this does" },
{ "label": "Option 2", "description": "What this does" }
],
"multiSelect": false
}]
}
question(必需):要显示的问题文本header(可选):简短的类别标签,显示为模态框标题(最多 12 个字符)options(可选):可选选项数组(建议 2–4 个)multiSelect(可选):是否允许多选(默认:false)
自定义文本输入: 若要允许用户输入自定义回复,请添加一个标签为 "Other"(不区分大小写)的选项。选中后,UI 会显示文本输入框。
{ "label": "Other", "description": "Type your own response" }
重要: 选择 "Other" 后,回复将是 User responded: [their text],而不是 User selected: Other。你必须等待并处理此文本回复——不要将其视为用户选择了预设选项并继续操作。
示例
询问文件组织偏好
AskUserQuestion({
"questions": [{
"question": "How would you like to organize your Downloads folder?",
"header": "Organize",
"options": [
{ "label": "By file type", "description": "Group into Documents, Images, Videos, etc." },
{ "label": "By date", "description": "Group by month/year" },
{ "label": "By project", "description": "You'll help me name project folders" }
]
}]
})
确认破坏性操作
AskUserQuestion({
"questions": [{
"question": "Delete these 15 duplicate files?",
"header": "Confirm",
"options": [
{ "label": "Delete all", "description": "Remove all 15 duplicates" },
{ "label": "Review first", "description": "Show me the list before deleting" },
{ "label": "Cancel", "description": "Don't delete anything" }
]
}]
})
简单的是/否确认
AskUserQuestion({
"questions": [{
"question": "Should I proceed with sending this email?",
"header": "Send email",
"options": [
{ "label": "Send", "description": "Send the email now" },
{ "label": "Cancel", "description": "Don't send" }
]
}]
})
回复格式
工具会返回用户的选择:
User selected: By file type——单选User selected: Option A, Option B——多选(如果multiSelect: true)User responded: [custom text]——如果用户输入了自定义回复User declined to answer the question.——如果用户关闭了模态框
错误与正确示例
错误(用户看不到):
I'll help organize your files. How would you like them organized?
- By type
- By date
- By project
正确(用户会看到模态框):
AskUserQuestion({
"questions": [{
"question": "How would you like your files organized?",
"options": [
{ "label": "By type" },
{ "label": "By date" },
{ "label": "By project" }
]
}]
})
评论
支持 Markdown