# GitFlow Config Template (v2.1.0)

## Configuration JSON

Write `.claude/gitflow/config.json` in develop worktree.

**IMPORTANT:** Store paths using `normalize_path_for_storage()` format (Windows-style: `D:/path/to/folder`). The `read_gitflow_config()` in `_shared.md` translates them to platform format at read time.

```json
{
  "version": "2.1.0",
  "platform": {
    "detected": "{GF_PLATFORM}",
    "shell": "{GF_SHELL}",
    "detectedAt": "{ISO_DATE}"
  },
  "workspace": {
    "path": "{WORKSPACE_DIR_STORAGE_FORMAT}",
    "name": ""
  },
  "repository": {
    "name": "{PROJECT_NAME}",
    "rootFolder": "{ROOT_FOLDER_STORAGE_FORMAT}",
    "nameVariants": {
      "pascalCaseDot": "{PascalCase.Dot}",
      "pascalCase": "{PascalCase}",
      "kebabCase": "{kebab-case}",
      "snakeCase": "{snake_case}",
      "displayName": "{Display Name}"
    },
    "defaultBranch": "main",
    "remoteUrl": "{REPO_URL}"
  },
  "git": {
    "provider": "{GIT_PROVIDER}",
    "branches": {
      "main": "main",
      "develop": "develop"
    },
    "prefixes": {
      "feature": "feature/",
      "release": "release/",
      "hotfix": "hotfix/"
    }
  },
  "worktrees": {
    "enabled": true,
    "mode": "{WORKTREE_MODE}",
    "structure": {
      "main": "{ROOT_FOLDER_STORAGE_FORMAT}/{MAIN_DIR}",
      "develop": "{ROOT_FOLDER_STORAGE_FORMAT}/{DEVELOP_DIR}",
      "features": "{ROOT_FOLDER_STORAGE_FORMAT}/features",
      "releases": "{ROOT_FOLDER_STORAGE_FORMAT}/releases",
      "hotfixes": "{ROOT_FOLDER_STORAGE_FORMAT}/hotfixes"
    }
  },
  "versioning": {
    "strategy": "semver",
    "current": "{VERSION}",
    "tagPrefix": "v",
    "sources": ["csproj", "package.json", "VERSION"]
  },
  "efcore": {
    "enabled": true,
    "validateOnCommit": true,
    "blockDestructive": true,
    "migrationNaming": "{context}_v{version}_{sequence}_{Description}"
  },
  "workflow": {
    "push": { "afterCommit": "worktree" },
    "pr": { "autoLabels": true, "requireReview": true }
  },
  "language": { "code": "{GF_LANG}" }
}
```

**Worktree mode directories:**

| Mode | `{MAIN_DIR}` | `{DEVELOP_DIR}` |
|------|-------------|-----------------|
| organized | `01-Main` | `02-Develop` |
| simple | `main` | `develop` |
| disabled | N/A | N/A (no worktrees, `enabled: false`) |

## Path Storage Convention

- `{ROOT_FOLDER_STORAGE_FORMAT}` = result of `normalize_path_for_storage("{ROOT_FOLDER}")`
- On WSL: `/mnt/d/projects/MyApp` -> stored as `D:/projects/MyApp`
- On Windows: `D:\projects\MyApp` -> stored as `D:/projects/MyApp`
- On Linux/macOS: `/home/user/projects/MyApp` -> stored as-is

## Post-Init Validation

```bash
PROJECT_BASE="{ROOT_FOLDER}"
MAIN_DIR=$([ "$WORKTREE_MODE" = "organized" ] && echo "01-Main" || echo "main")
DEVELOP_DIR=$([ "$WORKTREE_MODE" = "organized" ] && echo "02-Develop" || echo "develop")
ERRORS=0

# Verify bare repo
[ -f "$PROJECT_BASE/.bare/HEAD" ] && echo "OK .bare/HEAD" || { echo "FAIL .bare/HEAD missing"; ERRORS=$((ERRORS+1)); }

# Verify worktrees on correct branches
MAIN_BRANCH=$(git -C "$PROJECT_BASE/$MAIN_DIR" branch --show-current 2>/dev/null)
[ "$MAIN_BRANCH" = "main" ] && echo "OK $MAIN_DIR on main" || { echo "FAIL $MAIN_DIR on '$MAIN_BRANCH'"; ERRORS=$((ERRORS+1)); }

DEVELOP_BRANCH=$(git -C "$PROJECT_BASE/$DEVELOP_DIR" branch --show-current 2>/dev/null)
[ "$DEVELOP_BRANCH" = "develop" ] && echo "OK $DEVELOP_DIR on develop" || { echo "FAIL $DEVELOP_DIR on '$DEVELOP_BRANCH'"; ERRORS=$((ERRORS+1)); }

# Verify directories
for subdir in features releases hotfixes; do
  [ -d "$PROJECT_BASE/$subdir" ] && echo "OK $subdir/" || { echo "FAIL $subdir/ missing"; ERRORS=$((ERRORS+1)); }
done

# Verify config directory
[ -d "$PROJECT_BASE/$DEVELOP_DIR/.claude/gitflow" ] && echo "OK .claude/gitflow/" || { echo "FAIL .claude/gitflow/ missing"; ERRORS=$((ERRORS+1)); }

echo ""
[ "$ERRORS" -eq 0 ] && echo "VALIDATION: ALL CHECKS PASSED" || echo "VALIDATION: $ERRORS error(s) detected"
```

## Workspace Mode (`--workspace`)

When called with `init --workspace`, batch-initialize all repos in a workspace.

### Workspace Execution Sequence:

1. **Ask workspace directory** (AskUserQuestion: parent folder or custom path)
2. **Detect or ask for repos** (scan workspace for git repos or enter URLs)
3. **Create `.smartstack-workspace.json`:**
```json
{
  "version": "1.0.0",
  "name": "{WORKSPACE_NAME}",
  "createdAt": "{ISO_DATE}",
  "updatedAt": "{ISO_DATE}",
  "platform": { "detected": "{GF_PLATFORM}", "shell": "{GF_SHELL}" },
  "repositories": [],
  "defaults": { "provider": "{GIT_PROVIDER}", "worktreeMode": "organized", "language": "en" }
}
```
4. **Loop: For each repo, run Steps 1-10b with workspace defaults pre-populated.**
5. **Display global summary** with all repos initialized.
