---
description: Research-first implementation workflow
---

# Research & Implement

**Feature:** $ARGUMENTS
**Project:** $(basename $(pwd))
**Timestamp:** $(date '+%Y-%m-%d %H:%M:%S')

## Phase 1: Research

### 1. Internal Patterns (GKG)

!`gkg search_codebase_definitions --project_absolute_path $(pwd) --search_terms ["$ARGUMENTS"] --page 1`

### 2. Library Documentation (Context7)

!`context7 resolve-library-id --libraryName "$ARGUMENTS"`

### 3. Real-world Examples (Exa)

!`exa get-code-context-exa --query "$ARGUMENTS implementation examples" --numResults 3`

### 4. Existing Knowledge Base

!`rg -l "$ARGUMENTS" .opencode/memory/research/ 2>/dev/null | tail -3`

## Phase 2: Implementation Plan

Based on research findings:

### Architecture Approach

- Follow existing patterns from GKG analysis
- Use library best practices from Context7
- Adapt proven examples from Exa
- Reference previous research from knowledge base

### Implementation Steps

1. **Setup:** Create necessary files/folders
2. **Core Logic:** Implement main functionality
3. **Integration:** Connect with existing codebase
4. **Testing:** Add appropriate tests
5. **Documentation:** Update relevant docs

### Validation Criteria

- [ ] Matches existing code patterns
- [ ] Uses library APIs correctly
- [ ] Integrates with current architecture
- [ ] Meets task acceptance criteria

## Phase 3: Implementation

**Task Context:**

- Working in: $(pwd)
- Feature: $ARGUMENTS
- Research completed above

**Implementation Instructions:**

1. Review research findings from Phase 1
2. Follow implementation plan from Phase 2
3. Validate against criteria
4. Use session() tool for collaboration:
   - Code review: `session({ mode: "message", agent: "code-auditor", text: "Review implementation for quality/security" })`
   - Complex architecture: `session({ mode: "message", agent: "plan", text: "Review architecture alignment" })`
5. Update related backlog task

## Phase 4: Knowledge Capture

Create research summary: !`mkdir -p .opencode/memory/research/ && cat > .opencode/memory/research/$(date +%Y-%m-%d)-$(echo "$ARGUMENTS" | tr ' ' '-').md << 'EOF'

# Research: $ARGUMENTS

**Date:** $(date '+%Y-%m-%d')
**Project:** $(basename $(pwd))
**Context:** Implementation research for $ARGUMENTS

## Key Findings

[Extract key insights from research above]

## Implementation Decision

[Chosen approach and rationale]

## References

- Context7: [Library docs used]
- Exa: [Code examples referenced]
- GKG: [Internal patterns found]
  EOF`

---

_Use this command for any new feature implementation_
