# /feature — End-to-End Feature Builder

End-to-end feature development workflow. Creates worktree, plans (waits for approval), implements, verifies, commits, pushes, creates PR.

## Usage

```
/feature <branch-name> <description>
```

**Examples:**
- `/feature auth-oauth Add OAuth2 login with Google`
- `/feature voice-agent Implement ElevenLabs voice agent panel`
- `/feature billing-v2 Redesign billing management with Stripe`

## Arguments

Parse the user's input:
- First word after `/feature` = branch name (kebab-case)
- Everything after = feature description

If no branch name provided, ask the user for one.

## Workflow

### Phase 1: Setup
1. Confirm current git status — ensure working tree is clean (stash or commit if needed)
2. Create a git worktree for the feature:
   ```bash
   git worktree add ../mawidi-<branch-name> -b feature/<branch-name>
   ```
3. Change working context to the new worktree directory
4. Verify the worktree is set up correctly: `git branch --show-current`

### Phase 2: Planning (WAIT FOR APPROVAL)
1. Read the relevant domain files from `.claude/domains/` based on the feature description:
   - UI/components → `.claude/domains/frontend.md`
   - API/auth/DB → `.claude/domains/backend.md`
   - Docker/env → `.claude/domains/infrastructure.md`
   - Testing → `.claude/domains/testing.md`
2. Explore the codebase to understand existing patterns related to the feature
3. Create a detailed implementation plan including:
   - Files to create/modify
   - Architecture decisions
   - Test plan (what tests to write)
   - Potential risks
4. **Present plan to user and WAIT for approval before proceeding**

### Phase 3: Implementation
1. Write tests first (TDD approach per CLAUDE.md rules)
2. Implement the feature following existing patterns
3. Use parallel Task agents for independent parts of the implementation
4. After implementation, run verification:
   ```bash
   npx tsc --noEmit          # TypeScript check
   npx next lint              # ESLint
   npm run test:unit          # Jest unit tests
   ```

### Phase 4: Ship
1. Stage and commit all changes:
   ```bash
   git add <specific-files>
   git commit -m "feat(<scope>): <description>"
   ```
2. Push the branch:
   ```bash
   git push -u origin feature/<branch-name>
   ```
3. Create PR using gh CLI:
   ```bash
   gh pr create --title "<title>" --body "<body>"
   ```
4. Report PR URL to user
5. Ask user: "Ready to merge, or do you want to review first?"

### Phase 5: Cleanup (if merge approved)
1. Merge the PR: `gh pr merge --squash`
2. Remove the worktree: `git worktree remove ../mawidi-<branch-name>`
3. Delete the local branch: `git branch -d feature/<branch-name>`

## Key Rules
- NEVER skip the planning phase
- ALWAYS wait for user approval before implementing
- ALWAYS run verification before shipping
- ALWAYS commit immediately after changes
- Use `npx prisma` not global prisma
- Port is always 9000
- Follow conventional commits: `feat:`, `fix:`, `chore:`, `refactor:`
