---
description: Research within task constraints only
agent: oracle
---

# Research: $ARGUMENTS

## MANDATORY GATE: Task Must Exist

Check that `@backlog/tasks/$ARGUMENTS/` contains:

- [ ] prd.md with Goal, Scope, and Success Criteria sections
- [ ] spec.md with Architecture, Constraints, and Edge Cases sections

**If missing:** STOP. Create task with `/task-with-spec "$ARGUMENTS"` first.

## Step 1: Extract Research Boundaries

From `@backlog/tasks/$ARGUMENTS/prd.md` extract:

- **Goal:** What is the task trying to achieve?
- **In-Scope:** What is explicitly in-scope?
- **Out-of-Scope:** What is explicitly out-of-scope?

From `@backlog/tasks/$ARGUMENTS/spec.md` extract:

- **Constraints:** What rules must be followed?
- **Edge Cases:** What corner cases must be handled?
- **Architecture Plan:** What's the proposed structure?

## Step 2: Research Only Within Scope

Use these sources in order, but ONLY for information that fits the task boundaries:

**Source 1: Internal Patterns (GKG)**

- Search codebase for existing implementations of the goal
- Extract only patterns that follow spec constraints
- Discard anything violating task constraints

**Source 2: Framework Documentation (Context7)**

- Fetch docs ONLY for libraries mentioned in spec
- Extract only sections relevant to task goal
- Ignore features outside scope

**Source 3: Real-world Examples (Exa)**

- Find GitHub examples matching task goal
- Extract only patterns following spec constraints
- Reject any approaches violating requirements

**Source 4: Previous Research (Memory)**

- Check `.opencode/memory/research/` for similar tasks
- Extract only findings within scope
- Note any differences from this task

## Step 3: Filter Findings Against Constraints

For every finding, ask:

1. Is this within PRD scope (in-scope list)?
2. Does it follow spec constraints?
3. Does it handle a spec edge case?
4. Is it using only spec-allowed libraries?

**If NO to any question:** Discard that finding.

## Step 4: Create Research Document

Save bounded research to:
`.opencode/memory/research/YYYY-MM-DD-task-$ARGUMENTS.md`

Include:

- Task goal and boundaries
- Key findings (only within scope)
- Recommended implementation (only following constraints)
- How each spec edge case will be handled
- References to sources

## Step 5: Report Results

Present only:

- Findings that fit task boundaries
- Implementation recommendation
- Any gaps or unknown areas within scope
- File location of research

**Next:** User decides whether to proceed with `/research-and-implement $ARGUMENTS`

---

**ANTI-HALLUCINATION: Research must stay within task boundaries - no free exploration**
