---
description: Analyze project within task context only
agent: plan
---

# Task-Focused Project Analysis

## Phase 0: Task Context Validation (MANDATORY)

### Check Current Tasks

!`if [ ! -d "@backlog/tasks" ]; then echo "ERROR: No tasks found. Project analysis requires task context"; exit 1; fi`

### Load Task Context

!`echo "=== PROJECT ANALYSIS BOUNDARIES ==="`
!`echo "Active Tasks: $(find @backlog/tasks -maxdepth 1 -type d | wc -l | tr -d ' ')"`

## Phase 1: Task-Bounded Project Analysis

### Analyze Only Task-Relevant Areas

**Analysis Focus:** [Project areas relevant to active tasks]
**Analysis Boundaries:** [Limited to task requirements]
**Analysis Constraints:** [From task specifications]

### Task-Focused Analysis:

```
@plan Analyze project for task context only

ANTI-HALLUCINATION ANALYSIS REQUIREMENTS:
1. Check all active tasks in @backlog/tasks/
2. Read PRD+spec for each active task
3. Analyze only project areas relevant to tasks
4. Ignore project areas outside task scope
5. Provide analysis only for task requirements
6. Document findings in task context only
7. Stop if analysis exceeds task boundaries

TASK-FOCUSED ANALYSIS:
- Active Tasks: [From @backlog/tasks]
- Task Requirements: [From task PRDs]
- Task Constraints: [From task specs]
- Project Relevance: [Only task-related areas]

NO EXCEPTIONS: Analysis must serve task context only
```

### Project Structure Analysis (Task-Aligned):

!`echo "=== TASK-RELEVANT PROJECT AREAS ==="`
!`for task_dir in @backlog/tasks/task-*; do if [ -d "$task_dir" ]; then task_id=$(basename "$task_dir"); echo "Task $task_id areas:"; grep -A 5 "Files to Create/Modify:" "$task_dir/spec.md" 2>/dev/null | head -6 || echo "No file specifications found"; echo ""; done`

## Phase 2: Task-Context Knowledge Base

### Analyze Only Task-Linked Knowledge

**Knowledge Focus:** [Only research/docs for active tasks]
**Knowledge Boundaries:** [Limited to task requirements]

### Task-Linked Knowledge Analysis:

!`echo "=== TASK-RELEVANT KNOWLEDGE ==="`
!`echo "Task Specs: $(find @backlog/tasks -name "spec.md" | wc -l | tr -d ' ')" files`
!`echo "Task Reviews: $(find @backlog/tasks -name "review.md" | wc -l | tr -d ' ')" files`
!`echo "Task Research: $(ls .opencode/memory/research/*task-* 2>/dev/null | wc -l | tr -d ' ')" files`

### Task-Specific Patterns:

!`for task_dir in @backlog/tasks/task-*; do if [ -d "$task_dir" ]; then task_id=$(basename "$task_dir"); echo "=== Task $task_id Patterns ==="; grep -A 10 "Architecture Plan:" "$task_dir/spec.md" 2>/dev/null | head -11 || echo "No architecture specified"; echo ""; done`

## Phase 3: Task-Focused Status Analysis

### Status Only for Active Tasks

**Status Focus:** [Progress of active tasks only]
**Status Boundaries:** [Task completion metrics]

### Task Status Analysis:

!`echo "=== ACTIVE TASK STATUS ==="`
!`for task_dir in @backlog/tasks/task-*; do if [ -d "$task_dir" ]; then task_id=$(basename "$task_dir"); echo "Task $task_id:"; if [ -f "$task_dir/review.md" ]; then echo "  Status: In Progress - Review being updated"; elif [ -f "$task_dir/spec.md" ] && [ -f "$task_dir/prd.md" ]; then echo "  Status: Ready - PRD+spec complete"; else echo "  Status: Incomplete - Missing files"; fi; echo ""; done`

### Task Compliance Check:

!`complete_tasks=0; total_tasks=0; for task_dir in @backlog/tasks/task-*; do if [ -d "$task_dir" ]; then total_tasks=$((total_tasks + 1)); if [ -f "$task_dir/prd.md" ] && [ -f "$task_dir/spec.md" ] && [ -f "$task_dir/review.md" ]; then complete_tasks=$((complete_tasks + 1)); fi; fi; done; echo "Task Compliance: $complete_tasks/$total_tasks tasks have complete PRD+spec+review"`

## Phase 4: Task-Bounded Recommendations

### Recommendations Only for Task Context

**Recommendation Focus:** [Actions that serve active tasks]
**Recommendation Boundaries:** [Within task requirements]

### Task-Focused Recommendations:

```
## Task-Context Recommendations

### Immediate Actions (Task-Only)
1. **Complete incomplete tasks**: Finish missing PRD+spec+review files
2. **Start ready tasks**: Begin work on tasks with complete setup
3. **Fix non-compliant tasks**: Address missing constraint files

### Project Areas (Task-Relevant)
[Only project areas needed for active tasks]

### Architecture Decisions (Task-Aligned)
[Only decisions affecting active task implementation]

### Research Needs (Task-Specific)
[Only research needed for task requirements]

### Next Steps (Task-Focused)
1. Use /research-and-implement for specific tasks
2. Use /complete-task for finished work
3. Use /task-with-spec for new requirements
```

## Phase 5: Task Analysis Summary

### Analysis Validation (Task-Bounded):

- [ ] Analysis limited to task-relevant areas
- [ ] Knowledge base analysis task-focused only
- [ ] Status analysis for active tasks only
- [ ] Recommendations serve task requirements only
- [ ] No general project exploration included

### Task Analysis Output:

**Active Tasks**: [Count and status]
**Task Compliance**: [Percentage with complete files]
**Project Relevance**: [Only task-related areas]
**Next Actions**: [Task-focused recommendations]

---

**ANTI-HALLUCINATION: Project analysis must serve task context, not general exploration**
