---
description: "Single-phase handler for instruction (documentation) tasks"
allowed-tools: ["Read", "Write", "Edit", "MultiEdit", "Bash", "Grep", "Glob", "LS", "TodoWrite","mcp__*"]
disallowed-tools: ["git", "WebFetch", "WebSearch", "Task", "NotebookRead", "NotebookEdit"]
---

# Command: aidev-instruction-task

# 📚 DOCUMENTATION TASK - STREAMLINED HANDLER 📚

You are handling a documentation/instruction task. Complete it efficiently in a single phase.

## Purpose
Create documentation as specified in the task requirements without the overhead of multiple phases.

## Process

### 1. Task Setup

```bash
# Parse parameters
PARAMETERS_JSON='<extracted-json-from-prompt>'
TASK_FILENAME=$(echo "$PARAMETERS_JSON" | jq -r '.task_filename')
TASK_OUTPUT_FOLDER=$(echo "$PARAMETERS_JSON" | jq -r '.task_output_folder')

# Load task details
TASK_JSON=$(cat .aidev-storage/tasks/$TASK_FILENAME.json)
TASK_ID=$(echo "$TASK_JSON" | jq -r '.id')
TASK_NAME=$(echo "$TASK_JSON" | jq -r '.name')
TASK_DESCRIPTION=$(echo "$TASK_JSON" | jq -r '.description')

echo "📋 Documentation Task: $TASK_NAME"
```

### 2. Initialize Tracking

**Use TodoWrite to create initial todos:**
1. Analyze documentation requirements
2. Search for relevant context (if needed)
3. Create documentation
4. Save to specified location
5. Complete task tracking

### 3. Analyze Requirements

Read the task description carefully to understand:
- What type of documentation is needed
- Where it should be saved
- Any specific format or structure requirements
- Whether you need to reference existing code

### 4. Context Gathering (If Needed)

Only search for context if the documentation needs to reference existing code:
- API docs need actual endpoint details
- Component docs need real usage patterns
- Architecture docs need current system structure

Skip this step for standalone documentation like general guides or README files.

### 5. Create Documentation

Write clear, helpful documentation based on the requirements. Follow these principles:
- Use simple, direct language
- Include practical examples
- Structure content logically
- Match the project's existing documentation style

### 6. Minimal Validation (If Applicable)

<documentation-validation>
For documentation tasks, perform minimal validation to ensure nothing is broken:

1. **Build Check (only if docs affect build)**:
   - If the project builds documentation, run: `npm run build`
   - Only required if docs are part of the build process
   - Skip for standalone markdown files

2. **Documentation Linting (if configured)**:
   - Check for markdownlint or similar in package.json
   - Run if present: `npm run lint:docs` or equivalent
   - Fix any formatting issues

3. **Code Example Validation**:
   - If documentation includes code examples
   - Ensure examples are syntactically correct
   - Consider if examples should be tested

<validation-note>
Most documentation tasks do NOT require full validation. Only validate if:
- The project has documentation build steps
- Documentation linting is configured
- You created TypeScript declaration files
- Code examples might be validated
</validation-note>
</documentation-validation>

### 7. Save and Complete

Save the documentation to the specified location and ensure all tracking is complete:

```bash
# Update context for compatibility
echo '{
  "task_id": "'$TASK_ID'",
  "task_type": "instruction",
  "phases_completed": ["instruction_complete"],
  "pipeline_complete": true
}' > "$TASK_OUTPUT_FOLDER/context.json"

# Create summary
echo '{
  "task_id": "'$TASK_ID'",
  "documentation_created": true,
  "validation_performed": false,  # or true if validation was needed
  "success": true
}' > "$TASK_OUTPUT_FOLDER/instruction_summary.json"
```

### 8. Final Todo Completion

**CRITICAL: Mark ALL todos as completed using TodoWrite before finishing.**

## Success Criteria

<instruction-success-requirements>
✅ Documentation created at specified location
✅ Content addresses all requirements
✅ Documentation follows project style and conventions
✅ Code examples (if any) are syntactically correct
✅ Documentation linting passes (if configured)
✅ Build still passes (only if docs are part of build)
✅ All todos marked as completed
✅ Context shows pipeline_complete = true

<validation-flexibility>
Note: Unlike code tasks, documentation tasks have flexible validation:
- Full build validation is NOT required unless docs affect the build
- Focus on documentation quality over build integrity
- Most instruction tasks can skip validation entirely
</validation-flexibility>
</instruction-success-requirements>