You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This extension provides Git operations as an optional, self-contained module. It manages:
8
8
9
9
-**Repository initialization** with configurable commit messages
10
-
-**Feature branch creation** with sequential (`001-feature-name`) or timestamp (`20260319-143022-feature-name`) numbering
10
+
-**Feature branch creation** with sequential (`001-feature-name`) or timestamp (`20260319-143022-feature-name`) numbering and optional templates for branch namespaces
11
11
-**Branch validation** to ensure branches follow naming conventions
12
12
-**Git remote detection** for GitHub integration (e.g., issue creation)
13
13
-**Auto-commit** after core commands (configurable per-command with custom messages)
@@ -53,6 +53,16 @@ Configuration is stored in `.specify/extensions/git/git-config.yml`:
53
53
# Branch numbering strategy: "sequential" or "timestamp"
54
54
branch_numbering: sequential
55
55
56
+
# Optional branch name template. Leave empty for the default "{number}-{slug}".
57
+
# Supported tokens: {author}, {app}, {number}, {slug}; {slug} must not appear
58
+
# before {number}, and the final path segment must start with {number}-.
59
+
# Example for monorepos: "{author}/{app}/{number}-{slug}"
60
+
branch_template: ""
61
+
62
+
# Optional shorthand namespace. Leave empty to use branch_template/default behavior.
63
+
# Example: "features/{app}" expands to "features/{app}/{number}-{slug}"
64
+
branch_prefix: ""
65
+
56
66
# Custom commit message for git init
57
67
init_commit_message: "[Spec Kit] Initial commit"
58
68
@@ -65,6 +75,10 @@ auto_commit:
65
75
message: "[Spec Kit] Add specification"
66
76
```
67
77
78
+
`{author}` is derived from Git config and sanitized for branch names. `{app}` is derived from the Spec Kit init directory name. Custom templates must not put `{slug}` before `{number}`, and must put `{number}-` at the start of the final path segment so generated names remain valid feature branches. For a monorepo project at `apps/web/.specify/`, a template such as `{author}/{app}/{number}-{slug}` produces branches like `jdoe/web/008-guided-tour`.
79
+
80
+
For simple namespace-only customization, `branch_prefix` is also accepted as a shorthand and expands to `<branch_prefix>/{number}-{slug}`.
Copy file name to clipboardExpand all lines: extensions/git/commands/speckit.git.feature.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ You **MUST** consider the user input before proceeding (if not empty).
19
19
If the user explicitly provided `GIT_BRANCH_NAME` (e.g., via environment variable, argument, or in their request), pass it through to the script by setting the `GIT_BRANCH_NAME` environment variable before invoking the script. When `GIT_BRANCH_NAME` is set:
20
20
- The script uses the exact value as the branch name, bypassing all prefix/suffix generation
21
21
-`--short-name`, `--number`, and `--timestamp` flags are ignored
22
-
-`FEATURE_NUM` is extracted from the name if it starts with a numeric prefix, otherwise set to the full branch name
22
+
-`FEATURE_NUM` is extracted when the final path segment starts with a numeric or timestamp feature marker (for example `042-name`, `feat/042-name`, or `jdoe/app/042-name`), otherwise set to the full branch name
23
23
24
24
## Prerequisites
25
25
@@ -35,6 +35,19 @@ Determine the branch numbering strategy by checking configuration in this order:
35
35
3. Check `.specify/init-options.json` for `branch_numbering` value (deprecated, backward compatibility — will be removed in a future release)
36
36
4. Default to `sequential` if none of the above exist
37
37
38
+
## Branch Name Template
39
+
40
+
Check `.specify/extensions/git/git-config.yml` for an optional `branch_template` value. If it is empty or missing, use the default branch shape `{number}-{slug}`. If it is set, `{slug}` must not appear before `{number}`, its final path segment must start with `{number}-`, and the script expands these tokens:
41
+
42
+
-`{author}`: sanitized Git config author (`user.name`, falling back to the email local part)
43
+
-`{app}`: sanitized Spec Kit init directory name
44
+
-`{number}`: sequential number or timestamp
45
+
-`{slug}`: generated short branch slug
46
+
47
+
For monorepos, a template such as `{author}/{app}/{number}-{slug}` creates names like `jdoe/web/008-guided-tour` while preserving per-project feature numbering.
48
+
49
+
The script also accepts `branch_prefix` as a shorthand for simple namespaces; it expands to `<branch_prefix>/{number}-{slug}`.
50
+
38
51
## Execution
39
52
40
53
Generate a concise short name (2-4 words) for the branch:
@@ -54,6 +67,7 @@ Run the appropriate script based on your platform:
54
67
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
55
68
- You must only ever run this script once per feature
56
69
- The JSON output will contain `BRANCH_NAME` and `FEATURE_NUM`
70
+
- Do not manually expand `branch_template`; the script reads the git extension config and applies it consistently
57
71
58
72
## Graceful Degradation
59
73
@@ -64,5 +78,5 @@ If Git is not installed or the current directory is not a Git repository:
64
78
## Output
65
79
66
80
The script outputs JSON with:
67
-
-`BRANCH_NAME`: The branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`)
81
+
-`BRANCH_NAME`: The branch name (e.g., `003-user-auth`, `20260319-143022-user-auth`, or `jdoe/web/003-user-auth`)
68
82
-`FEATURE_NUM`: The numeric or timestamp prefix used
0 commit comments