Skip to content

feat: use Claude Code's native AskUserQuestion for /clarify and /checklist#2191

Open
0xrafasec wants to merge 1 commit intogithub:mainfrom
0xrafasec:feat/claude-ask-user-question
Open

feat: use Claude Code's native AskUserQuestion for /clarify and /checklist#2191
0xrafasec wants to merge 1 commit intogithub:mainfrom
0xrafasec:feat/claude-ask-user-question

Conversation

@0xrafasec
Copy link
Copy Markdown

@0xrafasec 0xrafasec commented Apr 12, 2026

Summary

Replaces the Markdown-table question rendering in /clarify and /checklist with Claude Code's native AskUserQuestion structured picker, while preserving the original table behavior for all other agents.

Closes #2181

What changed

  • Templates: Added HTML-comment fence markers (<!-- speckit:question-render:begin/end -->) around the question-rendering blocks in clarify.md and checklist.md. The markers are invisible to non-Claude agents — zero behavior change for them.
  • ClaudeIntegration: Extended setup() to post-process the fenced blocks at skill-generation time, following the same pattern used for argument-hint, user-invocable, and disable-model-invocation injection.
  • Schema mapping (documented inline):
    • /clarify's Option | DescriptionAskUserQuestion's {label, description}
    • /checklist's Option | Candidate | Why It Matters{label: Candidate, description: Why It Matters}
  • Recommended option placed first in options[] with Recommended — <reasoning> prefix.
  • Free-form escape hatch preserved as a final synthetic option ("Provide my own short answer (≤5 words)").
  • All downstream behavior unchanged: question caps (5 for clarify, 3-initial/5-total for checklist), validation pass, incremental spec writes, Q1–Q5 labeling.

Files changed

File Change
templates/commands/clarify.md +2 lines (fence markers)
templates/commands/checklist.md +2 lines (fence markers)
src/specify_cli/integrations/claude/__init__.py +76 lines (post-processor + replacement blocks)
tests/integrations/test_integration_claude.py +164 lines (9 new tests across 3 test classes)

Test results

  • 28/28 Claude integration tests pass (19 existing + 9 new)
  • 1246/1246 full test suite passes (18 skipped, unchanged from main)
  • Zero regressions

AI assistance disclosure

This PR was developed with assistance from Claude Code (Claude Opus 4.6). I reviewed, tested, and verified all changes manually. The implementation strategy follows the approach proposed in #2181 and matches the existing ClaudeIntegration post-processing patterns.

Test plan

  • All existing tests pass (uv run python -m pytest tests/ -q)
  • New tests verify Claude skills contain AskUserQuestion and not the original tables
  • New tests verify non-Claude integrations don't contain AskUserQuestion
  • New tests verify downstream behavior preservation (caps, validation, labeling)
  • New unit tests for replace_question_render_block() (no-fence passthrough, basic replacement)
  • Manual end-to-end verification: /speckit.clarify and /speckit.checklist inside Claude Code

🤖 Generated with Claude Code

…klist

Replace Markdown-table question rendering with Claude Code's native
AskUserQuestion structured picker in speckit-clarify and speckit-checklist
skills, while preserving the original table behavior for all other agents.

- Add HTML-comment fence markers (speckit:question-render:begin/end) around
  the question-rendering blocks in clarify.md and checklist.md templates
- Extend ClaudeIntegration.setup() to post-process fenced blocks at skill
  generation time, replacing them with AskUserQuestion instructions
- Map Option|Description (clarify) and Option|Candidate|Why It Matters
  (checklist) to AskUserQuestion's {label, description} shape
- Place recommended option first with "Recommended — <reasoning>" prefix
- Preserve free-form escape hatch as a final synthetic option
- All downstream behavior unchanged: question caps, validation, spec writes
- Non-Claude integrations output is completely unaffected

Closes github#2181

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the /clarify and /checklist command templates to support Claude Code’s native AskUserQuestion structured picker by fencing the question-rendering blocks in the templates and post-processing them during Claude skill generation, while leaving non-Claude integrations functionally unchanged.

Changes:

  • Added HTML comment fence markers around question-rendering sections in clarify.md and checklist.md.
  • Extended ClaudeIntegration.setup() to replace fenced blocks with AskUserQuestion-based instructions for the Claude-generated skills.
  • Added Claude integration tests covering replacement behavior, parity expectations, and basic downstream behavior preservation checks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
templates/commands/clarify.md Adds begin/end fence markers around the clarify question-rendering rules block.
templates/commands/checklist.md Adds begin/end fence markers around the checklist question-formatting rules block.
src/specify_cli/integrations/claude/__init__.py Adds fenced-block replacement logic and AskUserQuestion replacement instructions for clarify/checklist at skill generation time.
tests/integrations/test_integration_claude.py Adds tests ensuring Claude output uses AskUserQuestion, and that non-Claude outputs do not.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

re.escape(_QUESTION_FENCE_BEGIN) + r".*?" + re.escape(_QUESTION_FENCE_END),
re.DOTALL,
)
return pattern.sub(replacement, content, count=1)
_CHECKLIST_ASK_USER = """\
Question formatting rules:
- If presenting options, use the `AskUserQuestion` tool to present a native structured picker:
- `question`: the clarification question text
Comment on lines 136 to 139
4. Sequential questioning loop (interactive):
- Present EXACTLY ONE question at a time.
<!-- speckit:question-render:begin -->
- For multiple‑choice questions:
Comment on lines +96 to +102
<!-- speckit:question-render:begin -->
Question formatting rules:
- If presenting options, generate a compact table with columns: Option | Candidate | Why It Matters
- Limit to A–E options maximum; omit table if a free-form answer is clearer
- Never ask the user to restate what they already said
- Avoid speculative categories (no hallucination). If uncertain, ask explicitly: "Confirm whether X belongs in scope."
<!-- speckit:question-render:end -->
clarify_files = [
f for f in created
if "clarify" in f.name.lower() or "clarify" in str(f.parent).lower()
]
Comment on lines +562 to +563
# The fence is invisible HTML comments — just verify no
# AskUserQuestion was injected
Comment on lines +490 to +491
assert "5" in content
assert "maximum" in content.lower() or "Maximum" in content
Comment on lines +507 to +508
assert "THREE" in content or "three" in content.lower()
assert "Q1" in content or "Q4" in content or "Q5" in content
Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please deliver this as a preset similar to how it was done for VSCode (see https://github.com/github/spec-kit/tree/main/presets and foto see how it was done for VSCode see https://github.com/fdcastel/spec-kit-presets/tree/main/vscode-ask-questions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Use Claude Code's native AskUserQuestion tool instead of numbered-option prompts

3 participants