Skip to main content
command CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/speckit.git.initialize.md
Open on GitHub

What 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 main branch by default

How to install speckit.git.initialize

Manually: put the files in place

.claude/commands/speckit.git.initialize.md

Call it with /speckit.git.initialize. For all projects use ~/.claude/commands/

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

Similar slash commands

All slash commands for Git and GitHub →

From the same set83

The whole set →
specify The specify prompt turns a feature description and project context into a Markdown spec. Use it to define requirements before implementation. CX Codex GP ChatGPT ★ 110repo stars speckit.taskstoissues speckit.taskstoissues — a prompt that converts a task list into structured GitHub Issues with dependency ordering. Works with design artifacts and requires GitHub MCP server access. CX Codex GP ChatGPT ★ 110repo stars speckit.git.remote speckit.git.remote detects the Git remote origin URL, parses repository ownership, and validates github.com hosts for downstream workflows. CX Codex +1 ★ 110repo stars cleanup-reviewer cleanup-reviewer reviews a specified slice of a repository cleanup diff and reports findings only. Use it when the review should stay within named files. CX Codex ★ 110repo stars speckit-git-remote speckit-git-remote detects the Git remote URL and verifies GitHub connectivity for tasks like issue creation in spec-kit workflows. Designed for repositories structured with a .specify/ directory. CX Codex +1 ★ 110repo stars speckit-git-initialize speckit-git-initialize creates a Git repository in the current project and makes its first commit. It fits spec-kit projects that need Git initialized. CX Codex +1 ★ 110repo stars speckit.git.validate speckit.git.validate — a command that checks whether your current Git branch follows project naming conventions for feature branches. Install it if your team uses structured branch prefixes and wants to automate validation. CX Codex +1 ★ 110repo stars cleanup-implementer cleanup-implementer executes a single repository cleanup work packet. It edits assigned files, runs target checks, and never touches git write operations. CX Codex ★ 110repo stars

Project sponsors

Companies that keep this analytics open