---
name: status
description: Complete GitFlow state diagnostic
---

# Phase: STATUS - Diagnostic

## YOUR TASK:

Display complete GitFlow state including branches, worktrees, remotes, and pending work.

---

## EXECUTION:

### 1. Load Config and Repository Info

```bash
# Detect platform first (needed for path translation)
detect_platform

# Load GitFlow config (sets GF_* variables, translates paths for current platform)
read_gitflow_config || { echo "❌ Run /gitflow init first."; exit 1; }

REPO_NAME="$GF_PROJECT_NAME"
CURRENT=$(git rev-parse --abbrev-ref HEAD)
GIT_PROVIDER="$GF_PROVIDER"

# Workspace info (v2.1.0+)
WS_FILE=$(resolve_workspace_path 2>/dev/null)
```

### 2. Branch Status

```bash
git fetch origin --quiet

# Main branches (from config)
MAIN_LOCAL=$(git rev-parse --short $GF_MAIN_BRANCH 2>/dev/null || echo "N/A")
MAIN_REMOTE=$(git rev-parse --short origin/$GF_MAIN_BRANCH 2>/dev/null || echo "N/A")
DEVELOP_LOCAL=$(git rev-parse --short $GF_DEVELOP_BRANCH 2>/dev/null || echo "N/A")
DEVELOP_REMOTE=$(git rev-parse --short origin/$GF_DEVELOP_BRANCH 2>/dev/null || echo "N/A")

# Divergence
DEVELOP_AHEAD=$(git rev-list --count origin/$GF_MAIN_BRANCH..origin/$GF_DEVELOP_BRANCH 2>/dev/null || echo "0")
```

### 3. Active Branches

```bash
# Feature branches (using prefixes from config)
FEATURES=$(git branch -r | grep "origin/${GF_FEATURE_PREFIX}" | sed 's/origin\///')

# Release branches
RELEASES=$(git branch -r | grep "origin/${GF_RELEASE_PREFIX}" | sed 's/origin\///')

# Hotfix branches
HOTFIXES=$(git branch -r | grep "origin/${GF_HOTFIX_PREFIX}" | sed 's/origin\///')
```

### 4. Worktree Status

```bash
# Repair cross-platform paths before listing (WSL ↔ Windows)
detect_platform
repair_worktree_paths "$(git rev-parse --git-common-dir 2>/dev/null || echo '.bare')"

WORKTREES=$(git worktree list)
WORKTREE_COUNT=$(echo "$WORKTREES" | wc -l)

# Check for orphaned worktrees (normalize paths for cross-platform compatibility)
ORPHANED=""
while read -r line; do
  WT_PATH=$(echo "$line" | awk '{print $1}')
  WT_PATH=$(normalize_path_for_platform "$WT_PATH")
  BRANCH=$(echo "$line" | awk '{print $3}' | tr -d '[]')
  [ ! -d "$WT_PATH" ] && ORPHANED="$ORPHANED\n$WT_PATH ($BRANCH)"
done <<< "$WORKTREES"
```

### 5. Pending Changes

```bash
# Current branch changes
STAGED=$(git diff --cached --name-only | wc -l)
MODIFIED=$(git diff --name-only | wc -l)
UNTRACKED=$(git ls-files --others --exclude-standard | wc -l)

# Unpushed commits
UNPUSHED=$(git rev-list --count origin/$CURRENT..HEAD 2>/dev/null || echo "0")
```

### 6. EF Core Status

```bash
# Check for migrations
MIGRATIONS=$(find . -path "*/Migrations/*.cs" -not -name "*Designer*" -not -name "*Snapshot*" 2>/dev/null | wc -l)

# Check migration status
if command -v dotnet &> /dev/null; then
  PENDING=$(dotnet ef migrations list 2>/dev/null | grep -c "(Pending)" || echo "0")
fi
```

### 7. Display Status

```
╔══════════════════════════════════════════════════════════════════╗
║                    GITFLOW STATUS                                 ║
╠══════════════════════════════════════════════════════════════════╣
║  Repository: {REPO_NAME}                                          ║
║  Provider:   {GIT_PROVIDER}                                       ║
║  Platform:   {GF_PLATFORM} ({GF_SHELL})                           ║
║  Current:    {CURRENT}                                            ║
{if WS_FILE}
║  Workspace:  {dirname(WS_FILE)}                                   ║
{endif}
╠══════════════════════════════════════════════════════════════════╣

## Main Branches

| Branch | Local | Remote | Status |
|--------|-------|--------|--------|
| main | {MAIN_LOCAL} | {MAIN_REMOTE} | {synced/diverged} |
| develop | {DEVELOP_LOCAL} | {DEVELOP_REMOTE} | {synced/diverged} |

develop → main: {DEVELOP_AHEAD} commits {DEVELOP_AHEAD > 10 ? "⚠️ Release recommended" : ""}

## Active Branches

**Features:** {count}
{list of feature branches with status}

**Releases:** {count}
{list of release branches}

**Hotfixes:** {count}
{list of hotfix branches}

## Worktrees

| Path | Branch | Status |
|------|--------|--------|
{worktree list with status}

{if orphaned}
⚠️ Orphaned worktrees detected:
{list}
→ Run: /gitflow cleanup
{endif}

## Working Directory

| Type | Count |
|------|-------|
| Staged | {STAGED} |
| Modified | {MODIFIED} |
| Untracked | {UNTRACKED} |
| Unpushed | {UNPUSHED} |

## EF Core

| Metric | Value |
|--------|-------|
| Migrations | {MIGRATIONS} |
| Pending | {PENDING} |

╚══════════════════════════════════════════════════════════════════╝

## Recommended Actions

{if UNPUSHED > 0}
- Push commits: /gitflow sync
{endif}
{if DEVELOP_AHEAD > 10}
- Create release: /gitflow start release
{endif}
{if ORPHANED}
- Clean worktrees: /gitflow cleanup
{endif}
{if STAGED + MODIFIED > 0}
- Commit changes: /gitflow commit
{endif}
```

---

## SUCCESS CRITERIA:

- Complete state displayed
- Recommendations provided
- No actions taken (diagnostic only)
