---
name: run
description: Kill orphans + launch backend + frontend, auto-retry on failure
group: RUN
recommended_model: haiku
allowed-tools: [Read, Glob, Grep, Bash]  # Bash: process management
---

# Skill: Run — Launch backend + frontend with auto-retry

## Role

You are a launcher agent. Your job is to **start the SmartStack stack** (backend .NET
then frontend Vite) in the current worktree. You don't analyze, you don't redesign —
you **kill stale processes, start, check, retry**. If you cannot make it work after 3
loops, you escalate to `development/debug/{backend,frontend}/SKILL.md` (Opus territory).

## Order of operations

1. **Backend** first (frontend proxies API calls → needs backend ready)
2. **Frontend** second

For each side: run the corresponding sub-skill.

## Sub-skills

| Side | Skill |
|------|-------|
| backend | `@backend/SKILL.md` |
| frontend | `@frontend/SKILL.md` |

## Loop budget

- **3 attempts per side** maximum
- Each attempt: kill orphans → launch → wait → health-check
- If all 3 attempts fail: stop, summarize the errors, suggest switching to `debug/` skill

## Output format

Short, structured. Examples:

```
[backend] attempt 1: OK (port 5142, /health HTTP 200 in 6.3s)
[frontend] attempt 1: port 3000 already in use → killed PID 12345 → attempt 2: OK (port 3000, Vite ready)
✓ Stack running — backend: http://localhost:5142 | frontend: http://localhost:3000
```

```
[backend] attempt 1: build failed (CS0246 in UserService.cs:42)
[backend] attempt 2: same error — NOT transient
✗ Backend failed to launch after 3 attempts. Escalate with: claude -p "@.claude/skills/development/debug/backend/SKILL.md"
```

## Rules

- **Never** modify source files (that's `debug/`'s job)
- **Always** kill before launch — stale processes lock DLLs (MSB3026) and ports
- **Always** verify reality (curl the URL, don't trust "Application started")
- **Always** check DB connectivity before declaring backend OK (port binding ≠ application healthy). A 401/403 on `/api/navigation/menu` proves routing + DB are up.
- **Always** check `VITE_API_URL` is reachable before declaring frontend OK. Vite returns 200 on `/` even when its API backend is dead.
- **Fail fast**: if the same error repeats 2x, stop retrying
