speckit.git.initialize — Claude Code command: initialize Git
The speckit.git.initialize command sets up a Git repository in your project and creates an initial commit if one doesn't exist. Use it when starting a new project or preparing a template.
MIT ★ 110 updated 2026-10-19
.claude/commands/speckit.git.initialize.mdWhat speckit.git.initialize does
The command checks whether Git is installed and the directory is already in a repository. If not, it runs git init, stages all files, and creates a commit with the message “Initial commit from Specify template”.
It first looks for ready-made scripts in .specify/extensions/git/scripts/ (bash or PowerShell depending on your OS), and falls back to running commands directly if those scripts aren't found. If Git isn't installed, the command issues a warning and continues—your project stays functional, and you can still create specs without a repository.
You can customize it for your needs: add a custom .gitignore, set a non-standard default branch name, enable Git LFS, install hooks, or configure commit signing.
What it helps with
- set up a Git repository with an initial commit in a new project
- check whether a repository already exists before creating one
- stage all project files in the first commit automatically
- configure Git with a custom default branch name or additional options
Example prompts for the agent
- Initialize Git in this project
- Create a repository with an initial commit
- Set up Git to use the
mainbranch by default
How to install speckit.git.initialize
Manually: put the files in place
.claude/commands/speckit.git.initialize.mdCall it with /speckit.git.initialize. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/speckit.git.initialize.mdCall it with /prompts:speckit.git.initialize. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/speckit.git.initialize.prompt.mdManually: put the files in place
.gemini/commands/speckit.git.initialize.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about speckit.git.initialize
How do I install speckit.git.initialize in Claude Code?
Place the file .claude/commands/speckit.git.initialize.md in the .claude/commands/ folder of your project. The command will be available in Claude Code automatically.
What does speckit.git.initialize do?
It creates a Git repository in the current directory (if one doesn't exist) and makes an initial commit with all project files. If Git is not installed, it shows a warning and continues running.
What happens if a repository already exists?
The command detects an existing repository and skips initialization, leaving it unchanged.
Source text
speckit.git.initialize.md · MIT
--- description: "Initialize a Git repository with an initial commit" --- # Initialize Git Repository Initialize a Git repository in the current project directory if one does not already exist. ## Execution Run the appropriate script from the project root: - **Bash**: `.specify/extensions/git/scripts/bash/initialize-repo.sh` - **PowerShell**: `.specify/extensions/git/scripts/powershell/initialize-repo.ps1` If the extension scripts are not found, fall back to: - **Bash**: `git init && git add . && git commit -m "Initial commit from Specify template"` - **PowerShell**: `git init; git add .; git commit -m "Initial commit from Specify template"` The script handles all checks internally: - Skips if Git is not available - Skips if already inside a Git repository - Runs `git init`, `git add .`, and `git commit` with an initial commit message ## Customization Replace the script to add project-specific Git initialization steps: - Custom `.gitignore` templates - Default branch naming (`git config init.defaultBranch`) - Git LFS setup - Git hooks installation - Commit signing configuration - Git Flow initialization ## Output On success: - `[OK] Git repository initialized` ## Graceful Degradation If Git is not installed: - Warn the user - Skip repository initialization - The project continues to function without Git (specs can still be created under `specs/`) If Git is installed but `git init`, `git add .`, or `git commit` fails: - Surface the error to the user - Stop this command rather than continuing with a partially initialized repository
© alfredoperez · MIT · alfredoperez/speckit-companion