---
description: Show task-focused context usage
---

# Task-Focused Context Usage

## Phase 0: Task Validation (MANDATORY)

### Check Current Task

Find active task via Backlog MCP:

```typescript
backlog_task_list({ status: "In Progress" });
```

Look for most recent In Progress task with completed work in review.md.

**If no active task found:** STOP. Context analysis requires task context.

### Load Task Context

Read from `@backlog/tasks/[CURRENT_TASK]/`:

- **prd.md** - Task goal and scope
- **spec.md** - Task constraints
- **review.md** - What changed so far

## Phase 1: Task-Bounded Context Analysis

### Analyze Context Within Task Scope

**Analysis Focus:** [From PRD goal of task $CURRENT_TASK]
**Analysis Boundaries:** [From PRD scope of task $CURRENT_TASK]
**Analysis Constraints:** [From spec constraints of task $CURRENT_TASK]

### Context Usage Analysis

!`context_usage`

### Task-Focused Insights:

- **Relevance to task**: How does this context serve task $CURRENT_TASK?
- **Scope compliance**: Is this context within PRD boundaries?
- **Constraint alignment**: Does this respect spec constraints?
- **Efficiency**: Is this context essential for task completion?

## Phase 2: Task Context Validation

### Context Compliance Check:

- [ ] Context usage relates to task $CURRENT_TASK
- [ ] No off-task context consumption detected
- [ ] Token usage aligns with task requirements
- [ ] Context boundaries are respected

### Wasteful Context Indicators:

- ❌ Context unrelated to task goal
- ❌ Tokens used outside task scope
- ❌ General exploration instead of task-focused work
- ❌ Excessive context for simple task

## Phase 3: Task-Optimized Recommendations

### Context Optimization for Task $CURRENT_TASK:

1. **Reduce off-task context**: Limit to task-relevant tools
2. **Focus on task constraints**: Prioritize PRD+spec context
3. **Minimize exploration**: Use only essential research for task
4. **Task-bound tokens**: Ensure context serves task success criteria

### Efficiency Actions:

If context usage is wasteful for current task:

- Reduce tool usage to task-essential only
- Focus on @backlog/tasks/[CURRENT_TASK]/prd.md and spec.md
- Avoid general exploration
- Prioritize task completion over broad analysis

## Phase 4: Task Context Summary

### Task-Focused Context Report:

**Task**: [CURRENT_TASK from backlog]
**Goal**: [From task PRD]
**Context Efficiency**: [Based on task relevance]
**Optimization Needed**: [If wasteful usage detected]

### Next Actions:

- If context efficient: Continue task work
- If context wasteful: Refocus on task boundaries
- Always validate: Does this context serve current task?

---

**ANTI-HALLUCINATION: Context usage must serve task constraints, not general analysis**
