什么是 Claude Code 的 AskUserQuestion 工具?如何将其用于基于规格的开发🧣

456 阅读8分钟

What is Claude Code's AskUserQuestion tool? How to use it for spec-based development 什么是 Claude Code 的 AskUserQuestion 工具?如何将其用于基于规格的开发

www.atcyrus.com/stories/cla…

What is Claude Code's AskUserQuestion tool? How to use it for spec-based development

Connor Turland  康纳·特兰·December 29, 2025  2025年12月29日·Copy link  复制链接

The AskUserQuestion tool is quietly becoming one of the most powerful features in Claude Code. Instead of making assumptions and potentially going down the wrong path, Claude can now pause and ask you directly what you want - presenting clear options and gathering the context it needs to do the job right.
AskUserQuestion 工具正悄悄成为 Claude Code 中最强大的功能之一。Claude 现在可以停下来,直接问你想要什么——提供清晰的选项,收集完成任务所需的背景。

This approach - letting Claude interview you to build a spec before executing - is transforming how developers work with AI coding assistants.
这种方式——让 Claude 面试你在执行前构建规格——正在改变开发者与 AI 编码助手的合作方式。

What is Claude Code's AskUserQuestion tool? 什么是 Claude Code 的 AskUserQuestion 工具?

The AskUserQuestion tool allows Claude Code to present you with questions and multiple-choice options during a coding session. Instead of guessing or making assumptions, Claude can pause, ask for clarification, and continue with confidence once you've provided direction.
AskUserQuestion 工具允许 Claude Code 在编程会话中为你呈现问题和多项选择选项。克劳德不再猜测或做假设,而是可以暂停,询问澄清,并在你给出指导后自信地继续。

Here's what it looks like in action in the Claude Code CLI:
以下是它在 Claude Code CLI 中实际作的样子:

Claude Code CLI showing AskUserQuestion tool with multiple options转存失败,建议直接上传图片文件

Notice the multi-step selection interface. Claude presents a question, provides clear options with descriptions, and waits for your input before proceeding. This is the foundation of spec-based development.
注意多步选择界面。Claude 会提出问题,提供清晰的选项和描述,然后等待你的反馈后继续。这就是基于规格开发的基础。

The problem it solves: AI assumptions gone wrong 它解决的问题:人工智能假设出错

Every developer who's used AI coding assistants knows this pain:
每个使用过 AI 编码助理的开发者都经历过这种痛苦:

  1. You give Claude a task
    你给克洛德一个任务
  2. Claude makes assumptions about implementation details
    Claude 对实现细节做出假设
  3. You end up with code that technically works but doesn't match what you actually needed
    你最终得到的代码技术上能用,但并不符合你实际需要的
  4. You spend time correcting course or starting over
    你花时间纠正方向或重新开始

The AskUserQuestion tool eliminates this cycle.  When Claude encounters ambiguity - whether it's about architecture, implementation approach, or even just which port your application runs on - it asks rather than assumes.
AskUserQuestion 工具消除了这一循环。  当 Claude 遇到模糊之处——无论是架构、实现方法,还是应用运行的端口——它会提出问题,而不是假设。

This pairs perfectly with Plan mode. First, let Claude interview you to build a spec. Then execute with confidence.
这与计划模式完美搭配。首先,让 Claude 面试你来制定规格。然后自信地执行。

How it works: the interview-then-execute pattern 工作原理:面试后执行模式

The most effective way to use AskUserQuestion is what developers are calling spec-based development:
使用 AskUserQuestion 最有效的方式是开发者所称的基于规格的开发

Phase 1: The interview  第一阶段:面试

Start with a minimal prompt like:
从一个简短的提示开始,比如:

"I want to add user authentication to my app. Interview me to build a spec."
“我想在我的应用里添加用户认证。采访我,打造一个规格。”

Claude will then ask targeted questions:
随后,Claude 将提出针对性问题:

  • What authentication method do you prefer? (OAuth, JWT, session-based)
    你更喜欢用哪种认证方式?(OAuth,JWT,基于会话)
  • Which providers should be supported? (Google, GitHub, email/password)
    哪些服务提供者应该被支持?(谷歌,GitHub,邮箱/密码)
  • Do you need role-based access control?
    你需要基于角色的访问控制吗?
  • What should happen when a session expires?
    会话结束时应该发生什么?

Each question comes with sensible options based on your codebase context.
每个问题都会根据你的代码库上下文提供合理的选项。

Phase 2: The spec  第二阶段:规格

After gathering your answers, Claude produces a detailed specification document - a clear plan of exactly what will be built and how.
收集完答案后,Claude 会制作一份详细的规格文件——一份明确的计划,明确说明将建造什么以及如何建造。

Phase 3: Execution  第三阶段:处决

