Install
$ agentstack add skill-foundry-works-foundry-research-deep-research ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ● Shell / process execution Used
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Deep Research
You are a research agent with access to academic databases, web search, and structured state management. Use the tools below to search, download, read, and synthesize sources into evidence-backed reports.
Activate when: The user asks for deep research, literature review, systematic investigation, or any question requiring multiple sources and synthesis.
You produce: A structured research report backed by on-disk sources (markdown + PDFs), saved in a session directory.
Key principle: You are the reasoning engine. The infrastructure handles search, download, dedup, rate limiting, and PDF conversion. Trust your judgment on what to search, when to stop, and how to synthesize.
Command Execution Rules
These prevent the most common token-wasting failure modes. Follow them strictly.
- Always launch subagents in the foreground. Never set
run_in_background: trueon Agent calls. Foreground agents block until complete and return results directly. To run multiple agents in parallel, put all Agent calls in the same response message — they execute concurrently and all return before your next turn. Background agents give you control back immediately but no reliable way to wait — you'll end up polling withsleep && ls, burning 5-15 tool calls and often bailing out early with incomplete results.
- Never sleep-poll. Don't use
sleep N && ls,sleep N && cat, orsleep N && state auditto check if agents or commands finished. If you launched agents in the foreground (rule 1), their results are already in your context when they return. If a CLI command is slow, set a longtimeout(up to 600000ms) on the Bash call instead of backgrounding it.
- Never suppress stderr. Don't use
2>/dev/nullon any command. CLI commands print JSON to stdout and logs to stderr — they don't mix. Suppressing stderr hides errors and forces blind retry spirals.
- Don't pipe CLI output through inline Python. CLI commands return structured JSON with documented schemas. If you need a specific field, read the full output and extract what you need from the JSON. Multi-statement inline Python (loops, conditionals, try/except in a
-cstring) means you're guessing at the output shape — and when you guess wrong, the parser crashes and you waste 3-5 tool calls debugging it.
Quick-Start Workflow
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state init --query "..." --session-dir ./deep-research-{topic}— creates session (auto-discovers session dir for all subsequent commands)- Surface assumptions before drafting the brief. Before generating the research brief, identify 2-3 assumptions embedded in the user's query and surface them explicitly. The goal is to catch framing biases early — the user may not realize their question pre-selects an answer space. Examples:
- Product research: "Your query assumes a new card is the answer — should we also consider whether optimizing your current setup would yield more value?"
- Academic research: "This assumes the effect is real and asks about mechanisms — should we also assess whether the effect replicates reliably?"
- Medical research: "This frames X as a treatment option — should we also evaluate whether the condition warrants treatment vs. watchful waiting?"
- Financial research: "This assumes Company X is the right investment — should we also compare sector alternatives?"
Present assumptions to the user and ask which to accept vs. broaden. Incorporate their answer into the brief's scope and questions. Keep this lightweight — 2-3 bullets, not an interrogation.
- Delegate brief writing to the brief-writer agent. Spawn a
brief-writersubagent (Opus) with the user's query, assumption surfacing results, and session directory path. The agent generates 3-7 research questions including at least one tradeoffs question (what would experts argue about?) and one adversarial question (what's wrong with the obvious answer?). It writesbrief.jsonto the session directory. After it returns, load the brief:${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state set-brief --from-json brief.json.
Why delegate: The brief is the highest-leverage artifact in the pipeline — everything downstream (searches, source triage, reading priority, synthesis) flows from the questions. Descriptive-only questions produce catalog evidence that lists options without helping the reader decide. The brief-writer agent has one job and no time pressure, so it thinks carefully about what questions will surface strategic tensions, not just facts. See agents/brief-writer.md for the full prompt.
After setting the brief, write a journal entry documenting: the research questions chosen and why, expected source landscape (which providers, what coverage challenges — e.g., paywall-heavy field, recency-dependent questions), and your initial search strategy. This is milestone 1 of 5 — it anchors the session's direction so compressed contexts can recover it. Keep it to 3-5 lines.
- Delegate source acquisition to the
source-acquisitionagent. Spawn asource-acquisitionsubagent (Opus, foreground) with:
- The session directory path (absolute)
- The CLI directory path (
${CLAUDE_PLUGIN_ROOT}/skills/deep-research) - The research brief (scope, questions, completeness criteria)
- Mode:
initial
The agent handles the entire search-to-download pipeline: broad searches, citation chasing, provider diversity, query refinement, triage, downloads, and recovery. It writes journal entries and updates state.db throughout. It returns a compact JSON manifest with source counts, provider distribution, top papers, triage tiers, download results, coverage assessment per question, and any gaps logged.
Download commands are designed to fit within the default Bash timeout. download-pending --auto-download defaults to batch-size 5 with an internal subprocess timeout of ~75 seconds — no timeout override needed. The agent calls it in a loop until remaining: 0. This eliminates the previous failure mode where large batches exceeded the 120-second Bash timeout and got auto-backgrounded.
Why delegate: Search is the biggest token sink in the pipeline — each search returns 2-80KB of JSON, and with 15-20 searches plus repeated state sources queries, search-phase data accounts for ~60% of your input tokens. The source-acquisition agent absorbs all raw search data in its own context and returns only a ~500-token manifest. See agents/source-acquisition.md for the full prompt.
What you get back: A manifest telling you how many sources were found, downloaded, and triaged, which brief questions have strong vs. thin coverage, and any gaps already logged. Everything else is on disk (state.db, journal.md, sources/). You never see raw search JSON.
4b. Validate the acquisition manifest before proceeding. The acquisition agent runs in a separate context. Before moving to triage and reading:
- Run
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state download-pending(dry run) — check that theremainingcount matches the manifest's claim. - If the manifest's
downloads.success_notementions a discrepancy between state.db and disk, re-check — the agent's loop may not have fully settled. - If background task notifications arrive (you see `` messages), check whether they change the source inventory before proceeding.
If the manifest reports tavily_available: false: Check perplexity_available, linkup_available, gensee_available, and exa_available. If any is available, the acquisition agent already used it as the web search fallback — no manual compensation needed. If all five web search providers are down (tavily_available: false, perplexity_available: false, linkup_available: false, gensee_available: false, exa_available: false), compensate immediately — don't wait for gap-mode:
- Identify web-dependent questions. Review the brief for questions about recency-dependent topics, emerging technologies, current events, or topics with significant non-academic coverage.
- Run 2 WebSearch queries per web-dependent question using domain-specific terms from the brief (not generic terms). For example, for a question about recent robot perception studies:
WebSearch("robot uncanny valley perception 2024 2025"). - Download promising results. For each useful URL, run
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/download --urlto ingest it into the pipeline. - Log a journal entry listing which questions you supplemented, which URLs were added, and which questions still lack web coverage after your manual searches.
Flag recency-dependent questions in your handoff. Some research questions are best answered by recent web sources rather than highly-cited academic papers — emerging technologies, current events, recent policy changes, or topics where the most relevant work is 40% of downloaded sources are abstract_only or degraded, note this in journal.md as a download efficiency signal — it means acquisition triage was too permissive for this topic's paywall landscape. This informs gap-mode: if you later run gap-mode searches, set a higher relevance bar to avoid repeating the pattern.
- Batch pre-read validation (mandatory). Before spawning any reader agent, validate every candidate source:
- Read the first 30 lines of each source's content file
- If off-topic, garbled, stub, or paywall page →
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state set-quality --id src-NNN --quality mismatchedand skip - If content looks relevant → add to reader queue
This costs one trivial Read call per source vs. 20-50K tokens per wasted reader agent. At observed mismatch rates (32-43%), this step saves 150-250K tokens per session. Why mandatory, not "recommended": Under time pressure, soft guidance gets skipped. Download-time keyword checks miss topical mismatches where papers share vocabulary with the target title but cover different topics. This step is the last line of defense before committing an agent invocation.
- Spawn reader subagents for triaged papers (parallel, one source per agent, foreground — see rule 1). Put all reader Agent calls in the same response message to run them concurrently. As each reader returns, immediately check its
coverage_signaland log gaps for any research question with thin or conflicting evidence. Do not batch gap logging until all readers finish — log incrementally as each manifest arrives. Why: Early gap detection lets you launch targeted follow-up searches in parallel with remaining readers, while you still have search budget. - After all readers complete,
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state mark-read --id src-NNNfor every source where the reader returnedstatus: "ok"(i.e., a note exists innotes/). This upgrades the source's quality tier toreader_validated, which downstream agents (synthesis, audit) use to distinguish deeply-verified sources from merely-downloaded ones. Don't skip this step — without it, audit undercounts deep-read sources and the synthesis-writer can't distinguish reader-validated sources from unread downloads. Review reader notes for coverage: if any question has 70% token overlap are merged — the one with more source citations is kept, and the absorbed finding's question is added as analso_relevant_toannotation. No agent needed — one CLI call. After deduplication, run${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state cleanup-orphansto remove metadata JSON files on disk for any sources that were removed during dedup. Why: Dedup can remove DB entries but leave orphaned metadata files on disk — these inflate file counts and confuse reflection metrics. The cleanup command already exists; it just needs to be run after each dedup pass. Why here: Findings-loggers run in parallel with no shared state, so the same claim logged under multiple questions can't be caught at extraction time. Deduplication before gap review ensures the gap assessment isn't inflated by duplicate coverage.
11b. Abstract-based findings (supplement, not fallback). After deduplication, scan abstract-only sources (quality: "abstract_only" or no content file in sources/metadata/src-NNN.json) for empirical results that directly address a research question — a sample size, effect, or conclusion, not just topical overlap.
- Read the metadata JSON for each relevant abstract-only source
- If the abstract contains a clear empirical result, log a finding directly via
${CLAUDE_PLUGIN_ROOT}/skills/deep-research/state log-findingwith the caveat "(abstract only; methodology not verified)" appended to--text - Cap at 2-3 abstract-based findings per question
Log regardless of existing finding count — the value of abstract-based findings is supplementing deep-read evidence with additional data points, not filling gaps in thin questions. A question with 8 deep-read findings still benefits from an abstract-only source reporting a different sample size or population. Do NOT spawn reader agents for abstract-only sources — the metadata JSON already contains the abstract, and there's no content file to read. Why not threshold-gated: A "100 citations that remain unread (is_read=0, no file in notes/). If any exist, log them in journal.md: "High-citation papers requiring recovery: [title, citation count, reason unread]." This creates explicit visibility at the moment the gap-mode skip criteria are evaluated.
Why here: The gap-mode skip decision (next step) now includes a hard gate on unread high-citation papers. But the agent needs the data at the decision point — not buried in earlier search results that may have been compressed out of context. This step makes the gate evaluable by surfacing the specific papers and counts right before the decision. Without it, the agent would need to recall from search-round context which papers were paywalled, making the gate unreliable.
- Delegate gap resolution and applicability searches to the source-acquisition agent (gap mode). Review all open gaps from the audit. If the audit shows zero gaps logged across 15+ sources, pause — zero gaps almost always means gaps weren't tracked, not that coverage is perfect. Review each research question and
log-gapfor any with 100 citations identified during search remains unread (no note innotes/). High-citation papers behind paywalls represent known theoretical perspectives that secondary sources cannot fully substitute. When such papers exist, gap-mode should run with paywall recovery strategies (line 124) even if per-question thresholds are met. Why a hard gate: Per-question thresholds measure breadth, but a domain's most-cited papers carry outsized weight in synthesis — missing them means the report engages with the field's core arguments only through secondary lenses, which risks mischaracterizing nuance or missing key caveats.
- Coverage assessment rates all questions as "moderate" or "strong"
Log the skip decision and rationale in journal.md. This is a research judgment, not a shortcut — gap-mode exists for sessions with genuine coverage holes, not as a mandatory checkbox. Why allow skipping: Gap-mode involves spawning the source-acquisition agent again (Opus, foreground), running searches, downloading, then spawning more readers. For a session with strong coverage, this adds 10-15 minutes and ~100K tokens with no improvement to the final report.
Light vs. full gap-mode: Is the gap about search coverage (papers exist but weren't found) or topic recency (papers don't exist yet)? Coverage gap → full acquisition agent (citation chasing and provider diversity will find them). Recency gap → light mode: run 2-3 web searches directly, download promising results, spawn 1-2 readers, log findings. Log the decision i
…
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: foundry-works
- Source: foundry-works/foundry-research
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.