Comment déclencher des questions interactives dans OpenCode et ClaudeCode ?
Journal du vendredi 08 mai 2026 à 15:19
Cela fait plusieurs mois que je me demande comment fonctionne le mécanisme de questions interactives présent dans OpenCode et Claude Code.
Plus précisément, je me demande comment je peux déclencher, de manière certaine, des questions interactives dans mes SKILLS.md.
Dans cet exemple :
> Pose-moi la question pour savoir si je suis une femme ou un homme.
Es-tu une femme ou un homme ?
OpenCode ne me pose pas cette question de manière interactive, la question est posée sous la forme de "texte libre".
J'ai cherché à en savoir plus et voici ce que j'ai trouvé.
Le mécanisme de questions interactives est déclenché par un tool.
- Chez Claude Code, ce tool est nommé "
AskUserQuestion" - Et chez OpenCode, ce tool est nommé simplement "
question"
Et voici le contenu des descriptions de ces tools (qui jouent le rôle de prompt) :
- Pour OpenCode : https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/tool/question.txt
Use this tool when you need to ask the user questions during execution. This allows you to:
1. Gather user preferences or requirements
2. Clarify ambiguous instructions
3. Get decisions on implementation choices as you work
4. Offer choices to the user about what direction to take.
Usage notes:
- When `custom` is enabled (default), a "Type your own answer" option is added automatically; don't include "Other" or catch-all options
- Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
- Pour Claude Code : https://github.com/Piebald-AI/claude-code-system-prompts/blob/main/system-prompts/tool-description-askuserquestion.md
Use this tool when you need to ask the user questions during execution. This allows you to:
1. Gather user preferences or requirements
2. Clarify ambiguous instructions
3. Get decisions on implementation choices as you work
4. Offer choices to the user about what direction to take.
Usage notes:
- Users will always be able to select "Other" to provide custom text input
- Use multiSelect: true to allow multiple answers to be selected for a question
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool to ask "Is my plan ready?" or "Should I proceed?" - use ${EXIT_PLAN_MODE_TOOL_NAME} for plan approval. IMPORTANT: Do not reference "the plan" in your questions (e.g., "Do you have feedback about the plan?", "Does the plan look good?") because the user cannot see the plan in the UI until you call ${EXIT_PLAN_MODE_TOOL_NAME}. If you need plan approval, use ${EXIT_PLAN_MODE_TOOL_NAME} instead.
Aucun des deux prompts ne dit quand ne pas poser les questions en texte libre. Les deux disent "use this tool when you need to ask questions" — mais le modèle juge lui-même si la situation justifie le tool ou une réponse textuelle directe.
Pour être certain que l'agent IA pose une question en mode interactif, il faut lui demander explicitement de l'utiliser, par exemple, avec la mention (use question tool) ou dans cet exemple :
Utilise le tool question pour me poser deux questions :
1. Mon sexe (homme, femme, autre)
2. Mon prénom, avec "Stéphane" comme première option suggérée, et une option pour saisir autre chose
Autres ressources :
- Le code source du tool
questionde OpenCode : https://github.com/anomalyco/opencode/blob/e3c983c21f925fef4b03f46a06663f1b29cfed34/packages/opencode/src/tool/question.ts - https://github.com/vtemian/octto - un plugin permettant de créer des formulaires avancés, avec gestion de branches et 14 types de saisie. À noter : l'interface s'ouvre dans un navigateur, ce qui casse le flux TUI.