|
| 1 | +--- |
| 2 | +description: 'Intelligent Git Flow branch creator that analyzes git status/diff and creates appropriate branches following the nvie Git Flow branching model.' |
| 3 | +tools: ['run_in_terminal', 'get_terminal_output'] |
| 4 | +--- |
| 5 | + |
| 6 | +### Instructions |
| 7 | + |
| 8 | +```xml |
| 9 | +<instructions> |
| 10 | + <title>Git Flow Branch Creator</title> |
| 11 | + <description>This prompt analyzes your current git changes using git status and git diff (or git diff --cached), then intelligently determines the appropriate branch type according to the Git Flow branching model and creates a semantic branch name.</description> |
| 12 | + <note> |
| 13 | + Just run this prompt and Copilot will analyze your changes and create the appropriate Git Flow branch for you. |
| 14 | + </note> |
| 15 | +</instructions> |
| 16 | +``` |
| 17 | + |
| 18 | +### Workflow |
| 19 | + |
| 20 | +**Follow these steps:** |
| 21 | + |
| 22 | +1. Run `git status` to review the current repository state and changed files. |
| 23 | +2. Run `git diff` (for unstaged changes) or `git diff --cached` (for staged changes) to analyze the nature of changes. |
| 24 | +3. Analyze the changes using the Git Flow Branch Analysis Framework below. |
| 25 | +4. Determine the appropriate branch type based on the analysis. |
| 26 | +5. Generate a semantic branch name following Git Flow conventions. |
| 27 | +6. Create the branch and switch to it automatically. |
| 28 | +7. Provide a summary of the analysis and next steps. |
| 29 | + |
| 30 | +### Git Flow Branch Analysis Framework |
| 31 | + |
| 32 | +```xml |
| 33 | +<analysis-framework> |
| 34 | + <branch-types> |
| 35 | + <feature> |
| 36 | + <purpose>New features, enhancements, non-critical improvements</purpose> |
| 37 | + <branch-from>develop</branch-from> |
| 38 | + <merge-to>develop</merge-to> |
| 39 | + <naming>feature/descriptive-name or feature/ticket-number-description</naming> |
| 40 | + <indicators> |
| 41 | + <indicator>New functionality being added</indicator> |
| 42 | + <indicator>UI/UX improvements</indicator> |
| 43 | + <indicator>New API endpoints or methods</indicator> |
| 44 | + <indicator>Database schema additions (non-breaking)</indicator> |
| 45 | + <indicator>New configuration options</indicator> |
| 46 | + <indicator>Performance improvements (non-critical)</indicator> |
| 47 | + </indicators> |
| 48 | + </feature> |
| 49 | + |
| 50 | + <release> |
| 51 | + <purpose>Release preparation, version bumps, final testing</purpose> |
| 52 | + <branch-from>develop</branch-from> |
| 53 | + <merge-to>develop AND master</merge-to> |
| 54 | + <naming>release-X.Y.Z</naming> |
| 55 | + <indicators> |
| 56 | + <indicator>Version number changes</indicator> |
| 57 | + <indicator>Build configuration updates</indicator> |
| 58 | + <indicator>Documentation finalization</indicator> |
| 59 | + <indicator>Minor bug fixes before release</indicator> |
| 60 | + <indicator>Release notes updates</indicator> |
| 61 | + <indicator>Dependency version locks</indicator> |
| 62 | + </indicators> |
| 63 | + </release> |
| 64 | + |
| 65 | + <hotfix> |
| 66 | + <purpose>Critical production bug fixes requiring immediate deployment</purpose> |
| 67 | + <branch-from>master</branch-from> |
| 68 | + <merge-to>develop AND master</merge-to> |
| 69 | + <naming>hotfix-X.Y.Z or hotfix/critical-issue-description</naming> |
| 70 | + <indicators> |
| 71 | + <indicator>Security vulnerability fixes</indicator> |
| 72 | + <indicator>Critical production bugs</indicator> |
| 73 | + <indicator>Data corruption fixes</indicator> |
| 74 | + <indicator>Service outage resolution</indicator> |
| 75 | + <indicator>Emergency configuration changes</indicator> |
| 76 | + </indicators> |
| 77 | + </hotfix> |
| 78 | + </branch-types> |
| 79 | +</analysis-framework> |
| 80 | +``` |
| 81 | + |
| 82 | +### Branch Naming Conventions |
| 83 | + |
| 84 | +```xml |
| 85 | +<naming-conventions> |
| 86 | + <feature-branches> |
| 87 | + <format>feature/[ticket-number-]descriptive-name</format> |
| 88 | + <examples> |
| 89 | + <example>feature/user-authentication</example> |
| 90 | + <example>feature/PROJ-123-shopping-cart</example> |
| 91 | + <example>feature/api-rate-limiting</example> |
| 92 | + <example>feature/dashboard-redesign</example> |
| 93 | + </examples> |
| 94 | + </feature-branches> |
| 95 | + |
| 96 | + <release-branches> |
| 97 | + <format>release-X.Y.Z</format> |
| 98 | + <examples> |
| 99 | + <example>release-1.2.0</example> |
| 100 | + <example>release-2.1.0</example> |
| 101 | + <example>release-1.0.0</example> |
| 102 | + </examples> |
| 103 | + </release-branches> |
| 104 | + |
| 105 | + <hotfix-branches> |
| 106 | + <format>hotfix-X.Y.Z OR hotfix/critical-description</format> |
| 107 | + <examples> |
| 108 | + <example>hotfix-1.2.1</example> |
| 109 | + <example>hotfix/security-patch</example> |
| 110 | + <example>hotfix/payment-gateway-fix</example> |
| 111 | + <example>hotfix-2.1.1</example> |
| 112 | + </examples> |
| 113 | + </hotfix-branches> |
| 114 | +</naming-conventions> |
| 115 | +``` |
| 116 | + |
| 117 | +### Analysis Process |
| 118 | + |
| 119 | +```xml |
| 120 | +<analysis-process> |
| 121 | + <step-1> |
| 122 | + <title>Change Nature Analysis</title> |
| 123 | + <description>Examine the types of files modified and the nature of changes</description> |
| 124 | + <criteria> |
| 125 | + <files-modified>Look at file extensions, directory structure, and purpose</files-modified> |
| 126 | + <change-scope>Determine if changes are additive, corrective, or preparatory</change-scope> |
| 127 | + <urgency-level>Assess if changes address critical issues or are developmental</urgency-level> |
| 128 | + </criteria> |
| 129 | + </step-1> |
| 130 | + |
| 131 | + <step-2> |
| 132 | + <title>Git Flow Classification</title> |
| 133 | + <description>Map the changes to appropriate Git Flow branch type</description> |
| 134 | + <decision-tree> |
| 135 | + <question>Are these critical fixes for production issues?</question> |
| 136 | + <if-yes>Consider hotfix branch</if-yes> |
| 137 | + <if-no> |
| 138 | + <question>Are these release preparation changes (version bumps, final tweaks)?</question> |
| 139 | + <if-yes>Consider release branch</if-yes> |
| 140 | + <if-no>Default to feature branch</if-no> |
| 141 | + </if-no> |
| 142 | + </decision-tree> |
| 143 | + </step-2> |
| 144 | + |
| 145 | + <step-3> |
| 146 | + <title>Branch Name Generation</title> |
| 147 | + <description>Create semantic, descriptive branch name</description> |
| 148 | + <guidelines> |
| 149 | + <use-kebab-case>Use lowercase with hyphens</use-kebab-case> |
| 150 | + <be-descriptive>Name should clearly indicate the purpose</be-descriptive> |
| 151 | + <include-context>Add ticket numbers or project context when available</include-context> |
| 152 | + <keep-concise>Avoid overly long names</keep-concise> |
| 153 | + </guidelines> |
| 154 | + </step-3> |
| 155 | +</analysis-process> |
| 156 | +``` |
| 157 | + |
| 158 | +### Edge Cases and Validation |
| 159 | + |
| 160 | +```xml |
| 161 | +<edge-cases> |
| 162 | + <mixed-changes> |
| 163 | + <scenario>Changes include both features and bug fixes</scenario> |
| 164 | + <resolution>Prioritize the most significant change type or suggest splitting into multiple branches</resolution> |
| 165 | + </mixed-changes> |
| 166 | + |
| 167 | + <no-changes> |
| 168 | + <scenario>No changes detected in git status/diff</scenario> |
| 169 | + <resolution>Inform user and suggest checking git status or making changes first</resolution> |
| 170 | + </no-changes> |
| 171 | + |
| 172 | + <existing-branch> |
| 173 | + <scenario>Already on a feature/hotfix/release branch</scenario> |
| 174 | + <resolution>Analyze if new branch is needed or if current branch is appropriate</resolution> |
| 175 | + </existing-branch> |
| 176 | + |
| 177 | + <conflicting-names> |
| 178 | + <scenario>Suggested branch name already exists</scenario> |
| 179 | + <resolution>Append incremental suffix or suggest alternative name</resolution> |
| 180 | + </conflicting-names> |
| 181 | +</edge-cases> |
| 182 | +``` |
| 183 | + |
| 184 | +### Examples |
| 185 | + |
| 186 | +```xml |
| 187 | +<examples> |
| 188 | + <example-1> |
| 189 | + <scenario>Added new user registration API endpoint</scenario> |
| 190 | + <analysis>New functionality, additive changes, not critical</analysis> |
| 191 | + <branch-type>feature</branch-type> |
| 192 | + <branch-name>feature/user-registration-api</branch-name> |
| 193 | + <command>git checkout -b feature/user-registration-api develop</command> |
| 194 | + </example-1> |
| 195 | + |
| 196 | + <example-2> |
| 197 | + <scenario>Fixed critical security vulnerability in authentication</scenario> |
| 198 | + <analysis>Security fix, critical for production, immediate deployment needed</analysis> |
| 199 | + <branch-type>hotfix</branch-type> |
| 200 | + <branch-name>hotfix/auth-security-patch</branch-name> |
| 201 | + <command>git checkout -b hotfix/auth-security-patch master</command> |
| 202 | + </example-2> |
| 203 | + |
| 204 | + <example-3> |
| 205 | + <scenario>Updated version to 2.1.0 and finalized release notes</scenario> |
| 206 | + <analysis>Release preparation, version bump, documentation</analysis> |
| 207 | + <branch-type>release</branch-type> |
| 208 | + <branch-name>release-2.1.0</branch-name> |
| 209 | + <command>git checkout -b release-2.1.0 develop</command> |
| 210 | + </example-3> |
| 211 | + |
| 212 | + <example-4> |
| 213 | + <scenario>Improved database query performance and updated caching</scenario> |
| 214 | + <analysis>Performance improvement, non-critical enhancement</analysis> |
| 215 | + <branch-type>feature</branch-type> |
| 216 | + <branch-name>feature/database-performance-optimization</branch-name> |
| 217 | + <command>git checkout -b feature/database-performance-optimization develop</command> |
| 218 | + </example-4> |
| 219 | +</examples> |
| 220 | +``` |
| 221 | + |
| 222 | +### Validation Checklist |
| 223 | + |
| 224 | +```xml |
| 225 | +<validation> |
| 226 | + <pre-analysis> |
| 227 | + <check>Repository is in a clean state (no uncommitted changes that would conflict)</check> |
| 228 | + <check>Current branch is appropriate starting point (develop for features/releases, master for hotfixes)</check> |
| 229 | + <check>Remote repository is up to date</check> |
| 230 | + </pre-analysis> |
| 231 | + |
| 232 | + <analysis-quality> |
| 233 | + <check>Change analysis covers all modified files</check> |
| 234 | + <check>Branch type selection follows Git Flow principles</check> |
| 235 | + <check>Branch name is semantic and follows conventions</check> |
| 236 | + <check>Edge cases are considered and handled</check> |
| 237 | + </analysis-quality> |
| 238 | + |
| 239 | + <execution-safety> |
| 240 | + <check>Target branch (develop/master) exists and is accessible</check> |
| 241 | + <check>Proposed branch name doesn't conflict with existing branches</check> |
| 242 | + <check>User has appropriate permissions to create branches</check> |
| 243 | + </execution-safety> |
| 244 | +</validation> |
| 245 | +``` |
| 246 | + |
| 247 | +### Final Execution |
| 248 | + |
| 249 | +```xml |
| 250 | +<execution-protocol> |
| 251 | + <analysis-summary> |
| 252 | + <git-status>Output of git status command</git-status> |
| 253 | + <git-diff>Relevant portions of git diff output</git-diff> |
| 254 | + <change-analysis>Detailed analysis of what changes represent</change-analysis> |
| 255 | + <branch-decision>Explanation of why specific branch type was chosen</branch-decision> |
| 256 | + </analysis-summary> |
| 257 | + |
| 258 | + <branch-creation> |
| 259 | + <command>git checkout -b [branch-name] [source-branch]</command> |
| 260 | + <confirmation>Verify branch creation and current branch status</confirmation> |
| 261 | + <next-steps>Provide guidance on next actions (commit changes, push branch, etc.)</next-steps> |
| 262 | + </branch-creation> |
| 263 | + |
| 264 | + <fallback-options> |
| 265 | + <alternative-names>Suggest 2-3 alternative branch names if primary suggestion isn't suitable</alternative-names> |
| 266 | + <manual-override>Allow user to specify different branch type if analysis seems incorrect</manual-override> |
| 267 | + </fallback-options> |
| 268 | +</execution-protocol> |
| 269 | +``` |
| 270 | + |
| 271 | +### Git Flow Reference |
| 272 | + |
| 273 | +```xml |
| 274 | +<gitflow-reference> |
| 275 | + <main-branches> |
| 276 | + <master>Production-ready code, every commit is a release</master> |
| 277 | + <develop>Integration branch for features, latest development changes</develop> |
| 278 | + </main-branches> |
| 279 | + |
| 280 | + <supporting-branches> |
| 281 | + <feature>Branch from develop, merge back to develop</feature> |
| 282 | + <release>Branch from develop, merge to both develop and master</release> |
| 283 | + <hotfix>Branch from master, merge to both develop and master</hotfix> |
| 284 | + </supporting-branches> |
| 285 | + |
| 286 | + <merge-strategy> |
| 287 | + <flag>Always use --no-ff flag to preserve branch history</flag> |
| 288 | + <tagging>Tag releases on master branch</tagging> |
| 289 | + <cleanup>Delete branches after successful merge</cleanup> |
| 290 | + </merge-strategy> |
| 291 | +</gitflow-reference> |
| 292 | +``` |
0 commit comments