MediumContributed by Community
Claude Code /deep-research Built-in Workflow
A teardown of Claude Code's own deep research workflow: scope the question, fan out web search agents, fetch and extract claims, run adversarial verification, then synthesize a cited report.
OfficialResearchWebSearchVerification
512 stars2400 pulls
Orchestration Logic
Workflow Graph Visualizer
Generating visual workflow graph...
How to Use Today
1.Open Claude Code in an interactive session and run
/deep-research .2.Use
/workflows while it runs to inspect Scope, Search, Fetch, Verify, and Synthesize phases.3.Treat this as an official built-in example of the runtime shape: global
phase, agent, pipeline, parallel, args, and log, not a separate claude workflow run CLI.Workflow Script Code
.claude/workflows/claude-deep-research.js
// Built-in Claude Code /deep-research workflow shape
// Observed from Claude Code 2.1.157 generated workflow script.
// The real script is launched as /deep-research <question> inside Claude Code.
export const meta = {
name: "deep-research",
description:
"Deep research harness — fan-out web searches, fetch sources, adversarially verify claims, synthesize a cited report.",
whenToUse:
"When the user wants a deep, multi-source, fact-checked research report on any topic.",
phases: [
{ title: "Scope", detail: "Decompose question into search angles" },
{ title: "Search", detail: "Parallel WebSearch agents, one per angle" },
{ title: "Fetch", detail: "URL-dedup, fetch sources, extract falsifiable claims" },
{ title: "Verify", detail: "3-vote adversarial verification per claim" },
{ title: "Synthesize", detail: "Merge dupes, rank confidence, cite sources" },
],
}
const VOTES_PER_CLAIM = 3
const REFUTATIONS_REQUIRED = 2
const MAX_FETCH = 15
const MAX_VERIFY_CLAIMS = 25
phase("Scope")
const QUESTION = (typeof args === "string" && args.trim()) || ""
if (!QUESTION) {
return { error: "No research question provided. Pass it as /deep-research <question>." }
}
const scope = await agent(
"Decompose this research question into complementary search angles. " +
"Generate distinct web search queries that cover the question from different angles. " +
"Return structured output only.",
{ label: "scope", schema: SCOPE_SCHEMA }
)
const searchResults = await pipeline(
scope.angles,
angle => agent(SEARCH_PROMPT(angle), {
label: "search:" + angle.label,
phase: "Search",
schema: SEARCH_SCHEMA,
}),
searchResult => {
const novel = dedupeAndBudget(searchResult.results, MAX_FETCH)
return parallel(
novel.map(source => () =>
agent(FETCH_PROMPT(source, searchResult.angle), {
label: "fetch:" + host(source.url),
phase: "Fetch",
schema: EXTRACT_SCHEMA,
})
)
)
}
)
const rankedClaims = rankClaims(searchResults).slice(0, MAX_VERIFY_CLAIMS)
phase("Verify")
const voted = await parallel(
rankedClaims.map(claim => () =>
parallel(
Array.from({ length: VOTES_PER_CLAIM }, (_, voter) => () =>
agent(VERIFY_PROMPT(claim, voter), {
label: "v" + voter + ":" + claim.claim.slice(0, 40),
phase: "Verify",
schema: VERDICT_SCHEMA,
})
)
).then(verdicts => {
const valid = verdicts.filter(Boolean)
const refuted = valid.filter(v => v.refuted).length
const survives =
valid.length >= REFUTATIONS_REQUIRED &&
refuted < REFUTATIONS_REQUIRED
return { ...claim, verdicts: valid, refutedVotes: refuted, survives }
})
)
)
phase("Synthesize")
const report = await agent(
"Synthesize confirmed claims into a cited research report. " +
"Merge semantic duplicates, assign confidence, note caveats, and list open questions.",
{ label: "synthesize", schema: REPORT_SCHEMA }
)
return {
question: QUESTION,
...report,
stats: {
sourcesFetched: searchResults.flat().length,
claimsVerified: voted.length,
confirmed: voted.filter(c => c.survives).length,
killed: voted.filter(c => !c.survives).length,
},
}Saved Slash Command
Claude Code currently runs workflows from the interactive session. After a run is saved from /workflows, invoke it as a slash command.
$/deep-research <question>
There is no current `claude workflow run` CLI command.
Specifications
Concurrency MaxRuntime bounded
Verification LoopsAdversarial Checks
Platform SupportClaude Code surfaces
Review Before Running
Treat community workflows as patterns. Review the raw script, planned phases, and allowed tools before approving a run in your own project.