# Auto-Feature Development (Automatic Orchestration)

**IMPORTANT**: This skill performs AUTOMATIC multi-agent orchestration. You will execute ALL phases WITHOUT stopping for user confirmation.

## What This Skill Does

When invoked with `/auto-feature "Feature description"`, you will:
1. ✅ Detect project level automatically
2. ✅ Execute architect phase (design)
3. ✅ Execute developer phase (implementation)
4. ✅ Execute tester phase (tests - auth/payment only)
5. ✅ Execute reviewer phase (validation)
6. ✅ Report final results to user

**NO user confirmation between phases** - this is fully automatic.

---

## Execution Protocol

### Phase 0: Initialize

**FIRST**, gather feature requirements:

```
User Request: [Feature description from command]

Ask ONLY if unclear:
- What is the main goal?
- Any specific requirements?

Once clear, proceed to Phase 1 WITHOUT asking for confirmation.
```

### Phase 1: Auto-Detect Level

**REQUIRED**: Call MCP tool to detect project level:

```typescript
const context = await mcp__crafted-context__get_architecture_info();
// Returns: { level: "rapid", platform: "web" }
```

**Output to user**:
```
🎯 Detected: Rapid level, Web platform
📋 Starting automatic orchestration...
```

Then **IMMEDIATELY proceed to Phase 2** without waiting.

---

### Phase 2: Architect (Design)

**Role**: Software Architect

**Follow instructions from** `.claude/skills/agents/architect.md`

**For Rapid level** (current template):
1. Identify which router to create/modify
2. Design simple tRPC procedures
3. Plan Prisma schema changes (if needed)
4. Keep it simple - NO complex architecture

**Tools to use**:
```typescript
mcp__crafted-context__get_context_summary()  // Understand codebase
```

**Output to user**:
```
🏗️ Architecture Phase (Architect)
├─ Router: productRouter.list() - Logic directly in router
├─ Database: Prisma query with simple filtering
└─ ADR: Not required (simple feature)
```

**Then IMMEDIATELY proceed to Phase 3** without waiting.

---

### Phase 3: Developer (Implementation)

**Role**: Craftsman Developer

**Follow instructions from** `.claude/skills/agents/developer.md`

**For Rapid level** (current template):
1. Write logic directly in router (< 100 lines/function)
2. Use Prisma queries directly
3. Follow Clean Code principles (NO inline comments, self-documenting)
4. Duplication OK if < 3 times
5. Basic error handling (try-catch)

**Tools to use**:
```typescript
mcp__rules-validator__validate_code({
  code: generatedCode,
  filePath: "packages/api/routers/product.ts",
  level: "rapid"
})
```

**Output to user**:
```
👨‍💻 Implementation Phase (Developer)
├─ Created: packages/api/routers/product.ts (65 lines)
└─ ✅ Validation passed (no rule violations)
```

**Then IMMEDIATELY proceed to Phase 4** without waiting.

---

### Phase 4: Tester (Tests - Auth/Payment Only)

**Role**: Quality Engineer

**Follow instructions from** `.claude/skills/agents/tester.md`

**For Rapid level** (current template):
- ✅ Auth flows (if feature touches auth)
- ✅ Payment flows (if feature touches payments)
- ⏭️ **SKIP business logic tests** (not required for Rapid)
- ⏭️ **SKIP UI component tests**
- ⏭️ **SKIP coverage check** (no minimum required)

**If feature is NOT auth/payment related**:
```
🧪 Testing Phase (Tester)
└─ ⏭️ Skipped (Rapid level: only auth/payment tests required)
```

**If feature IS auth/payment related**:
```typescript
mcp__vitest__run_tests()
```

**Output to user**:
```
🧪 Testing Phase (Tester)
├─ Created: packages/api/routers/auth.test.ts (5 tests)
├─ Run tests: ✅ 5/5 passed
└─ Coverage: N/A (not required for Rapid)
```

**Then IMMEDIATELY proceed to Phase 5** without waiting.

---

### Phase 5: Reviewer (Validation)

**Role**: Code Reviewer

**Follow instructions from** `.claude/skills/agents/reviewer.md`

**Review Checklist for Rapid**:
- ✅ No inline comments (WHY comments only)
- ✅ Self-documenting code
- ✅ Basic error handling
- ✅ Type safety enforced
- ✅ Function length < 100 lines
- ⏭️ No architecture checks (flat structure OK)
- ⏭️ No coverage checks (not required)

**Tools to use**:
```typescript
mcp__rules-validator__validate_code()
mcp__typescript__check_types()
```

**Output to user**:
```
✅ Review Phase (Reviewer)
├─ Code quality: ✅ Passed
├─ Type safety: ✅ No errors
└─ Ready to ship!
```

**Then proceed to Phase 6** (Final Report).

---

### Phase 6: Final Report

**Output to user**:

```
✅ Feature Complete!

📊 Summary:
├─ Files created: 1
│  └─ packages/api/routers/product.ts (65 lines)
│
├─ Tests created: 0 (not required for non-auth features)
│
├─ Coverage: N/A (Rapid level - no minimum)
│
└─ Time: ~5 minutes (automatic orchestration)

🎯 Quality Level: Rapid
✅ All checks passed
✅ Ready to ship and iterate!

Next steps:
- Test the feature manually
- Ship to production
- Gather user feedback
- Iterate quickly
```

---

## Critical Rules

### 🚨 MUST DO

1. **Execute ALL phases automatically** - NO stopping for confirmation
2. **Use MCP tools** for validation at each phase
3. **Fix errors automatically** - If tests fail, fix and re-run
4. **Report progress** - Show user what's happening
5. **Adapt to detected level** - Rapid rules apply (simple, fast)

### ❌ NEVER DO

1. **NEVER ask for confirmation** between phases (only at start if requirements unclear)
2. **NEVER skip phases** (must complete architect → developer → tester → reviewer)
3. **NEVER write inline comments** (refactor instead, follow CLAUDE.md rules)
4. **NEVER over-engineer** for Rapid (flat structure, simple solutions)

---

## Rapid Philosophy

> "Code that works > Perfect code. Ship, learn, iterate."

**Keep it simple**:
- Logic in routers (no services/repositories needed)
- Basic error handling
- Tests only for critical flows (auth, payments)
- Ship fast, iterate quickly

---

## Example Invocation

**User types**:
```
/auto-feature "Add product catalog with basic filtering"
```

**You execute**:
```
🎯 Detected: Rapid level, Web platform
📋 Starting automatic orchestration...

🏗️ Architecture Phase (Architect)
├─ Router: productRouter.list() - Simple Prisma query
└─ Keep it flat - no layers needed

👨‍💻 Implementation Phase (Developer)
└─ Created: packages/api/routers/product.ts (65 lines)

🧪 Testing Phase (Tester)
└─ ⏭️ Skipped (non-auth feature)

✅ Review Phase (Reviewer)
└─ All checks passed

✅ Feature Complete! (5 minutes)
```

**Total time: ~5 minutes** (no manual intervention, minimal testing)

---

## Integration with Existing Skills

This skill **replaces** `/feature` for automatic mode.

- Use `/feature` for **manual mode** (you guide at each step)
- Use `/auto-feature` for **automatic mode** (full orchestration, no stops)

---

**Remember**: This is AI-**automated** development optimized for RAPID shipping. You execute the ENTIRE workflow without user confirmation. Ship fast, iterate quickly!
