From research
Researches SOTA AI/ML literature, compares methods, and recommends implementation strategy with optional phased plan.
How this skill is triggered — by the user, by Claude, or both
Slash command
/research:topic <topic> [--team] | plan [<output.md>] [--keep "<items>"]<topic> [--team] | plan [<output.md>] [--keep "<items>"]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
<objective>
Research AI/ML topic literature. Return actionable findings: SOTA methods, best fit, concrete implementation plan. Skill = orchestrator — gathers codebase context, delegates literature search to researcher agent, packages results into structured report.
NOT for deep single-paper analysis or experiment design — use research:scientist directly for hypothesis generation, ablation design, experiment validation.
<topic> — topic, method name, or problem description (e.g. "object detection for small objects", "efficient transformers", "self-supervised pretraining for medical images")plan — produce phased implementation plan from most recent research output (auto-detected from .temp/)plan <path-to-output.md> — produce plan from specific existing research output file--team — multi-agent mode; spawns 2–3 researcher teammates for topics with 3+ competing method families and no SOTA consensus; ~7× token cost vs single-agent modeKey boundary: end of Step 2 — SOTA literature gathered and written to AGENT_OUT; before Step 3 report synthesis. Preserve: AGENT_OUT path (TMPDIR key), BRANCH (TMPDIR key), DATE (TMPDIR key), REPORT_OUT target path, topic string from ARGUMENTS. Clear at Step 1 start (stale prior run) and at follow-up gate (terminal action).
# loads: compaction-contract.md
_RESEARCH_SHARED=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/research}/bin/resolve_shared.py" 2>/dev/null) # timeout: 5000
[ -z "$_RESEARCH_SHARED" ] && { echo "! Plugin path resolution failed — ensure research plugin installed and CLAUDE_PLUGIN_ROOT set, or invoke from project root."; exit 1; }
Read $_RESEARCH_SHARED/agent-resolution.md. Contains: foundry check + fallback table. Foundry not installed → substitute each foundry:X with general-purpose per table. Agents this skill uses: foundry:solution-architect.
Task hygiene: Before creating tasks, call TaskList. For each found task:
completed if work clearly donedeleted if orphaned / no longer relevantin_progress only if genuinely continuingTask tracking: per CLAUDE.md, create tasks (TaskCreate) for each major phase — paper collection, researcher analysis, report generation. Mark in_progress/completed throughout.
Read current project before searching, extract constraints:
Case-insensitive flag/mode normalization — normalize before parsing so --PLAN, --Team, Plan, etc. accepted. Each Bash tool call runs fresh shell, so lowercased copy does NOT persist across blocks — re-derive inline from $ARGUMENTS (harness-substituted every block) wherever dispatch check needs it, e.g. echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | …. Preserve original $ARGUMENTS only where literal substitution into prompts required (e.g. topic string).
Unsupported flag check (runs BEFORE any mode dispatch to catch unknown flags in all modes): follow $_RESEARCH_SHARED/unsupported-flag-protocol.md. Supported flags for this skill: --team, --keep.
# Extract --keep quoted value (compaction-contract.md §keep semantics)
KEEP_ITEMS=""
if [[ "$ARGUMENTS" =~ --keep[[:space:]]\"([^\"]+)\" ]]; then
KEEP_ITEMS="${BASH_REMATCH[1]}"
fi
# Clear stale contract from any prior incomplete run (compaction-contract.md §Lifecycle)
rm -f .claude/state/skill-contract.md # timeout: 5000
echo "${KEEP_ITEMS:-}" > "${TMPDIR:-/tmp}/topic-keep-items" # persist for Step 2 contract write
UNKNOWN_FLAGS=$(echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | grep -oE -- '--[a-z][a-z0-9-]+' | grep -v -- '--team' || true) # timeout: 5000
Early dispatch for --team and plan modes — check BEFORE Steps 2-3. Priority: --team wins over plan (plan --team → Team Mode, topic string = "plan"):
FIRST_WORD=$(echo "$ARGUMENTS" | tr '[:upper:]' '[:lower:]' | awk '{print $1}') # timeout: 5000
$ARGUMENTS_LOWER contains --team flag → skip Steps 2-3; jump directly to Team Mode section below.$FIRST_WORD equals exactly plan → skip Steps 2-3; jump directly to Plan Mode section below.Steps 2-3 execute only when neither --team nor plan mode is detected.
Parallelism scope: 2a (Agent spawn) and 2b (Grep) issue in one response. Any WebSearch/WebFetch calls inside the researcher agent are issued sequentially — invoke all searches before synthesizing results. No mechanism exists to parallelize prose-driven searches across calls.
Conduct broad SOTA search directly using foundry:web-explorer (or inline WebSearch/WebFetch if web-explorer unavailable) — topic skill owns SOTA end-to-end. Find top 5 papers for $ARGUMENTS, produce comparison table (method, key idea, benchmark results, compute, code availability), recommend single best method given codebase constraints from Step 1.
Note: never dispatch to research:scientist for broad SOTA surveys — scientist scoped to deep single-paper analysis with named paper anchor. Use research:scientist directly only when: (a) specific paper identified and needs deep analysis, (b) hypothesis generation for identified method, or (c) experiment design for concrete approach. Broad SOTA = web-explorer territory.
Pre-compute output paths before searching:
BRANCH=$(git branch --show-current 2>/dev/null | tr '/' '-' || echo 'main') # timeout: 3000
DATE=$(date +%Y-%m-%d) # timeout: 3000
# Anti-overwrite: resolve counter-suffix (quality-gates.md rule)
AGENT_OUT=".temp/output-research-agent-$BRANCH-$DATE.md"
_N=2; while [ -e "$AGENT_OUT" ]; do AGENT_OUT=".temp/output-research-agent-$BRANCH-$DATE-$_N.md"; _N=$((_N+1)); done # timeout: 5000
mkdir -p .temp # timeout: 3000
echo "$BRANCH" > "${TMPDIR:-/tmp}/topic-branch"
echo "$DATE" > "${TMPDIR:-/tmp}/topic-date"
echo "$AGENT_OUT" > "${TMPDIR:-/tmp}/topic-agent-out"
Search targets: arXiv, Papers With Code, Semantic Scholar, HuggingFace Hub. For each of top 5 papers found via WebSearch/WebFetch: extract method, key idea, benchmark results, compute cost, code availability. Write full findings (comparison table, paper analysis, recommendation, implementation plan, Confidence block) to $AGENT_OUT.
If foundry:web-explorer available (check ls ~/.claude/plugins/cache/borda-ai-rig/foundry/*/agents/web-explorer.md 2>/dev/null): spawn Agent(subagent_type="foundry:web-explorer", prompt="...") for parallel deep web research, then merge results into $AGENT_OUT. Otherwise conduct research inline using WebSearch and WebFetch directly.
Use Grep tool to search codebase for existing related code:
$ARGUMENTS (treat as literal string — if $ARGUMENTS contains regex metacharacters like ., *, +, ?, (, ), [, ], \\, escape them via grep -F semantics, OR escape each metachar with \\ before passing to Grep tool)**/*.pyfiles_with_matches# Compaction contract — boundary: after Step 2 literature gathered (compaction-contract.md §Lifecycle)
_AGENT_OUT=$(cat "${TMPDIR:-/tmp}/topic-agent-out" 2>/dev/null || echo "")
_BRANCH=$(cat "${TMPDIR:-/tmp}/topic-branch" 2>/dev/null || echo "")
_DATE=$(cat "${TMPDIR:-/tmp}/topic-date" 2>/dev/null || echo "")
_KEEP=$(cat "${TMPDIR:-/tmp}/topic-keep-items" 2>/dev/null || echo "")
_REPORT_OUT=".reports/research/topic-${_BRANCH}-${_DATE}.md"
_KEEP_APPEND=""; [ -n "$_KEEP" ] && _KEEP_APPEND="; user-keep: $_KEEP"
mkdir -p .claude/state # timeout: 5000
{
echo "## Active Skill Contract"
echo "- skill: research:topic · phase: synthesis (after Step 2 literature gathered)"
echo "- run-dir: n/a"
echo "- preserve: agent-out=${_AGENT_OUT}, report-out=${_REPORT_OUT}, branch=${_BRANCH}${_KEEP_APPEND}"
echo "- next: Step 3 synthesize agent findings into report → follow-up gate"
} > .claude/state/skill-contract.md # timeout: 5000
---
Research — [topic]
Date: [YYYY-MM-DD]
Scope: [topic / research question]
Focus: SOTA literature research
Agents: foundry:web-explorer (Step 2a, if available), foundry:solution-architect (plan mode P2)
Outcome: EXPLORATORY | PROMISING | CONSENSUS
Best method: [recommended approach / architecture]
Papers: [N papers analyzed]
Confidence: [aggregate score] — [key gaps]
Next steps: /research:topic plan → /develop:feature (requires `develop` plugin)
Path: → .reports/research/topic-<branch>-<date>.md
---
## Research: $ARGUMENTS
### SOTA Overview
[2-3 sentence summary of the current state of the field]
### Method Comparison
| Method | Key Idea | SOTA Result | Compute | Code Available |
|--------|----------|-------------|---------|----------------|
| ... | ... | ... | ... | Yes/No + link |
### Recommendation
**Use [method]** because [specific reason matching the current codebase constraints].
### Implementation Plan
1. [step with file/component to change]
2. [step]
3. [step]
### Key Hyperparameters
- [param]: [typical range] — [what it controls]
### Gotchas
- [common failure mode and how to avoid it]
### Integration with Current Codebase
- Files to modify: [list with file:line references]
- New dependencies needed: [package versions]
- Estimated effort: [hours/days]
- Risk assessment: [what could go wrong during integration]
### References
- [Paper title] ([year]) — [link]
### Agent Confidence
<!-- One row per spawned agent; team mode: 2–3 rows -->
<!-- Emit only rows for agents actually spawned — omit researcher-2 and researcher-3 rows in single-agent mode -->
| Agent | Score | Gaps |
|---|---|---|
| researcher-1 | [score] | [gaps] |
| researcher-2 | [score] | [gaps] |
| researcher-3 _(team mode only)_ | [score] | [gaps] |
mkdir -p .reports/research # timeout: 3000
# Reload from Step 2a bash block (Check 41: fresh shell per call)
BRANCH=$(cat "${TMPDIR:-/tmp}/topic-branch" 2>/dev/null || git branch --show-current 2>/dev/null | tr '/' '-' || echo 'main')
DATE=$(cat "${TMPDIR:-/tmp}/topic-date" 2>/dev/null || date +%Y-%m-%d)
# Anti-overwrite counter-suffix loop (per quality-gates.md output routing rule)
BASE=".reports/research/topic-$BRANCH-$DATE.md"; REPORT_OUT="$BASE"; COUNT=2
while [ -f "$REPORT_OUT" ]; do REPORT_OUT="${BASE%.md}-${COUNT}.md"; COUNT=$((COUNT+1)); done # timeout: 5000
Write full report to $REPORT_OUT using Write tool (resolved by counter-suffix loop above) — do not print full report to terminal.
Print compact terminal summary:
---
Research — [topic]
SOTA: [1–2 sentence summary of current landscape]
Best method: [recommended approach / architecture]
Key papers: [top 2–3 papers with year]
Gaps: [what the research couldn't cover or needs runtime validation]
Confidence: [aggregate score] — [key gaps]
→ saved to .reports/research/topic-$BRANCH-$DATE.md
---
End response with ## Confidence block per CLAUDE.md output standards.
--team flag presentloads: modes/team.md # also loads: modes/plan.md Mode-file existence check — verify before reading:
_TEAM_MODE="${CLAUDE_PLUGIN_ROOT:-plugins/research}/skills/topic/modes/team.md"
[ -f "$_TEAM_MODE" ] || { echo "! MISSING — modes/team.md not found at $_TEAM_MODE. Plugin may not be fully installed. Falling back to single-agent mode."; exit 1; }
Also verify ~/.claude/TEAM_PROTOCOL.md exists (each teammate spawn prompt requires it):
[ -f "$HOME/.claude/TEAM_PROTOCOL.md" ] || { echo "! MISSING — ~/.claude/TEAM_PROTOCOL.md not found. Run /foundry:setup (requires foundry plugin) to install. Falling back to single-agent mode."; exit 1; }
Read "${CLAUDE_PLUGIN_ROOT:-plugins/research}/skills/topic/modes/team.md" and execute its workflow.
Mandatory termination gate: after modes/team.md returns (consolidation complete, report written), continue to ## Follow-up gate section below — do NOT exit early. AskUserQuestion call in ## Follow-up gate is only authorized terminal action for team mode; reaching end of team workflow without invoking it is protocol violation.
$ARGUMENTS is exactly plan (not a prefix match — "planning algorithms" must NOT trigger this mode)loads: modes/plan.md Mode-file existence check — verify before reading:
_PLAN_MODE="${CLAUDE_PLUGIN_ROOT:-plugins/research}/skills/topic/modes/plan.md"
[ -f "$_PLAN_MODE" ] || { echo "! MISSING — modes/plan.md not found at $_PLAN_MODE. Plugin may not be fully installed."; exit 1; }
Read "${CLAUDE_PLUGIN_ROOT:-plugins/research}/skills/topic/modes/plan.md" and execute its workflow.
Mandatory termination gate: after modes/plan.md returns (phased plan emitted, report written), continue to ## Follow-up gate section below — do NOT exit early. AskUserQuestion call in ## Follow-up gate is only authorized terminal action for plan mode; reaching end of plan workflow without invoking it is protocol violation.
rm -f .claude/state/skill-contract.md # clear contract — topic research complete (compaction-contract.md §Lifecycle) # timeout: 5000
Call AskUserQuestion tool — do NOT write options as plain text first. Map options directly into tool call arguments:
/research:plan — description: design a research program from these findings/develop:feature — description: implement based on findings (requires develop plugin)skip — description: no actionfoundry:web-explorer, delegates codebase mapping to foundry:solution-architect (plan mode). For direct hypothesis/experiment work on named paper, use research:scientist directly.--team requires ~/.claude/TEAM_PROTOCOL.md to exist — each teammate spawn prompt includes Read $HOME/.claude/TEAM_PROTOCOL.md and use AgentSpeak v2; verify file present before launching team mode./research:plan for sequenced plan (auto-detects latest output), then /develop:feature (requires develop plugin) for TDD-first implementation/develop:refactor (requires develop plugin) first to prepare module, then /develop:feature (requires develop plugin)pip-audit or uv run pip-audit for Common Vulnerabilities and Exposures (CVE) scan.plans/active/todo_<method>.md with phases as task groups; start with /develop:feature <first task from Phase 1> (requires develop plugin)npx claudepluginhub borda/ai-rig --plugin researchDeep-dives into ML/AI topics by fetching official docs and GitHub sources via KB or web tools, for explaining concepts, comparing approaches, or surveying frameworks like 'how does X work?' or 'X vs Y'.
Conducts systematic literature research to find related papers, survey areas, identify gaps, and discover open-source implementations on topics like research questions.
Orchestrates a full research-plan-implement pipeline using parallel subagents, each in its own context window, with file artifacts as the communication channel between phases.