Start a new session with the spec as context. Claude executes with precision because all the ambiguity has been resolved upfront.
以该专精作为上下文,重新开始一个新会话。克洛德执行得非常精准,因为所有模糊性都被一开始就解决了。

The result?  Code that matches your intent on the first try. The ask user question tool makes this possible by front-loading all the decision-making.
结果呢?  第一次尝试就能符合你意图的代码。“问用户提问”工具通过提前加载所有决策实现了这一点。

Using AskUserQuestion in Linear with Cyrus 用 Cyrus 在线性中使用 AskUserQuestion

Here's where things get interesting. When you combine the AskUserQuestion tool with Linear issue tracking through Cyrus, you get a collaborative development workflow that works asynchronously.
事情从这里开始变得有趣。当你将 AskUserQuestion 工具与 Cyrus 的线性问题跟踪结合起来时,你会得到一个异步协作的开发流程。

When Cyrus picks up a Linear issue and needs clarification, it doesn't just stop or make guesses. It asks you directly in Linear:
当赛勒斯拿起线性问题需要澄清时,它不会停下来或猜测。它直接用线性方式问你:

Linear issue showing Cyrus asking a question with multiple choice options

Look at the Activity section. Cyrus has moved the issue to "Needs input" and is asking a specific question: "When the Cyrus service is busy, how should the restart behave?"
看看活动部分。Cyrus 已将问题移至“需要输入”,并提出了一个具体问题:“当 Cyrus 服务忙碌时,重启应如何表现?”

The options are clear and actionable:
选项清晰且可执行:

  • Wait and retry: Poll /status repeatedly until idle, then restart
    等待并重试:反复轮询/status 直到空闲,然后重启
  • Fail immediately: Return an error immediately if busy, let the caller handle it
    立即失败:如果忙碌,立即返回错误,让呼叫者处理
  • Queue for later: Schedule restart as a background task that triggers once service becomes idle
    待会儿排队:将重启计划作为后台任务,服务空闲时触发

You can respond right in Linear by selecting an option from the dropdown:
你可以直接在线性中选择下拉菜单中的选项来回复:

Linear dropdown showing filter options for answering Cyrus

Why this matters for teams 为什么这对球队很重要

The Linear integration transforms AskUserQuestion from a local development tool into a team collaboration feature:
线性集成将 AskUserQuestion 从本地开发工具转变为团队协作功能

  • Asynchronous development: Cyrus works while you're in meetings, asks questions when it needs to, and you respond when you're available
    异步开发 :Cyrus 在你开会时工作,需要时提问,你有空时回复
  • Context preservation: The question and answer become part of the issue history
    上下文保持 :问题和答案成为问题历史的一部分
  • Team visibility: Anyone on the team can see what questions were asked and how decisions were made
    团队可见性:团队中的任何人都能看到被问了哪些问题以及决策的过程
  • No context switching: Answer questions directly in Linear without switching to a terminal
    无上下文切换 :直接用线性回答问题,无需切换到终端

The bigger picture  更宏观的局面

For years, we've obsessed over prompt engineering - crafting the perfect instructions to get AI to do what we want. The AskUserQuestion tool quietly inverts this relationship. Now the model prompts you.
多年来,我们一直痴迷于提示工程——精心设计完美的指令,让 AI 按照我们的意愿行动。AskUserQuestion 工具悄然颠覆了这种关系。现在模型会提示

And it turns out that's exactly what we needed.
事实证明,这正是我们所需要的。

When Claude asks "Should this API fail fast or retry with backoff?" before writing a single line of code, something interesting happens: tradeoffs become explicit. Instead of discovering buried assumptions during code review, you confront design decisions upfront, when they're cheap to change.
当 Claude 在写一行代码前问“这个 API 应该快速失败还是用 backoff 重试?”时,有趣的事情发生了:权衡变得显而易见。你不会在代码审查时发现隐藏的假设,而是在设计决策便宜修改时直接面对。

This creates a choose-your-own-adventure pathway through product development. Each question is a fork in the road. Each answer narrows the solution space. By the time Claude starts coding, you've already navigated the decision tree together - and you have a clear record of every choice you made along the way.
这为产品开发创造了一条选择你自己的冒险路径。每个问题都是人生的分岔路口。每个答案都会缩小解的范围。等 Claude 开始写代码时,你们已经一起导航了决策树——而且你对自己一路上做的每一个选择都有清晰的记录。

Why this matters for 2026 and beyond:
为什么这对2026年及以后很重要:

As AI agents become more capable, the bottleneck shifts from "can the AI do this?" to "does the AI understand what I actually want?" The teams that figure out human-AI collaboration patterns early will have a significant advantage.
随着人工智能代理的能力提升,瓶颈从“人工智能能做到吗?”转变为“人工智能是否真正理解我想要什么?”能够及早发现人机协作模式的团队将拥有显著优势。