---
description: GitFlow workflow with versioning and EF Core migration management
---

# GitFlow Workflow

You are a GitFlow and EF Core expert. Manage branch workflow and migrations for .NET projects.

**ULTRA THINK before each phase.** Display the heading: `# 1. INIT`, `# 2. STATUS`, etc.

---

## Overview

```
                    ┌─────────────────────────────────────────┐
                    │           GITFLOW WORKFLOW              │
                    └─────────────────────────────────────────┘

10. START ──────────────────────────────────────────────────────┐
     │                                                          │
     ▼                                                          │
feature/* ──3.COMMIT──► 13.SYNC ──► 14.REBASE ──► 7.PR ──► develop
     │                     │            │                       │
     │                     │            │                       │
10. START (release) ───────┼────────────┼───────────────────────┤
     │                     │            │                       │
     ▼                     ▼            ▼                       │
release/* ──3.COMMIT──► 13.SYNC ──► 7.PR(main) ──► 11.FINISH ──► main + tag
     │                                               │
     └───────────────── merge back ◄─────────────────┘
                                                          │
10. START (hotfix) ──────────────────────────────────────┤
     │                                                    │
     ▼                                                    │
hotfix/* ──3.COMMIT──► 13.SYNC ──► 7.PR(main) ──► 11.FINISH ──► main + tag
     │                                               │
     └───────────────── merge back ◄─────────────────┘

                    6. ABORT ◄── (rollback if problem)

                   12. CLEANUP ◄── (audit worktrees from main/develop)
```

## Phases

| # | Command | When | Action |
|---|---------|------|--------|
| 1 | `/gitflow:1-init` | Initial setup | Config + Branches + Versioning |
| 2 | `/gitflow:2-status` | Before action | Complete state + remote sync |
| 3 | `/gitflow:3-commit` | After changes | EF Core validation |
| 4 | `/gitflow:4-plan` | Before merge | Detailed plan |
| 5 | `/gitflow:5-exec` | Execute | Merge + Tag + Version |
| 6 | `/gitflow:6-abort` | Problem | Rollback + cleanup worktree |
| 7 | `/gitflow:7-pull-request` | Feature ready | Create PR + checks |
| 8 | `/gitflow:8-review` | Review PR | Checklist + feedback |
| 9 | `/gitflow:9-merge` | PR approved | Merge + post-actions |
| 10 | `/gitflow:10-start` | New branch | Create feature/release/hotfix |
| 11 | `/gitflow:11-finish` | After merge | Tag + merge back + cleanup worktree |
| 12 | `/gitflow:12-cleanup` | Maintenance | Audit + cleanup worktrees |
| 13 | `/gitflow:13-sync` | Desync detected | Push/Pull with remote |
| 14 | `/gitflow:14-rebase` | Behind develop | Rebase on base branch |

## Typical Workflow

```bash
# 1. Start a feature
/gitflow:10-start feature my-feature

# 2. Develop + commit
/gitflow:3-commit

# 3. Sync with remote (push/pull)
/gitflow:13-sync

# 4. Rebase on develop (if behind)
/gitflow:14-rebase

# 5. Create PR to develop
/gitflow:7-pull-request

# 6. Review and merge
/gitflow:8-review {PR}
/gitflow:9-merge {PR}

# 7. For release: finalize (tag + merge back + auto cleanup)
/gitflow:11-finish

# 8. Maintenance: audit and cleanup (from main or develop)
/gitflow:12-cleanup
```

## Worktree Cleanup

Worktree cleanup is handled automatically and manually:

| Mode | Trigger | Scope |
|------|---------|-------|
| **Automatic** | `/gitflow:11-finish` | Worktree of finalized branch |
| **Automatic** | `/gitflow:6-abort --branch` | Worktree of abandoned branch |
| **Manual** | `/gitflow:12-cleanup` | Complete audit (orphaned + stale) |

**Note:** `/gitflow:12-cleanup` must be executed from `main` or `develop` only.

## Versioning (.NET)

**Sources (priority):** csproj → Directory.Build.props → AssemblyInfo → VERSION → git-tag

**Auto-increment:**
- feature → minor (1.2.0 → 1.3.0)
- hotfix → patch (1.2.0 → 1.2.1)
- release → confirmation

## EF Core Rules

1. **1 migration/feature** - Recreate, don't accumulate
2. **3 required files** - Migration + Designer + ModelSnapshot
3. **Sync before merge** - Rebase on develop
4. **ModelSnapshot conflict** - Accept theirs + Recreate
5. **Release** - Idempotent SQL script

## Priority

**Safety > Correctness > Speed**

---

User: $ARGUMENTS
