Full research cycle — refines query, calls Gemini Deep Research, polls, delivers report. Combines /research-request + /research-respond. Triggers: "research this topic", "run a research cycle", "call Gemini Deep Research".
Full research cycle — refines query, calls Gemini Deep Research, polls, delivers report. [!!!] CRITICAL BOOT SEQUENCE:
~/.claude/directives/COMMANDS.md, ~/.claude/directives/INVARIANTS.md, and ~/.claude/directives/TAGS.md.¶INV_SKILL_PROTOCOL_MANDATORY.Output this block in chat with every blank filled:
Boot proof:
- COMMANDS.md — §CMD spotted:
________- INVARIANTS.md — ¶INV spotted:
________- TAGS.md — §FEED spotted:
________
[!!!] If ANY blank above is empty: STOP. Go back to step 1 and load the missing file. Do NOT read Phase 0 until every blank is filled.
[!!!] DO NOT USE THE BUILT-IN PLAN MODE (EnterPlanMode tool). This protocol has its own planning system — Phase 2 (Interrogation / Query Refinement). The engine's artifacts live in the session directory as reviewable files, not in a transient tool state. Use THIS protocol's phases, not the IDE's.
Intent: Execute §CMD_REPORT_INTENT_TO_USER.
- I am starting Phase 0: Setup phase.
- I will
§CMD_USE_ONLY_GIVEN_CONTEXTfor Phase 0 only (Strict Bootloader — expires at Phase 1).- My focus is RESEARCH (
§CMD_REFUSE_OFF_COURSEapplies).- I will
§CMD_LOAD_AUTHORITY_FILESto ensure all templates and standards are loaded.- I will
§CMD_FIND_TAGGED_FILESto identify active alerts (#active-alert).- I will
§CMD_PARSE_PARAMETERSto define the flight plan.- I will
§CMD_MAINTAIN_SESSION_DIRto establish working space.- I will
§CMD_ASSUME_ROLEto execute better: Role: You are the Research Strategist. Goal: To craft a precise research question, get it answered by Gemini Deep Research, and deliver the result. Mindset: A good research question is half the answer. Spend time refining before firing.- I will obey
§CMD_NO_MICRO_NARRATIONand¶INV_CONCISE_CHAT(Silence Protocol).
Constraint: Do NOT read any project files (source code, docs) in Phase 0. Only load the required system templates/standards.
Required Context: Execute §CMD_LOAD_AUTHORITY_FILES (multi-read) for the following files:
~/.claude/skills/research-request/SKILL.md (Request posting protocol — Phase 3 reuses steps)~/.claude/skills/research-respond/assets/TEMPLATE_RESEARCH_RESPONSE.md (Template for the response document)~/.claude/skills/research-request/assets/TEMPLATE_RESEARCH_LOG.md (Template for session logging)Parse parameters: Execute §CMD_PARSE_PARAMETERS - output parameters to the user as you parsed it.
Session Location: Execute §CMD_MAINTAIN_SESSION_DIR - ensure the directory is created.
Scope: Understand the [Topic] and [Goal].
Output this block in chat with every blank filled:
Phase 0 proof:
- Role:
________- Session dir:
________- Templates loaded:
________,________- Parameters parsed:
________
Phase 0 always proceeds to Phase 1 — no transition question needed.
Load relevant materials before refining the query.
Intent: Execute §CMD_REPORT_INTENT_TO_USER.
- I am moving to Phase 1: Context Ingestion.
- I will
§CMD_INGEST_CONTEXT_BEFORE_WORKto ask for and loadcontextPaths.
Action: Execute §CMD_INGEST_CONTEXT_BEFORE_WORK.
Output this block in chat with every blank filled:
Phase 1 proof:
- RAG session-search:
________ resultsorunavailable- RAG doc-search:
________ resultsorunavailable- Files loaded:
________ files- User confirmed:
yes / no
Execute §CMD_TRANSITION_PHASE_WITH_OPTIONAL_WALKTHROUGH:
completedPhase: "1: Context Ingestion"
nextPhase: "2: Query Refinement"
prevPhase: "0: Setup"
custom: "Skip to 3: Execute Research | Question is already well-defined, skip refinement"
Refine the research question through structured dialogue.
Intent: Execute §CMD_REPORT_INTENT_TO_USER.
- I am moving to Phase 2: Query Refinement.
- I will
§CMD_EXECUTE_INTERROGATION_PROTOCOLto refine the research question.- I will
§CMD_LOG_TO_DETAILSto capture the Q&A.- If I get stuck, I'll
§CMD_ASK_USER_IF_STUCK.
Before asking any questions, present this choice via AskUserQuestion (multiSelect: false):
"How deep should query refinement go?"
| Depth | Minimum Rounds | When to Use |
|---|---|---|
| Short | 3+ | Question is mostly clear, just needs minor sharpening |
| Medium | 6+ | Moderate ambiguity, multiple angles to consider |
| Long | 9+ | Complex multi-faceted topic, many constraints |
| Absolute | Until ALL questions resolved | Novel domain, high-stakes research, zero ambiguity tolerance |
Record the user's choice. This sets the minimum — the agent can always ask more, and the user can always say "proceed" after the minimum is met.
[!!!] CRITICAL: You MUST complete at least the minimum rounds for the chosen depth. Track your round count visibly.
Round counter: Output it on every round: "Round N / {depth_minimum}+"
Topic selection: Pick from the topic menu below each round. Do NOT follow a fixed sequence — choose the most relevant uncovered topic based on what you've learned so far.
Examples of themes to explore. Adapt to the task — skip irrelevant ones, invent new ones as needed.
Standard topics (typically covered once):
Repeatable topics (can be selected any number of times):
Each round:
§CMD_ASK_ROUND_OF_QUESTIONS via AskUserQuestion (3-5 targeted questions on that topic).§CMD_LOG_TO_DETAILS immediately.§CMD_APPEND_LOG_VIA_BASH_USING_TEMPLATE.If this is a follow-up: Also ask which previous response to continue from. Read it to extract the Interaction ID.
After reaching minimum rounds, present this choice via AskUserQuestion (multiSelect: true):
"Round N complete (minimum met). What next?"
- "Proceed to Phase 3: Execute Research" — (terminal: if selected, skip all others and move on)
- "More interrogation (3 more rounds)" — Standard topic rounds, then this gate re-appears
- "Devil's advocate round" — 1 round challenging assumptions, then this gate re-appears
- "What-if scenarios round" — 1 round exploring hypotheticals, then this gate re-appears
- "Deep dive round" — 1 round drilling into a prior topic, then this gate re-appears
Execution order (when multiple selected): Standard rounds first → Devil's advocate → What-ifs → Deep dive → re-present exit gate.
For Absolute depth: Do NOT offer the exit gate until you have zero remaining questions. Ask: "Round N complete. I still have questions about [X]. Continuing..."
Output this block in chat with every blank filled:
Phase 2 proof:
- Depth chosen:
________- Rounds completed:
________/________+- DETAILS.md entries:
________- Research question defined:
________
Create the request document, then immediately fulfill it.
Intent: Execute §CMD_REPORT_INTENT_TO_USER.
- I am moving to Phase 3: Research Execution.
- I will post the request document for traceability.
- I will call Gemini Deep Research and poll for results.
Before calling any tool, ask yourself:
Have I made 2+ tool calls since my last log entry?
→ YES: Log NOW before doing anything else. This is not optional.
→ NO: Proceed with the tool call.
[!!!] If you make 3 tool calls without logging, you are FAILING the protocol. The log is your brain — unlogged work is invisible work.
Execute Phase 3 (steps 1-3) of ~/.claude/skills/research-request/SKILL.md to create the request document, tag it with #needs-research, and log the posting. Use the interrogation context already gathered in Phase 2 above — do not re-interrogate.
[session-dir]/research_raw_output.txt — temporary file for the script's raw output.~/.claude/scripts/research.sh <output-path> <<'EOF'
[composed research prompt]
EOF
~/.claude/scripts/research.sh --continue <interaction-id> <output-path> <<'EOF'
[composed follow-up prompt]
EOF
run_in_background: true. Note the task ID from the background task.The script writes INTERACTION_ID=<id> to the output file immediately (before polling starts). After a short wait (~5 seconds), read the output file to extract the ID.
INTERACTION_ID=<id>.~/.claude/scripts/log.sh "$REQUEST_FILE" <<'EOF'
## Active Research
* **Interaction ID**: `[interaction-id]`
* **Started**: [YYYY-MM-DD HH:MM:SS]
EOF
#needs-research → #claimed-research on the request file:
~/.claude/scripts/tag.sh swap "$REQUEST_FILE" '#needs-research' '#claimed-research'
This marks the request as in-flight. If this session dies, another agent can find #claimed-research requests, read the Interaction ID, and resume polling.[id]. Watching for results via §CMD_AWAIT_TAG."§CMD_AWAIT_TAG (file mode) on the request file for #done-research:
Bash("~/.claude/scripts/await-tag.sh $REQUEST_FILE '#done-research'", run_in_background=true)
The research.sh script (launched in Step 2) handles polling Gemini, writing the response, and swapping the tag. await-tag.sh detects the tag swap and signals the agent.#claimed-research tag + Interaction ID on the request file means /research-respond can pick it up in a future session.INTERACTION_ID=<id>. Remaining lines are the report.~/.claude/skills/research-respond/assets/TEMPLATE_RESEARCH_RESPONSE.md with the interaction ID, original request path, and full report. Save as RESEARCH_RESPONSE_[TOPIC].md.## Response section to the request file via log.sh.#claimed-research → #done-research on the request file:
~/.claude/scripts/tag.sh swap "$REQUEST_FILE" '#claimed-research' '#done-research'
research_raw_output.txt.Output this block in chat with every blank filled:
Phase 3 proof:
- Request created and tagged:
________- Gemini called:
________- Interaction ID captured:
________- Response saved:
________- Tag lifecycle complete:
________- Raw output cleaned:
________
Execute §CMD_TRANSITION_PHASE_WITH_OPTIONAL_WALKTHROUGH:
completedPhase: "3: Execute Research"
nextPhase: "4: Present Results"
prevPhase: "2: Query Refinement"
Show the research results and close the session.
1. Announce Intent
Execute §CMD_REPORT_INTENT_TO_USER.
- I am moving to Phase 4: Present Results.
- I will
§CMD_PROCESS_CHECKLISTSto process any discovered CHECKLIST.md files.- I will present the research report.
- I will
§CMD_REPORT_RESULTING_ARTIFACTSto list outputs.- I will
§CMD_REPORT_SESSION_SUMMARYto provide a concise session overview.
STOP: Do not create artifacts yet. You must output the block above first.
2. Execution — SEQUENTIAL, NO SKIPPING
[!!!] CRITICAL: Execute these steps IN ORDER. Do NOT skip to step 4 or 5 without completing step 1.
Step 0 (CHECKLISTS): Execute §CMD_PROCESS_CHECKLISTS — process any discovered CHECKLIST.md files. Read ~/.claude/directives/commands/CMD_PROCESS_CHECKLISTS.md for the algorithm. Skips silently if no checklists were discovered. This MUST run before the debrief to satisfy ¶INV_CHECKLIST_BEFORE_CLOSE.
Step 1 (THE DELIVERABLE): Present the research report in chat so the user can read it immediately.
Step 2: Log a Research Complete entry via §CMD_APPEND_LOG_VIA_BASH_USING_TEMPLATE.
Step 3: Archive to Docs (Optional) — Ask the user if they want to copy the research to a project docs directory for permanent reference.
AskUserQuestion with options:
packages/[pkg]/docs/research/ or docs/research/)mkdir -p).Step 4: Execute §CMD_REPORT_RESULTING_ARTIFACTS — list all created files in chat.
Step 5: Execute §CMD_REPORT_SESSION_SUMMARY — 2-paragraph summary in chat.
Step 6: Suggest follow-up options:
/research again to ask a follow-up question (will chain via Interaction ID)"[path] — reference it from any other session"Output this block in chat with every blank filled:
Phase 4 proof:
- Research report presented:
________- Log entry written:
________- Archive decision:
________- Artifacts listed:
________- Session summary:
________
If ANY blank above is empty: GO BACK and complete it before proceeding.
Post-Synthesis: If the user continues talking, obey §CMD_CONTINUE_OR_CLOSE_SESSION.
Identify Recent Truth: Execute §CMD_FIND_TAGGED_FILES for #active-alert.
contextPaths for ingestion in Phase 1.