---
description: Create skill within task constraints
argument-hint: "[task-id]"
agent: build
---

# Create Skill: $ARGUMENTS

## Phase 0: Task Validation (MANDATORY)

### Check Task Exists

!`TASK_DIR="@backlog/tasks/$ARGUMENTS"`
!`if [ ! -d "$TASK_DIR" ]; then echo "ERROR: Task $ARGUMENTS not found. Use /task-with-spec first"; exit 1; fi`

### Load Skill Requirements from Task

!`echo "=== SKILL REQUIREMENTS ==="`
!`grep -A 5 "Goal:" "$TASK_DIR/prd.md"`
!`grep -A 10 "Scope:" "$TASK_DIR/prd.md"`
!`grep -A 15 "Constraints:" "$TASK_DIR/spec.md"`

## Phase 1: Task-Based Skill Planning

### Extract Skill Requirements from Task

**From PRD:**

- Skill purpose: $(grep -A 3 "Goal:" "$TASK_DIR/prd.md")
- Skill scope: $(grep -A 5 "In-Scope:" "$TASK_DIR/prd.md")

**From Spec:**

- Technical constraints: $(grep -A 10 "Framework Requirements:" "$TASK_DIR/spec.md")
- Naming conventions: $(grep -A 5 "Naming Conventions:" "$TASK_DIR/spec.md")

### Skill Boundaries (Task-Defined)

- **Functionality:** [From PRD goal]
- **Technical limits:** [From spec constraints]
- **Integration points:** [From spec architecture]
- **Success criteria:** [From PRD success criteria]

## Phase 2: Constrained Skill Creation

### Create Skill Within Task Specifications

```
@build Create skill for task $ARGUMENTS

ANTI-HALLUCINATION SKILL REQUIREMENTS:
1. Read $TASK_DIR/prd.md and $TASK_DIR/spec.md FIRST
2. Create skill only for PRD-defined purpose
3. Follow all technical constraints from spec
4. Use naming conventions from spec
5. Implement only within PRD scope
6. Stop if any constraint violation detected
7. Complete $TASK_DIR/review.md after work
8. Mark success criteria as completed

SKILL BOUNDARIES:
- Purpose: [From PRD goal]
- Scope: [From PRD scope]
- Constraints: [From spec constraints]
- Integration: [From spec architecture]

NO EXCEPTIONS: Skill must serve task requirements only
```

### Skill Creation Process:

1. **Analyze task requirements** from PRD+spec
2. **Design skill interface** for task-specific needs
3. **Implement skill logic** within spec constraints
4. **Test skill** against task success criteria
5. **Document skill** following spec patterns

## Phase 3: Skill Validation

### Task Compliance Check:

- [ ] Skill serves PRD goal only
- [ ] Implementation follows spec constraints
- [ ] Uses correct naming conventions
- [ ] Integrates with task architecture
- [ ] Meets all success criteria

### Technical Validation:

```
session({
  mode: "message",
  agent: "code-auditor",
  text: "Review skill for task $ARGUMENTS compliance with technical constraints"
})
```

## Phase 4: Skill Integration

### Install Skill in Task Context

!`SKILL_DIR=".config/opencode/skills/task-$ARGUMENTS"`
!`mkdir -p "$SKILL_DIR"`
!`echo "# Skill for Task $ARGUMENTS" > "$SKILL_DIR/SKILL.md"`
!`echo "Created: $(date '+%Y-%m-%d')" >> "$SKILL_DIR/SKILL.md"`
!`echo "Task: $TASK_DIR/prd.md" >> "$SKILL_DIR/SKILL.md"`
!`echo "Spec: $TASK_DIR/spec.md" >> "$SKILL_DIR/SKILL.md"`

### Skill Documentation:

!`cat >> "$SKILL_DIR/SKILL.md" << EOF

## Purpose

[From PRD goal]

## Constraints

[From spec constraints]

## Integration

[With task architecture]

## Validation

[Against success criteria]
EOF`

## Phase 5: Task Completion

### Complete Skill Creation Task

!`/complete-task $ARGUMENTS`

---

**ANTI-HALLUCINATION: Skills must serve task constraints, not general functionality**
