Research

From juicesharp/rpiv-pi · View interactive version

Research is an AI agent skill from the GitHub repository juicesharp/rpiv-pi. Answer structured research questions via targeted parallel analysis agents. Consumes question artifacts from discover. Produces research documents in thoughts/shared/research/. Second stage of the research pipeline — always requires a questions artifact.

How to use this skill

Skill file

Questions Source

If the user has not already provided a specific discover artifact path, ask them for it before proceeding. Their input will appear as a follow-up paragraph after this skill body.

Research

You are tasked with answering structured research questions by spawning targeted analysis agents and synthesizing their findings into a comprehensive research document. This skill consumes questions artifacts produced by the discover skill.

Step 1: Read Questions Artifact

  1. Determine input:

Questions artifact provided (path to a .md file in thoughts/):

No arguments provided:

```

I'll answer research questions from a questions artifact. Please provide the path:

/skill:research thoughts/shared/questions/YYYY-MM-DD_HH-MM-SS_topic.md

This skill requires a questions artifact from discover.

There is no standalone path — run /skill:discover first to produce a questions artifact.

```

Then wait for input.

  1. Read key shared files referenced across multiple questions into main context — especially shared utilities, type definitions, and integration points that multiple questions mention.
  1. Analyze question overlap for grouping:
  1. Report chained status:

```

[Chained]: Found research questions for "[topic]". [N] questions in [G] groups, [M] shared files.

```

Step 2: Dispatch Analysis Agents

Spawn analysis agents using the Agent tool. All agents run in parallel.

Default agent: codebase-analyzer for all codebase questions. This agent has Read, Grep, Glob, LS — it can trace code paths, find patterns, and analyze integration points.

Exception: Questions that explicitly reference external documentation, web APIs, or third-party libraries → web-search-researcher.

Agent prompt — question-as-prompt:

Each agent receives the dense question paragraph(s) directly as its prompt. The question IS the instruction.

For standalone questions (no grouping):

Research topic: [topic from frontmatter]

Answer the following research question thoroughly with file:line references. Read the files mentioned, trace the code paths described, and provide a complete analysis.

[Full dense question paragraph]

Provide your analysis with exact file:line references. Focus on DEPTH — trace the actual code, don't just locate it.

For grouped questions:

Research topic: [topic from frontmatter]

Answer the following related research questions thoroughly with file:line references. These questions share overlapping code paths — use your cross-question context to provide deeper, more connected analysis.

Question 1: [Full dense question paragraph]

Question 2: [Full dense question paragraph]

For each question, provide your analysis with exact file:line references. Note connections between the questions where the same code serves multiple roles. Focus on DEPTH — trace the actual code, don't just locate it.

Precedent sweep (always spawn):

Spawn one precedent-locator agent alongside the question agents:

"Find similar past changes involving [list key files from Discovery Summary]. Search git log for commits that touched these files, similar commit messages, and follow-up fixes. Research topic: [original query]."

This agent runs with full knowledge of discovered files — its findings go into Precedents & Lessons, not tied to a specific question.

Wait for ALL agents to complete before proceeding.

Step 3: Synthesize and Checkpoint

  1. Compile findings:
  1. Developer checkpoint — grounded questions one at a time:

Start with grounded questions referencing real findings with file:line evidence. Ask ONE question at a time, waiting for the answer before the next. Use a ❓ Question: prefix. Each question must pull NEW information from the developer — not confirm what you already found:

Every question MUST embed at least one file:line reference in the question text — not just in surrounding context. Examples:

Anti-patterns — NEVER ask these:

Question patterns by finding type:

Choosing question format:

> Use the ask_user_question tool with the following question: "Found 2 patterns for retry logic — which is canonical?". Header: "Pattern". Options: "Event-sourced retry (Recommended)" (src/events/orders.ts:45-67 — 3 hooks, matches precedent commit abc123); "Direct retry loop" (src/services/OrderService.ts:112 — single use, no event traceability).

