Conduct multi-agent deep research on any topic and save a cited report to a markdown file. Use when the user asks to research a topic deeply, do deep research, or wants a comprehensive research report with citations. Supports optional --model, --output, and --interactive flags.
Runs a multi-agent research pipeline modelled on Claude.ai's Deep Research feature. The outer session expands the user's query into a detailed research brief (mirroring claude.ai's launch_extended_search_task pattern), then launches the lead agent (Sonnet) via claude -p with native subagent definitions passed via --agents. The lead agent uses the Agent tool to spawn parallel researcher subagents (Haiku) and a citations subagent (Haiku). Research findings flow through context — no filesystem coordination. The final cited report is saved to a markdown file.
LEAD_MODEL: claude-sonnet-4-6
SUBAGENT_MODEL: claude-haiku-4-5-20251001
CITATIONS_MODEL: claude-haiku-4-5-20251001
DEFAULT_OUTPUT_DIR: ~/research
INTERACTIVE: false
references/lead-agent.md — this is the system prompt for the lead agent (the only reference file you need in context)When the skill is invoked:
1. Parse invocation
Extract from the user's message:
QUERY: the research topic (everything that is not a flag)LEAD_MODEL: if --model opus is present, use claude-opus-4-6; otherwise default claude-sonnet-4-6OUTPUT_DIR: if --output <path> is present, use that path; otherwise use ~/researchINTERACTIVE: if --interactive or -i is present, set to true; otherwise default false2. Clarifying questions
INTERACTIVE is true: always ask clarifying questions before proceeding.Rules for clarifying questions:
3. Expand the research brief
This is the most important step. Build a detailed research brief that will be passed to the lead agent in place of the raw query.
High-fidelity preservation — the brief must retain:
Enrichment — augment the query with:
The brief can be as long as needed to fully capture the above.
4. Derive paths
SLUG: convert QUERY to kebab-case, max 5 words (e.g. "ai impact on healthcare" -> "ai-impact-on-healthcare")DATE: today's date in YYYY-MM-DD formatOUTPUT_PATH: {OUTPUT_DIR}/{DATE}-{SLUG}.mdBOOTSTRAP_DIR: {OUTPUT_DIR}/.tmp/{DATE}-{SLUG}/ (temporary, holds only launch files)5. Prepare launch files
Construct two files needed to launch the lead agent:
a) Lead agent prompt: Read references/lead-agent.md (substituting {CURRENT_DATE} with {DATE}), then append the expanded research brief as a task context block:
---
<task_context>
Current date: {DATE}
Final output path: {OUTPUT_PATH}
<research_brief>
{EXPANDED_BRIEF}
</research_brief>
</task_context>
Use the Write tool to save the result to {BOOTSTRAP_DIR}/lead-prompt.txt — this implicitly creates {BOOTSTRAP_DIR}.
b) Agents JSON: Construct the agents JSON via Bash using cat/sed/jq — do NOT read references/subagent.md or references/citations-agent.md into context. Use the following pattern:
SKILL_DIR="<absolute path to claude-code-only/deep-research>"
DATE="{DATE}"
jq -n \
--arg sub "$(sed "s/{CURRENT_DATE}/$DATE/g" "$SKILL_DIR/references/subagent.md")" \
--arg cit "$(cat "$SKILL_DIR/references/citations-agent.md")" \
'{
researcher: {
description: "Research subagent for deep research tasks. Spawned by the lead agent to investigate specific research questions.",
prompt: $sub,
tools: ["WebSearch", "WebFetch", "Read", "Bash"],
model: "haiku"
},
citations: {
description: "Citations agent for resolving citation markers in research reports. Spawned by the lead agent after draft synthesis.",
prompt: $cit,
model: "haiku"
}
}' > "{BOOTSTRAP_DIR}/agents.json"
6. Announce
Tell the user:
Starting deep research on: "{QUERY}" Lead model: {LEAD_MODEL} | Subagents: {SUBAGENT_MODEL} Report will be saved to: {OUTPUT_PATH}
7. Launch lead agent
Run the lead agent via Bash:
unset CLAUDECODE && cclaude -p "$(cat {BOOTSTRAP_DIR}/lead-prompt.txt)" \
--model {LEAD_MODEL} \
--tools "Agent,WebSearch,WebFetch,Write,Read,Bash" \
--agents "$(cat {BOOTSTRAP_DIR}/agents.json)" \
--dangerously-skip-permissions \
--no-session-persistence 2>&1
The lead agent uses the Agent tool to spawn researcher and citations subagents internally. Wait for it to complete — it writes the final cited report to {OUTPUT_PATH} before finishing.
8. Confirm and clean up
Clean up bootstrap files:
rm -rf {BOOTSTRAP_DIR}
Tell the user:
Research complete. Report saved to: {OUTPUT_PATH}
--output <path>--interactive or -i