mirror of
https://github.com/github/spec-kit.git
synced 2026-07-03 12:28:06 +08:00
* feat(scripts): add SPECIFY_INIT_DIR to target a member project from the repo root Resolve an explicit SPECIFY_INIT_DIR project override once in the core get_repo_root / Get-RepoRoot, so a non-interactive / CI caller can target a member project (the directory containing .specify/) from a monorepo root without cd. Strict by design: the path must exist and contain .specify/, otherwise it hard-errors with no silent fallback. - Single resolver in core; the git feature-branch script inherits it by sourcing core, with no per-extension copies. - PS resolver verifies the resolved path is a directory (Resolve-Path also succeeds for files) so a file value errors as "not an existing directory". - get_feature_paths splits decl/assignment so a SPECIFY_INIT_DIR failure propagates instead of being masked by `local`. - create-new-feature-branch: when core is absent (only git-common loaded) and SPECIFY_INIT_DIR is set, hard-error rather than silently using the git root. - Document SPECIFY_INIT_DIR and SPECIFY_FEATURE_DIRECTORY in the core reference. - Tests for valid/relative/trailing-slash/file/missing/no-.specify targets, feature-axis composition, the no-core guard, and a PowerShell mirror. * fix: guard SPECIFY_INIT_DIR with stale core scripts * docs: clarify SPECIFY_FEATURE_DIRECTORY precedence wording * fix: normalize trailing slash in PowerShell SPECIFY_INIT_DIR resolver Resolve-Path preserves a trailing separator from its input, so a SPECIFY_INIT_DIR ending in a slash returned a root that didn't match the bash resolver (whose `cd && pwd` strips it). That broke test_ps_trailing_slash_tolerated on the CI runners, which do have pwsh. Trim it with TrimEndingDirectorySeparator (no-op on a bare root or a path with no trailing separator). Also fix the misleading test comment: the PowerShell mirror runs on the CI ubuntu/windows runners (they ship pwsh), it is not skipped there. * test: normalize bash path expectations on Windows * docs: clarify SPECIFY_INIT_DIR root helpers
Git Branching Workflow Extension
Git repository initialization, feature branch creation, numbering (sequential/timestamp), validation, remote detection, and auto-commit for Spec Kit.
Overview
This extension provides Git operations as an optional, self-contained module. It manages:
- Repository initialization with configurable commit messages
- Feature branch creation with sequential (
001-feature-name) or timestamp (20260319-143022-feature-name) numbering - Branch validation to ensure branches follow naming conventions
- Git remote detection for GitHub integration (e.g., issue creation)
- Auto-commit after core commands (configurable per-command with custom messages)
Commands
| Command | Description |
|---|---|
speckit.git.initialize |
Initialize a Git repository with a configurable commit message |
speckit.git.feature |
Create a feature branch with sequential or timestamp numbering |
speckit.git.validate |
Validate current branch follows feature branch naming conventions |
speckit.git.remote |
Detect Git remote URL for GitHub integration |
speckit.git.commit |
Auto-commit changes (configurable per-command enable/disable and messages) |
Hooks
| Event | Command | Optional | Description |
|---|---|---|---|
before_constitution |
speckit.git.initialize |
No | Init git repo before constitution |
before_specify |
speckit.git.feature |
No | Create feature branch before specification |
before_clarify |
speckit.git.commit |
Yes | Commit outstanding changes before clarification |
before_plan |
speckit.git.commit |
Yes | Commit outstanding changes before planning |
before_tasks |
speckit.git.commit |
Yes | Commit outstanding changes before task generation |
before_implement |
speckit.git.commit |
Yes | Commit outstanding changes before implementation |
before_checklist |
speckit.git.commit |
Yes | Commit outstanding changes before checklist |
before_analyze |
speckit.git.commit |
Yes | Commit outstanding changes before analysis |
before_taskstoissues |
speckit.git.commit |
Yes | Commit outstanding changes before issue sync |
after_constitution |
speckit.git.commit |
Yes | Auto-commit after constitution update |
after_specify |
speckit.git.commit |
Yes | Auto-commit after specification |
after_clarify |
speckit.git.commit |
Yes | Auto-commit after clarification |
after_plan |
speckit.git.commit |
Yes | Auto-commit after planning |
after_tasks |
speckit.git.commit |
Yes | Auto-commit after task generation |
after_implement |
speckit.git.commit |
Yes | Auto-commit after implementation |
after_checklist |
speckit.git.commit |
Yes | Auto-commit after checklist |
after_analyze |
speckit.git.commit |
Yes | Auto-commit after analysis |
after_taskstoissues |
speckit.git.commit |
Yes | Auto-commit after issue sync |
Configuration
Configuration is stored in .specify/extensions/git/git-config.yml:
# Branch numbering strategy: "sequential" or "timestamp"
branch_numbering: sequential
# Custom commit message for git init
init_commit_message: "[Spec Kit] Initial commit"
# Auto-commit per command (all disabled by default)
# Example: enable auto-commit after specify
auto_commit:
default: false
after_specify:
enabled: true
message: "[Spec Kit] Add specification"
Installation
# Install the bundled git extension (no network required)
specify extension add git
Disabling
# Disable the git extension (spec creation continues without branching)
specify extension disable git
# Re-enable it
specify extension enable git
Graceful Degradation
When Git is not installed or the directory is not a Git repository:
- Spec directories are still created under
specs/ - Branch creation is skipped with a warning
- Branch validation is skipped with a warning
- Remote detection returns empty results
Scripts
The extension bundles cross-platform scripts:
scripts/bash/create-new-feature-branch.sh— Bash implementation (branch creation only)scripts/bash/git-common.sh— Shared Git utilities (Bash)scripts/powershell/create-new-feature-branch.ps1— PowerShell implementation (branch creation only)scripts/powershell/git-common.ps1— Shared Git utilities (PowerShell)