"❓ Question: src/events/orders.ts:45-67 has 3 event hooks but no error recovery path. Is there a retry mechanism elsewhere I'm not seeing?"

Anti-pattern — do NOT dump a verbose paragraph mixing analysis with a trailing question:

❌ "The premise inversion is load-bearing for prioritization — it means Site A is a no-op, and the real bloat only hits general-purpose dispatches. Given this, where is the bloat actually landing? Do your skills dispatch named bundled agents — in which case append-mode is irrelevant — or general-purpose — in which case it IS the dominant source?"

✅ Extract the 2 concrete options and call ask_user_question: "Where is the prompt bloat landing?". Header: "Bloat source". Options: "Named bundled agents (Recommended)" (Skills dispatch codebase-analyzer etc. — prompt_mode: "replace", no parent inheritance); "General-purpose agent" (default-agents.ts:11-28 — promptMode: "append", inherits full parent prompt).

Batching: When you have 2-4 independent questions (answers don't depend on each other), you MAY batch them in a single ask_user_question call. Keep dependent questions sequential.

CRITICAL: Ask ONE question at a time. Wait for the answer before asking the next. Lead with your most significant finding.

  1. Present compiled scan (under 30 lines):

```

Task: [one-line summary]

Scope: [N files across M layers, K integration points]

[Layer name] — [key files and what they do]

[Layer name] — [key files and what they do]

Integration — [N inbound, M outbound, K wiring. Top concern if any]

History — [N relevant docs. Key insight if any]

Best template: [implementation to model after]

Precedents — [N similar changes found. Top lesson if any]

Inconsistencies: [count] found ([short names])

```

Wait for the developer's response before proceeding.

  1. Incorporate developer input:

Classify each response:

Corrections (e.g., "skip the job scheduler", "use CreateProduct not GetUser"):

New areas (e.g., "you missed the events module"):

Decisions (e.g., "yes, hook into that event chain"):

Scope/focus (e.g., "focus on API layer, UI is out of scope"):

After incorporating all input, proceed to Step 4.

Step 4: Write Research Document

  1. Determine metadata:
  1. Write the research document — this document is compressed context for a new session. Include everything the planner needs to make architectural decisions without re-researching:

```markdown


date: [Current date and time with timezone in ISO format]

researcher: [User from injected git context]

git_commit: [Current commit hash]

branch: [Current branch name]

repository: [Repository name]

topic: "[User's Research Topic]"

tags: [research, codebase, relevant-component-names]

status: complete

questions_source: "[path to questions artifact]"

last_updated: [Current date in YYYY-MM-DD format]

last_updated_by: [User from injected git context]


# Research: [User's Research Topic]

## Research Question

[Original user query from questions artifact]

## Summary

[High-level findings answering the user's question]

## Detailed Findings

### [Component/Area 1]

### [Component/Area 2]

...

## Code References

## Integration Points

[All connections to the researched area. Enumerate each consumer, dependency, and wiring point with file:line. Source from the questions artifact's Discovery Summary + new connections found by analysis agents.]

### Inbound References

### Outbound Dependencies

### Infrastructure Wiring

## Architecture Insights

[Patterns, conventions, and design decisions discovered]

## Precedents & Lessons

[N] similar past changes analyzed. Key commits: hash (description).

## Historical Context (from thoughts/)

[Links only — one line per doc, no summaries of their contents]

## Developer Context

Q (file.ext:line): [Question grounded in specific code reference]

A: [Developer's answer]

## Related Research

## Open Questions

[Only questions NOT resolved during checkpoint]

```

Step 5: Present and Chain

Research document written to:
`thoughts/shared/research/[filename].md`

[N] questions answered, [M] findings across [K] files.

Please review and let me know if you have follow-up questions.

When ready:
`/skill:design thoughts/shared/research/[filename].md`

Step 6: Handle Follow-ups

Important Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.