---
name: step-02-execute
description: Execute ONE task from the task list
next_step: steps/step-03-commit.md
---

# Step 2: Execute Task

## YOUR TASK:

Execute exactly ONE task from prd.json. Do NOT batch multiple tasks.

**ULTRA THINK about the implementation.**

---

## EXECUTION RULES:

1. **ONE TASK ONLY** - Execute only `{current_task_description}`
2. **ATOMIC CHANGES** - Changes should be complete and working
3. **USE MCP** - Validate with SmartStack MCP as needed
4. **DOCUMENT** - Track what you're doing

---

## EXECUTION SEQUENCE:

### 1. Understand the Task

**ULTRA THINK:**

- What exactly needs to be done?
- What files need to be created/modified?
- What are the success criteria?
- What patterns should be followed?

### 2. Explore Context (if needed)

**Use subagents sparingly:**

```
If exploration needed:
  - Use explore-codebase agent for file discovery
  - Use explore-docs agent for library docs
  - Use Context7 MCP for documentation
```

**Prefer direct tool usage:**
- Glob for file patterns
- Grep for code search
- Read for file contents

### 3. Execute Implementation

**Implement the task:**

- Create/modify files as needed
- Follow existing patterns in codebase
- Use SmartStack conventions
- Add appropriate logging
- Handle errors properly

**Use TodoWrite to track sub-steps:**

```
If task has multiple parts:
  1. Create TodoWrite entries for each part
  2. Mark in_progress as you work
  3. Mark completed when done
```

### 4. Validate with MCP

**After implementation, validate:**

```
mcp__smartstack__validate_conventions:
  checks: ["all"]
```

**If validation fails:**
- Fix the issues
- Re-validate
- Do NOT proceed until valid

### 5. Run Quick Tests

**If applicable:**

```bash
# For backend changes
dotnet build src/SmartStack.Api/SmartStack.Api.csproj --no-restore

# For frontend changes
npm run lint && npm run typecheck

# For specific tests
dotnet test --filter "FullyQualifiedName~{relevant_test}"
```

**If tests fail:**
- Fix the failing tests
- Re-run until passing
- Document what was fixed

### 6. Track Progress

**Update internal state:**

```
{files_created}  = ["path/to/file1.cs", "path/to/file2.ts"]
{files_modified} = ["path/to/existing.cs"]
{tests_run}      = true/false
{validation}     = "passed" / "failed"
```

---

## IMPORTANT CONSTRAINTS:

### What TO DO:
- Implement exactly what the task describes
- Follow existing patterns
- Validate changes
- Write minimal, clean code

### What NOT TO DO:
- Don't implement other tasks
- Don't refactor unrelated code
- Don't add "nice to have" features
- Don't skip validation

---

## OUTPUT FORMAT:

```
Task Executed:

| Action | Details |
|--------|---------|
| Task | [{current_task_id}] {current_task_description} |
| Files Created | {files_created} |
| Files Modified | {files_modified} |
| Validation | ✅ Passed |
| Tests | ✅ Passed |

-> Committing changes...
```

---

## ERROR HANDLING:

**If task cannot be completed:**

1. Document the blocker
2. Update progress.txt with learnings
3. Mark task with a note (don't mark passes: true)
4. Proceed to step-03 to save progress

**If build fails:**

1. Analyze error messages
2. Fix the issues
3. Re-build until success
4. Then proceed

---

## NEXT STEP:

After task executed and validated, proceed to `./step-03-commit.md`
