deep-web-research

workflow claude_code
Created by Prasham Trivedi

Copy This Prompt

export const meta = {
  name: 'deep-web-research',
  description: 'Decompose a research question, search each sub-query in parallel, fact-check claims, then synthesize a cited report',
  whenToUse: 'A research question needing multiple sources and verified, current information',
  phases: [
    { title: 'Plan', detail: 'decompose into sub-queries' },
    { title: 'Research', detail: 'per sub-query: search+fetch -> fact-check (pipeline)' },
    { title: 'Synthesize', detail: 'merge into one cited report' },
  ],
}

// args: { question: string, asOf?: string }  — asOf is the current-date context (scripts can't call Date)
const QUESTION = (args && args.question) || (typeof args === 'string' ? args : null)
const AS_OF = (args && args.asOf) || 'the current date'
if (!QUESTION) return { error: 'Pass args.question (or a plain string) with the research question.' }

const PLAN = {
  type: 'object', additionalProperties: false, required: ['subQueries'],
  properties: {
    subQueries: {
      type: 'array',
      items: {
        type: 'object', additionalProperties: false, required: ['q', 'rationale', 'timeSensitive'],
        properties: {
          q: { type: 'string' },
          rationale: { type: 'string' },
          timeSensitive: { type: 'boolean', description: 'whether recent/dated results matter for this sub-query' },
        },
      },
    },
  },
}

const FINDINGS = {
  type: 'object', additionalProperties: false, required: ['subQuery', 'findings', 'claims', 'sources'],
  properties: {
    subQuery: { type: 'string' },
    findings: { type: 'string', description: 'synthesized answer to this sub-query' },
    claims: { type: 'array', items: { type: 'string' }, description: 'key factual claims worth verifying' },
    sources: { type: 'array', items: { type: 'object', additionalProperties: false, required: ['url', 'credibility'], properties: { url: { type: 'string' }, credibility: { type: 'string', enum: ['high', 'medium', 'low'] } } } },
  },
}

const VERDICTS = {
  type: 'object', additionalProperties: false, required: ['checks'],
  properties: {
    checks: {
      type: 'array',
      items: {
        type: 'object', additionalProperties: false, required: ['claim', 'status', 'evidence'],
        properties: {
          claim: { type: 'string' },
          status: { type: 'string', enum: ['supported', 'disputed', 'unverified'] },
          evidence: { type: 'string' },
        },
      },
    },
  },
}

phase('Plan')
const plan = await agent(
  `Decompose this research question into 3-6 focused, non-overlapping sub-queries.
Question: "${QUESTION}"
Current date context: ${AS_OF}. Mark each sub-query timeSensitive if recent/dated results matter.`,
  { label: 'plan', phase: 'Plan', schema: PLAN, agentType: 'web-search-specialist', model: 'opus' }
)
if (!plan || !plan.subQueries.length) return { error: 'Planning produced no sub-queries.' }
log(`${plan.subQueries.length} sub-queries planned.`)

phase('Research')
// Pipeline: each sub-query is researched then fact-checked independently — no barrier between stages.
const researched = await pipeline(
  plan.subQueries,
  sq => agent(
    `Research this sub-query thoroughly using web search + page reads. Cross-reference multiple sources.
Sub-query: "${sq.q}"
${sq.timeSensitive ? `Prioritize recent information; current-date context is ${AS_OF}.` : ''}
Return synthesized findings, the key factual claims, and rated sources.`,
    { label: `search:${sq.q.slice(0, 32)}`, phase: 'Research', schema: FINDINGS, agentType: 'web-search-specialist' }
  ),
  (found, sq) => agent(
    `Fact-check these claims from the sub-query "${sq.q}". Use fact-checking and cross-source verification. Mark each supported/disputed/unverified with evidence.
Claims:\n${found.claims.map((c, i) => `${i + 1}. ${c}`).join('\n')}`,
    { label: `verify:${sq.q.slice(0, 32)}`, phase: 'Research', schema: VERDICTS, agentType: 'web-search-specialist' }
  ).then(v => ({ ...found, verdicts: v ? v.checks : [] }))
)

const ok = researched.filter(Boolean)

phase('Synthesize')
// Barrier is correct here: synthesis genuinely needs ALL sub-query results at once.
const report = await agent(
  `Write a clear, structured, cited research report answering: "${QUESTION}"
Use the per-sub-query findings, their fact-check verdicts, and rated sources below. Flag any disputed/unverified claims explicitly, note conflicting information, give confidence levels, and end with suggested follow-up questions. Current-date context: ${AS_OF}.

DATA:
${JSON.stringify(ok, null, 2)}`,
  { label: 'synthesize', phase: 'Synthesize' }
)

return { question: QUESTION, report, subQueryCount: ok.length, raw: ok }

Workflow Details

Format Availability

Workflows are available in Claude Code format only and are delivered as-is. They cannot be converted to Codex or Gemini.

Actions

(Clears cached conversions and forces re-processing)
← Back to List