@@ -103,8 +103,19 @@ Determine if this is a fork-based workflow:
103103 git diff --cached --stat # Staged changes
104104 git status --porcelain # All changes summary
105105 ```
106- - Slugify the PR title (if provided) or generate from changes: lowercase, replace spaces with hyphens
106+ - ** Sanitize the branch name** (from title or generated):
107+ 1. Lowercase the string
108+ 2. Replace spaces with hyphens
109+ 3. Remove invalid git ref characters: ` :` , ` ? ` , ` * ` , ` [` , ` ]` , ` ^` , ` ~` , ` \` , ` @{` , ` ..`
110+ 4. Replace consecutive hyphens/underscores with single hyphen
111+ 5. Trim leading/trailing hyphens
112+ 6. Truncate to reasonable length (50 chars max for branch name portion)
107113 - Prefix based on change type: ` feature/` , ` fix/` , ` refactor/` , ` docs/`
114+ - ** Validate with git** :
115+ ` ` ` bash
116+ git check-ref-format --branch " <branch-name>"
117+ ```
118+ - If validation fails, prompt user for a valid branch name
108119 - If no diff output and no title provided, prompt user for branch name
109120 - ** Create and switch to the new branch BEFORE staging** :
110121 ` ` ` bash
@@ -123,13 +134,18 @@ Determine if this is a fork-based workflow:
123134 ` ` `
124135
1251362. ** Secret scanning check** (AFTER staging to catch all files):
126- - ** Run deterministic pattern check** :
137+ - ** Run deterministic pattern check** (case-insensitive with expanded patterns):
138+ ` ` ` bash
139+ git diff --cached | grep -iE " (AKIA[A-Z0-9]{16}|ghp_[a-zA-Z0-9]{36}|sk-[a-zA-Z0-9]{48}|gho_[a-zA-Z0-9]{36}|api[_-]?key\s*[=:]|secret[_-]?key\s*[=:]|password\s*[=:]|private[_-]?key|bearer\s+[a-zA-Z0-9_-]+|token\s*[=:])" || true
140+ ` ` `
141+ - ** Check for sensitive file names** (case-insensitive):
127142 ` ` ` bash
128- git diff --cached | grep -E " (AKIA[A-Z0-9]{16}|ghp_[a-zA-Z0-9]{36}|sk-[a-zA-Z0-9]{48}|API_KEY=|SECRET=|PASSWORD=|PRIVATE_KEY) " || true
143+ git diff --cached --name-only | grep -iE " (\.env|credentials|secret|\.pem|\.key|\.p12|\.pfx|id_rsa|id_ed25519)$ " || true
129144 ` ` `
130- - ** Check for sensitive file names ** :
145+ - ** Optional ** : For more thorough scanning, use dedicated tools if available :
131146 ` ` ` bash
132- git diff --cached --name-only | grep -E " (\.env|credentials|secret|\.pem|\.key)$" || true
147+ # gitleaks detect --staged --no-git # If gitleaks installed
148+ # trufflehog git file://. --only-verified --fail # If trufflehog installed
133149 ` ` `
134150 - Pay special attention to newly added files:
135151 ` ` ` bash
0 commit comments