ask_clarification
Ask targeted questions to clarify user requirements and improve the prompt engineering process, ensuring accurate and optimized outputs for Claude Code.
Instructions
Ask clarifying questions to better understand user requirements and refine the prompt engineering process.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| questions | Yes | List of clarifying questions to ask the user | |
| sessionId | Yes | The session ID for this prompt engineering session |
Implementation Reference
- index.ts:625-638 (handler)The handler function for the 'ask_clarification' tool. Validates arguments using isClarificationArgs, then formats and returns the clarifying questions to the user with instructions to use answer_questions tool.case "ask_clarification": { if (!isClarificationArgs(args)) { throw new Error("Invalid arguments for ask_clarification"); } const { sessionId, questions } = args; return { content: [{ type: "text", text: `Please answer these clarifying questions:\n\n${questions.map((q, i) => `${i + 1}. ${q}`).join('\n')}\n\nUse the answer_questions tool with session ID "${sessionId}" when ready.` }], isError: false, }; }
- index.ts:58-73 (schema)Input schema definition for the 'ask_clarification' tool, specifying sessionId and questions array as required parameters.inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "The session ID for this prompt engineering session" }, questions: { type: "array", items: { type: "string" }, description: "List of clarifying questions to ask the user" } }, required: ["sessionId", "questions"], title: "ask_clarificationArguments" }
- index.ts:570-572 (registration)Registers the 'ask_clarification' tool (via ASK_CLARIFICATION_TOOL constant) in the list of available tools returned by ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ENGINEER_PROMPT_TOOL, ASK_CLARIFICATION_TOOL, ANSWER_QUESTIONS_TOOL, AUTO_OPTIMIZE_TOOL], }));
- index.ts:151-163 (helper)Type guard helper function to validate and type-check the arguments passed to the 'ask_clarification' tool handler.function isClarificationArgs(args: unknown): args is { sessionId: string; questions: string[]; } { return ( typeof args === "object" && args !== null && "sessionId" in args && typeof (args as { sessionId: string }).sessionId === "string" && "questions" in args && Array.isArray((args as { questions: string[] }).questions) ); }