# Environment Detection

## Platform and Git Detection

```bash
# PLATFORM DETECTION (required for correct path handling on WSL/Windows/macOS/Linux)
if [ -f /proc/version ] && grep -qi "microsoft\|wsl" /proc/version 2>/dev/null; then
  GF_PLATFORM="wsl"; GF_SHELL="bash"
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "mingw"* ]] || [[ "$OSTYPE" == "cygwin" ]]; then
  GF_PLATFORM="windows"; GF_SHELL="gitbash"
elif [[ -n "$WINDIR" ]] || [[ -n "$SystemRoot" ]]; then
  GF_PLATFORM="windows"; GF_SHELL="powershell"
elif [[ "$OSTYPE" == "darwin"* ]]; then
  GF_PLATFORM="macos"; GF_SHELL="zsh"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
  GF_PLATFORM="linux"; GF_SHELL="bash"
else
  GF_PLATFORM="unknown"; GF_SHELL="bash"
fi
echo "Platform: $GF_PLATFORM ($GF_SHELL)"

# Check if we're in a git repository
IS_GIT_REPO=$(git rev-parse --git-dir 2>/dev/null && echo "true" || echo "false")

# Auto-detect values for defaults (will be confirmed by user)
DETECTED_URL=$(git remote get-url origin 2>/dev/null || echo "")
DETECTED_FOLDER=$(dirname "$(pwd)")
DETECTED_NAME=$(basename -s .git "$DETECTED_URL" 2>/dev/null || basename "$(pwd)")

# Detect git provider
if [[ "$DETECTED_URL" == *"github.com"* ]]; then
  GIT_PROVIDER="github"
elif [[ "$DETECTED_URL" == *"dev.azure.com"* ]]; then
  GIT_PROVIDER="azuredevops"
else
  GIT_PROVIDER="unknown"
fi

# Check if already initialized
ALREADY_INITIALIZED=$([ -f ".claude/gitflow/config.json" ] && echo "true" || echo "false")
```
