# Code Investigation Prompt

## 🔍 Investigation Question

**Question:**
{{QUESTION}}

**Scope:**
{{SCOPE}}

**Background:**
{{BACKGROUND}}

---

## 🎯 Your Task

Investigate systematically to answer your question and document findings.

### Phase 1: Clarify the Question

- Restate the question clearly
- Identify what you need to understand
- What are you trying to learn?
- Who needs this information?

### Phase 2: Locate Relevant Code

Identify which files and components are relevant:

- Where does the feature start? (entry point)
- How does it flow through the system?
- What files are involved?
- Are there tests that show usage?

### Phase 3: Trace the Flow

Follow the code flow from entry to end:

```
User Action / API Call
    ↓
Controller / Route Handler
    ↓
Service / Business Logic
    ↓
Model / Data Layer
    ↓
External Systems (if any)
```

Document:
- What happens at each step?
- What data is passed?
- What transformations occur?
- What are the key files?

### Phase 4: Understand Patterns

Look for patterns and conventions:

- How is this feature structured?
- What design patterns are used?
- How does it follow team conventions?
- Are there alternative approaches?

### Phase 5: Identify Potential Issues

Note:
- Potential bugs or edge cases
- Performance concerns
- Security considerations
- Opportunities for improvement

### Phase 6: Document Findings

Create clear documentation:

**Summary:**
- What you found
- How the system works
- Key takeaways

**Code Examples:**
- Show the important parts
- Explain the logic
- Highlight key patterns

**Key Files:**
- List files involved
- Explain their roles
- Show dependencies

**Questions Answered:**
- Your original question answered?
- Any new questions?
- Follow-up areas to investigate?

---

## 📚 Team Framework Rules

{{FRAMEWORK_RULES}}

---

## 📏 Team Rules & Standards

{{TEAM_RULES}}

---

## 🔬 Investigation Checklist

### Understanding Phase
- [ ] Question is clear
- [ ] Scope is defined
- [ ] Background understood

### Code Exploration Phase
- [ ] Entry point found
- [ ] Flow traced
- [ ] Key files identified
- [ ] Tests examined

### Analysis Phase
- [ ] Patterns understood
- [ ] Implementation clear
- [ ] Interactions mapped
- [ ] Issues noted

### Documentation Phase
- [ ] Summary written
- [ ] Examples provided
- [ ] Files documented
- [ ] Findings saved

---

## 💡 Tips

- **Start with tests** → Show how code is used
- **Read code carefully** → Don't skim
- **Ask questions** → Why is it this way?
- **Follow the flow** → Don't jump around
- **Document as you go** → Don't lose findings
- **Save for team** → Use memory system

---

## ✅ Success Criteria

- [ ] Original question fully answered
- [ ] Code flow understood
- [ ] Key patterns identified
- [ ] Can explain to others
- [ ] Findings documented
- [ ] Saved to team memory

---

**Deep understanding leads to better code decisions.** 🔍

Start investigating now! 🕵️
