|
| 1 | +--- |
| 2 | +description: "Create a feature branch with sequential or timestamp numbering" |
| 3 | +scripts: |
| 4 | + sh: ../../scripts/bash/create-new-feature.sh |
| 5 | + ps: ../../scripts/powershell/create-new-feature.ps1 |
| 6 | +--- |
| 7 | + |
| 8 | +# Create Feature Branch |
| 9 | + |
| 10 | +Create a new feature branch for the given specification. |
| 11 | + |
| 12 | +## User Input |
| 13 | + |
| 14 | +```text |
| 15 | +$ARGUMENTS |
| 16 | +``` |
| 17 | + |
| 18 | +You **MUST** consider the user input before proceeding (if not empty). |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Verify Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null` |
| 23 | +- If Git is not available, warn the user and skip branch creation (spec directory will still be created) |
| 24 | + |
| 25 | +## Branch Numbering Mode |
| 26 | + |
| 27 | +Determine the branch numbering strategy by checking configuration in this order: |
| 28 | + |
| 29 | +1. Check `.specify/extensions/git/git-config.yml` for `branch_numbering` value |
| 30 | +2. Check `.specify/init-options.json` for `branch_numbering` value (backward compatibility) |
| 31 | +3. Default to `sequential` if neither exists |
| 32 | + |
| 33 | +## Execution |
| 34 | + |
| 35 | +Generate a concise short name (2-4 words) for the branch: |
| 36 | +- Analyze the feature description and extract the most meaningful keywords |
| 37 | +- Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug") |
| 38 | +- Preserve technical terms and acronyms (OAuth2, API, JWT, etc.) |
| 39 | + |
| 40 | +Run the appropriate script based on your platform: |
| 41 | + |
| 42 | +- **Bash**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --short-name "<short-name>" "<feature description>"` |
| 43 | +- **Bash (timestamp)**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --timestamp --short-name "<short-name>" "<feature description>"` |
| 44 | +- **PowerShell**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -ShortName "<short-name>" "<feature description>"` |
| 45 | +- **PowerShell (timestamp)**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -Timestamp -ShortName "<short-name>" "<feature description>"` |
| 46 | + |
| 47 | +**IMPORTANT**: |
| 48 | +- Do NOT pass `--number` — the script determines the correct next number automatically |
| 49 | +- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably |
| 50 | +- You must only ever run this script once per feature |
| 51 | +- The JSON output will contain BRANCH_NAME and SPEC_FILE paths |
| 52 | + |
| 53 | +If the extension scripts are not found at the `.specify/extensions/git/` path, fall back to: |
| 54 | +- **Bash**: `scripts/bash/create-new-feature.sh` |
| 55 | +- **PowerShell**: `scripts/powershell/create-new-feature.ps1` |
| 56 | + |
| 57 | +## Graceful Degradation |
| 58 | + |
| 59 | +If Git is not installed or the current directory is not a Git repository: |
| 60 | +- The script will still create the spec directory under `specs/` |
| 61 | +- A warning will be printed: `[specify] Warning: Git repository not detected; skipped branch creation` |
| 62 | +- The workflow continues normally without branch creation |
| 63 | + |
| 64 | +## Output |
| 65 | + |
| 66 | +The script outputs JSON with: |
| 67 | +- `BRANCH_NAME`: The created branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`) |
| 68 | +- `SPEC_FILE`: Path to the created spec file |
| 69 | +- `FEATURE_NUM`: The numeric or timestamp prefix used |
0 commit comments