Skip to content

feat: Git extension stage 1 — bundled extensions/git with hooks on all core commands#1941

Merged
mnriem merged 11 commits intomainfrom
copilot/extract-git-branching-operations
Apr 7, 2026
Merged

feat: Git extension stage 1 — bundled extensions/git with hooks on all core commands#1941
mnriem merged 11 commits intomainfrom
copilot/extract-git-branching-operations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 23, 2026

Stage 1: Git Extension (opt-in, bundled)

Extracts Git branching operations into a self-contained extensions/git/ extension. This is stage 1 — the extension is opt-in via specify extension add git (resolves locally from the bundled copy, no network required). Core git init and branching code remains unchanged.

Refs: #841, #1382, #1066, #1791, #1191


Extension structure (extensions/git/)

5 commands:

Command Description
speckit.git.initialize Initialize a Git repo with configurable commit message
speckit.git.feature Create feature branch (sequential/timestamp numbering)
speckit.git.validate Validate branch follows naming conventions
speckit.git.remote Detect Git remote URL for GitHub integration
speckit.git.commit Auto-commit changes (configurable per-command)

18 hooks across all 9 core commands:

Hook Command Purpose
before_constitution speckit.git.initialize Init git repo before constitution
before_specify speckit.git.feature Create feature branch before spec
before_clarify/plan/tasks/implement/checklist/analyze/taskstoissues speckit.git.commit Commit outstanding changes before command
after_constitution/specify/clarify/plan/tasks/implement/checklist/analyze/taskstoissues speckit.git.commit Auto-commit after command completes

Scripts (bash + powershell):

  • create-new-feature.{sh,ps1} — branch creation with sequential/timestamp numbering
  • initialize-repo.{sh,ps1} — git init with configurable commit message
  • auto-commit.{sh,ps1} — per-command auto-commit with config-driven enable/disable and custom messages
  • git-common.{sh,ps1} — extracted has_git() and check_feature_branch() helpers

All scripts capture git output and suppress it on success; full output is included in error messages on failure.

Configuration (git-config.yml):

  • branch_numbering: sequential or timestamp
  • init_commit_message: custom initial commit message
  • auto_commit: per-command enable/disable with custom commit messages (all disabled by default)

Hook system improvements

  • All 9 core commands now have hooks: Added before_*/after_* hook support to analyze, checklist, clarify, constitution, and taskstoissues (previously only specify, plan, tasks, implement had hooks)
  • Hooks-only extensions: Extensions can now provide only hooks (no commands required). The validation changed from "must provide at least one command" to "must provide at least one command or hook"
  • Removed before_commit/after_commit: These were documented as "planned" but never implemented and had no backing core command. Removed from API reference, user guide, and dev guide

Bundled extension install

  • pyproject.toml force-includes extensions/git into the wheel
  • _locate_bundled_extension() resolves bundled extensions from core_pack/ (wheel) or extensions/ (source checkout)
  • specify extension add git resolves locally before falling back to catalog — no network needed
  • Added git extension to catalog.json for discoverability via specify extension search

What stays in core (unchanged)

is_git_repo(), init_git_repo(), --branch-numbering flag, --no-git flag, get_current_branch(), SPECIFY_FEATURE env var, find_feature_dir_by_prefix(), specify.md template — all unchanged. The core {SCRIPT} flow continues to work as before.

Disable/re-enable

specify extension disable git   # stops all branch operations
specify extension enable git    # re-enables branching

Tests

37 new tests in tests/extensions/git/test_git_extension.py:

  • Manifest validation (commands, hooks, file existence)
  • Extension install via ExtensionManager
  • Bundled extension locator
  • initialize-repo.sh/.ps1 — init, skip-if-exists, custom commit message
  • create-new-feature.sh/.ps1 — sequential, timestamp, spec dir creation, increments, no-git degradation, dry-run
  • auto-commit.sh/.ps1 — disabled by default, per-command enable, custom messages, default fallback, no-changes skip, no-config skip, no-git skip
  • git-common.sh — has_git, check_feature_branch (sequential, timestamp, reject main, reject malformed)

Stage 2 (future)

  1. Auto-install during specify init (controlled by --no-git → don't install git extension)
  2. Remove core git init / is_git_repo / init_git_repobefore_constitution hook handles it
  3. Remove branch creation from specify.mdbefore_specify hook handles it via speckit.git.feature; change specify.md script ref from create-new-feature to check-prerequisites only
  4. Custom naming via presets (addresses [Feature request] Custom namespacing and branch naming conventions #1382 — override create-new-feature scripts)

Copilot AI changed the title [WIP] Extract Git/branching operations into extensions/git extension Extract Git/Branching operations into extensions/git extension (opt-out, auto-enabled) Mar 23, 2026
Copilot AI requested a review from mnriem March 23, 2026 21:34
@mnriem mnriem requested a review from Copilot March 23, 2026 21:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates git/branching workflow logic into a bundled extensions/git/ extension and wires it into specify init as an auto-enabled (opt-out) migration step, aiming to decouple branching behavior from core and reduce platform-specific breakages.

Changes:

  • Add a new extensions/git/ extension (manifest, commands, config template, and cross-platform scripts) for feature-branch creation/validation/remote detection.
  • Auto-install the bundled git extension during specify init and bundle it into the wheel via pyproject.toml force-include.
  • Update the /speckit.specify command template to consult extension enablement/config and prefer extension scripts with fallback behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
templates/commands/specify.md Updates specify command flow to check git extension enablement/config and prefer extension scripts.
src/specify_cli/init.py Adds bundled-extension discovery + auto-install during specify init.
pyproject.toml Bundles extensions/git into the wheel’s core_pack.
extensions/git/extension.yml New extension manifest defining commands, hooks, and defaults.
extensions/git/config-template.yml New user-facing config template for git extension settings.
extensions/git/README.md Documentation for git extension usage, config, and behavior.
extensions/git/commands/speckit.git.feature.md Command template for creating a feature branch via extension scripts.
extensions/git/commands/speckit.git.validate.md Command template for validating branch naming conventions.
extensions/git/commands/speckit.git.remote.md Command template for detecting git remote URL safely.
extensions/git/scripts/bash/create-new-feature.sh Bash feature-creation script adapted for extension install locations.
extensions/git/scripts/bash/git-common.sh Bash git-only helper functions extracted for reuse.
extensions/git/scripts/powershell/create-new-feature.ps1 PowerShell feature-creation script adapted for extension install locations.
extensions/git/scripts/powershell/git-common.ps1 PowerShell git-only helper functions extracted for reuse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

All 9 review comments addressed in 5e49ec6 and 17810c8:

  1. Bash common.sh sourcing — checks .specify/scripts/bash/scripts/bash/git-common.sh with hard error if none found
  2. PowerShell common.ps1 sourcing — uses $fallbackRoot for reliable resolution with same priority order and error
  3. Removed branch_template/auto_fetch from extension.yml defaults and config-template.yml (not implemented in scripts)
  4. Removed unused ExtensionError import
  5. Added 2 tests for auto-install path (init flow + already-installed no-op)
  6. Fixed double branch creation — step 2 now skips when before_specify hook already executed
  7. Added explicit FEATURE_DIR/SPEC_FILE creation in disabled-git path
  8. Added PowerShell path to script resolution in specify.md
  9. Removed undocumented SPECKIT_GIT_BRANCH_NUMBERING env var from README

All 818 tests pass, CodeQL clean.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/github/spec-kit/releases/latest
    • Triggering command: `/usr/bin/python3 python3 -c
      import tempfile, shutil
      from pathlib import Path
      from typer.testing import CliRunner
      from specify_cli import app

with tempfile.TemporaryDirectory() as tmpdir:
project = Path(tmpdir) / 'test-project'
REDACTED = CliRunner()
result = REDACTED.invok` (http block)

  • Triggering command: `/usr/bin/python3 python3 -c
    import tempfile
    from pathlib import Path
    from typer.testing import CliRunner
    from specify_cli import app

with tempfile.TemporaryDirectory() as tmpdir:
project = Path(tmpdir) / 'test-project'
REDACTED = CliRunner()
result = REDACTED.invoke(app, [` (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

All 7 review comments addressed in 4f1b63a and 363b7dc:

  1. Auto-install failure loggingexcept Exception now logs a [dim yellow]Warning: with details via console.print instead of silently returning False
  2. README install command — fixed --from extensions/git/extensions/git --dev
  3. README table syntax — already correct (single pipes), no change needed
  4. Bash fail-fast — added post-source check for resolve_template/json_escape; hard-fails with error listing actual tried paths
  5. PowerShell fail-fast — added post-source check for Resolve-Template; throws with paths tried
  6. PowerShell $env: prefix — fixed $env:FEATURE_DIR/$env:SPEC_FILE$FEATURE_DIR/$SPEC_FILE
  7. Docstring — updated to "Returns True if the extension was installed or already present"

All 818 tests pass, CodeQL clean.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot apply changes based on the comments in this thread

Both comments addressed in a5466f0:

  1. Quiet git checkoutgit checkout -q -b "$BRANCH_NAME" >/dev/null 2>&1 suppresses the "Switched to a new branch…" status line that was contaminating JSON output
  2. Registry check clarification — specify.md now explicitly states: only skip branching when extensions.git.enabled is present and explicitly false; proceed normally in all other cases (missing registry, missing entry, absent enabled field)

All 818 tests pass.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a bundled, opt-in extensions/git extension that encapsulates Spec Kit’s Git workflow (init/branch/validate/remote/auto-commit) and expands hook support so all core commands can participate in before/after extension hooks.

Changes:

  • Add bundled extensions/git/ (manifest, commands, config templates, bash + PowerShell scripts) plus comprehensive extension-level tests.
  • Update extension manifest validation to allow hooks-only extensions (must provide at least one command or hook).
  • Add hook-checking guidance to additional core command templates and enable local install of bundled extensions via specify extension add <id>.
Show a summary per file
File Description
tests/test_extensions.py Adds manifest validation tests for hooks-only and invalid hooks/commands types.
tests/extensions/git/test_git_extension.py New test suite covering git extension manifest + scripts + bundled locator.
tests/extensions/git/init.py Initializes git extension test package.
tests/extensions/init.py Initializes extensions test package.
templates/commands/taskstoissues.md Adds pre/post hook-check sections for tasks-to-issues command template.
templates/commands/constitution.md Adds pre/post hook-check sections for constitution command template.
templates/commands/clarify.md Adds pre/post hook-check sections for clarify command template.
templates/commands/checklist.md Adds pre/post hook-check sections for checklist command template.
templates/commands/analyze.md Adds hook-check guidance for analyze command template.
src/specify_cli/extensions.py Allows manifests with hooks-only; adds stricter type checks for commands/hooks.
src/specify_cli/init.py Adds _locate_bundled_extension() + installs bundled extensions before catalog fallback.
pyproject.toml Force-includes extensions/git into wheel core_pack.
extensions/git/scripts/powershell/initialize-repo.ps1 New PS repo init script for git extension.
extensions/git/scripts/powershell/git-common.ps1 New PS git helper functions (has git, feature-branch validation).
extensions/git/scripts/powershell/create-new-feature.ps1 New PS feature-branch creation script for git extension.
extensions/git/scripts/powershell/auto-commit.ps1 New PS auto-commit script for git extension.
extensions/git/scripts/bash/initialize-repo.sh New bash repo init script for git extension.
extensions/git/scripts/bash/git-common.sh New bash git helper functions (has git, feature-branch validation).
extensions/git/scripts/bash/create-new-feature.sh New bash feature-branch creation script for git extension.
extensions/git/scripts/bash/auto-commit.sh New bash auto-commit script for git extension.
extensions/git/README.md Documents git extension commands, hooks, config, and install/disable workflow.
extensions/git/git-config.yml Default git extension configuration (auto-commit disabled by default).
extensions/git/extension.yml Git extension manifest (commands + hooks + config template).
extensions/git/config-template.yml Config template copied into project on install.
extensions/git/commands/speckit.git.validate.md Command doc for branch validation behavior.
extensions/git/commands/speckit.git.remote.md Command doc for remote URL detection behavior.
extensions/git/commands/speckit.git.initialize.md Command doc for repo initialization behavior.
extensions/git/commands/speckit.git.feature.md Command doc for feature-branch creation behavior.
extensions/git/commands/speckit.git.commit.md Command doc for hook-driven auto-commit behavior.
extensions/EXTENSION-USER-GUIDE.md Updates documented list of hook events (removes before/after_commit).
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates extension authoring guidance for hooks-only + expanded hook events.
extensions/EXTENSION-API-REFERENCE.md Updates hook event reference list to include newly supported events.
extensions/catalog.json Adds git extension to catalog for discoverability and updates updated_at.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 3

Ensures git init succeeds even on empty repos where nothing has been
staged yet.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a bundled, opt-in git extension that encapsulates Spec Kit’s git init/branching/commit workflows as extension commands + hooks, while also extending hook support across additional core commands and relaxing manifest validation to allow hooks-only extensions.

Changes:

  • Introduces extensions/git/ (manifest, config template, command templates, and Bash/PowerShell scripts) plus comprehensive tests for install + script behaviors.
  • Updates extension manifest validation to allow “hooks-only” extensions and tightens type validation for provides.commands and hooks.
  • Adds pre/post hook discovery steps to additional core command templates and updates extension documentation/catalog metadata.
Show a summary per file
File Description
tests/test_extensions.py Updates/extends manifest validation tests for hooks-only support and type checks.
tests/extensions/git/test_git_extension.py New integration-style tests for bundled git extension install + scripts.
tests/extensions/git/init.py Adds test package marker for git extension tests.
tests/extensions/init.py Adds test package marker for extensions tests.
templates/commands/analyze.md Adds before/after hook discovery instructions to analyze command template.
templates/commands/checklist.md Adds before/after hook discovery instructions to checklist command template.
templates/commands/clarify.md Adds before/after hook discovery instructions to clarify command template.
templates/commands/constitution.md Adds before/after hook discovery instructions to constitution command template.
templates/commands/taskstoissues.md Adds before/after hook discovery instructions to taskstoissues command template.
src/specify_cli/extensions.py Allows hooks-only manifests; validates commands/hooks types; makes commands property resilient when absent.
src/specify_cli/init.py Adds bundled-extension locator and prefers installing bundled extensions before catalog download.
pyproject.toml Packages bundled extensions/git into the wheel under core_pack/extensions/git.
extensions/git/extension.yml Defines the git extension’s commands, hooks, config template, and metadata.
extensions/git/config-template.yml Adds template configuration file for git extension install.
extensions/git/git-config.yml Adds default user-facing git extension configuration (copied on install).
extensions/git/README.md Documents the git extension commands, hooks, and configuration.
extensions/git/commands/speckit.git.feature.md Adds extension command template for feature branch creation via scripts.
extensions/git/commands/speckit.git.validate.md Adds extension command template for validating feature branch naming.
extensions/git/commands/speckit.git.remote.md Adds extension command template for remote URL detection.
extensions/git/commands/speckit.git.initialize.md Adds extension command template for git repo initialization.
extensions/git/commands/speckit.git.commit.md Adds extension command template for config-driven auto-commit.
extensions/git/scripts/bash/create-new-feature.sh Adds Bash implementation for branch creation + spec dir creation.
extensions/git/scripts/bash/initialize-repo.sh Adds Bash implementation for git init + initial commit.
extensions/git/scripts/bash/auto-commit.sh Adds Bash implementation for config-driven auto-commit.
extensions/git/scripts/bash/git-common.sh Adds Bash helpers for git presence + branch validation.
extensions/git/scripts/powershell/create-new-feature.ps1 Adds PowerShell implementation for branch creation + spec dir creation.
extensions/git/scripts/powershell/initialize-repo.ps1 Adds PowerShell implementation for git init + initial commit.
extensions/git/scripts/powershell/auto-commit.ps1 Adds PowerShell implementation for config-driven auto-commit.
extensions/git/scripts/powershell/git-common.ps1 Adds PowerShell helpers for git presence + branch validation.
extensions/EXTENSION-USER-GUIDE.md Updates documented hook events list (removes planned commit hooks; adds new core hook events).
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates “provides” guidance and hook event documentation to match new behavior.
extensions/EXTENSION-API-REFERENCE.md Updates hook event reference list to include newly supported events.
extensions/catalog.json Adds bundled git extension entry and updates catalog timestamp.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 7

When 'specify extension add "Git Branching Workflow"' is used with a
display name instead of the ID, the catalog resolver now runs first to
map the name to an ID, then checks bundled extensions again with the
resolved ID before falling back to network download.

Also noted: EXECUTE_COMMAND_INVOCATION and condition handling match the
existing pattern in specify/plan/tasks/implement templates (pre-existing,
not introduced by this PR).
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces an opt-in, bundled git extension that moves Git initialization/branching/validation/remote-detection/auto-commit into extensions/git/, and expands hook support so all core commands can trigger before/after extension hooks via the .specify/extensions.yml configuration.

Changes:

  • Add bundled extensions/git/ extension (commands, scripts, default config) plus extensive test coverage for manifest/install and scripts.
  • Update extension manifest validation to allow hooks-only extensions (commands optional, but at least one command or hook required).
  • Add hook-check instructions to additional core command templates and update extension documentation/catalog for new hook events.
Show a summary per file
File Description
tests/test_extensions.py Updates/extends manifest validation tests for hooks-only extensions and stricter type checks.
tests/extensions/git/test_git_extension.py New end-to-end tests for the bundled git extension (install + bash/pwsh scripts).
tests/extensions/git/__init__.py Adds package marker for git extension tests.
tests/extensions/__init__.py Adds package marker for extensions tests.
templates/commands/taskstoissues.md Adds pre/post hook-check instructions for before_taskstoissues / after_taskstoissues.
templates/commands/constitution.md Adds pre/post hook-check instructions for constitution hooks.
templates/commands/clarify.md Adds pre/post hook-check instructions for clarify hooks.
templates/commands/checklist.md Adds pre/post hook-check instructions for checklist hooks.
templates/commands/analyze.md Adds hook-check instructions for analyze hooks.
src/specify_cli/extensions.py Allows hooks-only extensions and adds type validation for provides.commands and hooks.
src/specify_cli/__init__.py Adds bundled extension locator and installs bundled extensions locally before catalog download.
pyproject.toml Ensures extensions/git is packaged into the wheel under core_pack/extensions/git.
extensions/git/scripts/powershell/initialize-repo.ps1 New PowerShell repo-init script for the git extension.
extensions/git/scripts/powershell/git-common.ps1 New PowerShell shared git helpers (repo detection + branch validation).
extensions/git/scripts/powershell/create-new-feature.ps1 New PowerShell feature-branch creation script for the extension layout.
extensions/git/scripts/powershell/auto-commit.ps1 New PowerShell auto-commit script driven by git-config.yml.
extensions/git/scripts/bash/initialize-repo.sh New Bash repo-init script for the git extension.
extensions/git/scripts/bash/git-common.sh New Bash shared git helpers (repo detection + branch validation).
extensions/git/scripts/bash/create-new-feature.sh New Bash feature-branch creation script for the extension layout.
extensions/git/scripts/bash/auto-commit.sh New Bash auto-commit script driven by git-config.yml.
extensions/git/README.md Adds extension README describing commands, hooks, config, install/disable behavior.
extensions/git/git-config.yml Default extension configuration template shipped with the extension.
extensions/git/extension.yml New git extension manifest (commands, hooks, config metadata).
extensions/git/config-template.yml Config template file referenced by the manifest.
extensions/git/commands/speckit.git.validate.md New command template doc for branch validation command.
extensions/git/commands/speckit.git.remote.md New command template doc for remote detection command.
extensions/git/commands/speckit.git.initialize.md New command template doc for repo initialization command.
extensions/git/commands/speckit.git.feature.md New command template doc for feature-branch creation command.
extensions/git/commands/speckit.git.commit.md New command template doc for auto-commit hook command.
extensions/EXTENSION-USER-GUIDE.md Updates list of supported hook events to include all core commands.
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates manifest guidance (commands optional; hooks expanded; hooks can reference any command).
extensions/EXTENSION-API-REFERENCE.md Updates hook event reference (removes planned commit hooks; adds new standard events).
extensions/catalog.json Adds bundled git extension entry for discoverability and updates catalog timestamp.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 3

- Strip both before_ and after_ prefixes when deriving command name
  (fixes misleading 'Auto-commit after before_plan' messages)
- Include phase (before/after) in default commit messages
- Clarify README config example is an override, not default behavior
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a bundled, opt-in git extension that encapsulates Spec Kit’s Git branching/init/auto-commit behavior, expands hook support to all core commands, and adds local-first installation of bundled extensions (no network required).

Changes:

  • Added extensions/git/ (manifest, commands, config templates, bash + PowerShell scripts) plus a comprehensive test suite for the bundled extension.
  • Updated extension manifest validation to allow hooks-only extensions (must provide at least one command or hook).
  • Added hook support to remaining core command templates and added a bundled-extension install path (specify extension add git resolves locally first).
Show a summary per file
File Description
tests/test_extensions.py Updates manifest validation tests for hooks-only extensions and stronger type checks.
tests/extensions/git/test_git_extension.py Adds end-to-end tests for git extension install + scripts (bash + pwsh) + bundled locator.
tests/extensions/git/init.py Declares test package for git extension tests.
tests/extensions/init.py Declares test package for extension tests.
templates/commands/taskstoissues.md Adds before/after hook checks around tasks-to-issues conversion.
templates/commands/constitution.md Adds before/after hook checks around constitution command.
templates/commands/clarify.md Adds before/after hook checks around clarify command.
templates/commands/checklist.md Adds before/after hook checks around checklist command.
templates/commands/analyze.md Adds before hook checks and an after hook check step for analyze.
src/specify_cli/extensions.py Allows hooks-only manifests; validates provides.commands and hooks types; makes commands property resilient.
src/specify_cli/init.py Adds _locate_bundled_extension() and updates extension add to prefer bundled installs before catalog download.
pyproject.toml Force-includes extensions/git into the wheel under core_pack/.
extensions/git/scripts/powershell/initialize-repo.ps1 Adds PowerShell repo initialization script reading init_commit_message.
extensions/git/scripts/powershell/git-common.ps1 Adds PowerShell git helpers (repo detection + branch validation).
extensions/git/scripts/powershell/create-new-feature.ps1 Adds PowerShell feature-branch creation script with sequential/timestamp modes and graceful no-git behavior.
extensions/git/scripts/powershell/auto-commit.ps1 Adds PowerShell auto-commit hook script driven by auto_commit config.
extensions/git/scripts/bash/initialize-repo.sh Adds bash repo initialization script reading init_commit_message.
extensions/git/scripts/bash/git-common.sh Adds bash git helpers (repo detection + branch validation).
extensions/git/scripts/bash/create-new-feature.sh Adds bash feature-branch creation script with sequential/timestamp modes and graceful no-git behavior.
extensions/git/scripts/bash/auto-commit.sh Adds bash auto-commit hook script driven by auto_commit config.
extensions/git/README.md Documents git extension commands, hooks, configuration, and install/disable workflow.
extensions/git/git-config.yml Provides default git extension config (branch numbering + per-event auto-commit toggles/messages).
extensions/git/extension.yml Declares git extension manifest (commands, hooks, config defaults, metadata).
extensions/git/config-template.yml Template config file for install-time config provisioning.
extensions/git/commands/speckit.git.validate.md Adds validate command documentation/behavior contract.
extensions/git/commands/speckit.git.remote.md Adds remote-detection command documentation/behavior contract.
extensions/git/commands/speckit.git.initialize.md Adds initialize command documentation/behavior contract.
extensions/git/commands/speckit.git.feature.md Adds feature-branch command documentation/behavior contract.
extensions/git/commands/speckit.git.commit.md Adds commit hook command documentation/behavior contract.
extensions/EXTENSION-USER-GUIDE.md Updates documented hook event list to include newly supported core commands.
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates docs to reflect hooks-only extensions + expanded hook events.
extensions/EXTENSION-API-REFERENCE.md Updates hook event reference list (removes planned commit hooks; adds newly supported events).
extensions/catalog.json Adds the bundled git extension entry for discoverability via catalog search.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (5)

templates/commands/constitution.md:148

  • This post-hook section also hardcodes /{command} as the invocation. For skill-mode agents, the executable invocation can differ; the existing HookExecutor can render the correct invocation and includes EXECUTE_COMMAND_INVOCATION in its formatted output. Update this section to output/reference the rendered invocation instead of assuming slash commands.
    **Optional Hook**: {extension}
    Command: `/{command}`
    Description: {description}

    Prompt: {prompt}
    To execute: `/{command}`
    ```
  - **Mandatory hook** (`optional: false`):
    ```
    ## Extension Hooks

    **Automatic Hook**: {extension}
    Executing: `/{command}`
    EXECUTE_COMMAND: {command}

templates/commands/clarify.md:248

  • Post-execution hook output here assumes hooks are executed as /{command}. That won’t be correct for skill-mode agents; the codebase already supports agent-specific invocations via HookExecutor (EXECUTE_COMMAND_INVOCATION). Adjust this section to use the rendered invocation so hooks remain runnable across agents.
    **Optional Hook**: {extension}
    Command: `/{command}`
    Description: {description}

    Prompt: {prompt}
    To execute: `/{command}`
    ```
  - **Mandatory hook** (`optional: false`):
    ```
    ## Extension Hooks

    **Automatic Hook**: {extension}
    Executing: `/{command}`
    EXECUTE_COMMAND: {command}

templates/commands/checklist.md:362

  • This post-hook block hardcodes /{command} as the execution syntax. In skill-mode setups the correct invocation may not be a slash command; the repo already has HookExecutor logic that emits EXECUTE_COMMAND_INVOCATION. Update this block to output/reference the rendered invocation rather than assuming /{command}.
    **Optional Hook**: {extension}
    Command: `/{command}`
    Description: {description}

    Prompt: {prompt}
    To execute: `/{command}`
    ```
  - **Mandatory hook** (`optional: false`):
    ```
    ## Extension Hooks

    **Automatic Hook**: {extension}
    Executing: `/{command}`
    EXECUTE_COMMAND: {command}

templates/commands/taskstoissues.md:97

  • The post-execution hook instructions here assume /{command} is the correct invocation. For skill-mode agents this can be incorrect; HookExecutor already renders agent-specific invocations and provides EXECUTE_COMMAND_INVOCATION. Update this block to use the rendered invocation to keep hooks executable.
    **Optional Hook**: {extension}
    Command: `/{command}`
    Description: {description}

    Prompt: {prompt}
    To execute: `/{command}`
    ```
  - **Mandatory hook** (`optional: false`):
    ```
    ## Extension Hooks

    **Automatic Hook**: {extension}
    Executing: `/{command}`
    EXECUTE_COMMAND: {command}

templates/commands/analyze.md:229

  • This after-hook rendering block also hardcodes /{command}. Since HookExecutor supports agent-specific invocations (and emits EXECUTE_COMMAND_INVOCATION), this template should use that rendered invocation rather than assuming slash commands, otherwise hooks may be non-executable in skills mode.
    **Optional Hook**: {extension}
    Command: `/{command}`
    Description: {description}

    Prompt: {prompt}
    To execute: `/{command}`
    ```
  - **Mandatory hook** (`optional: false`):
    ```
    ## Extension Hooks

    **Automatic Hook**: {extension}
    Executing: `/{command}`
    EXECUTE_COMMAND: {command}
  • Files reviewed: 33/33 changed files
  • Comments generated: 0 new

@mnriem mnriem marked this pull request as ready for review April 7, 2026 12:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a bundled, opt-in extensions/git/ Git workflow extension and expands the core command templates/docs to support before/after extension hooks across all core commands, including new hook points for analyze, checklist, clarify, constitution, and taskstoissues.

Changes:

  • Add bundled git extension (manifest, scripts, config templates, command prompts) plus comprehensive tests.
  • Allow hooks-only extensions by updating ExtensionManifest validation and adding regression tests.
  • Add bundled-extension resolution to specify extension add and expand hook-check sections across additional core command templates and docs.
Show a summary per file
File Description
tests/test_extensions.py Updates manifest validation tests for hooks-only extensions and type checks.
tests/extensions/init.py Marks extensions tests as a package.
tests/extensions/git/init.py Marks git extension tests as a package.
tests/extensions/git/test_git_extension.py Adds end-to-end tests for bundled git extension, install flow, and scripts (bash/pwsh).
templates/commands/analyze.md Adds pre/post hook checks for before_analyze / after_analyze.
templates/commands/checklist.md Adds pre/post hook checks for before_checklist / after_checklist.
templates/commands/clarify.md Adds pre/post hook checks for before_clarify / after_clarify.
templates/commands/constitution.md Adds pre/post hook checks for before_constitution / after_constitution.
templates/commands/taskstoissues.md Adds pre/post hook checks for before_taskstoissues / after_taskstoissues.
src/specify_cli/extensions.py Relaxes manifest validation to permit hooks-only extensions; adds type validation for commands/hooks.
src/specify_cli/init.py Adds _locate_bundled_extension() and updates extension add to prefer local bundled extensions before catalog download.
pyproject.toml Force-includes extensions/git into the wheel’s core_pack bundle.
extensions/catalog.json Adds the bundled git extension to the catalog for discoverability.
extensions/EXTENSION-API-REFERENCE.md Updates documented hook events and removes unimplemented planned commit hooks.
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates guidance to allow hooks-only extensions and expands hook points.
extensions/EXTENSION-USER-GUIDE.md Updates list of available hook events.
extensions/git/README.md Documents git extension commands, hooks, configuration, and behavior.
extensions/git/extension.yml Defines the git extension manifest, commands, and hook registrations across core events.
extensions/git/config-template.yml Provides install-time template for git-config.yml.
extensions/git/git-config.yml Provides a default example configuration (disabled auto-commit by default).
extensions/git/commands/speckit.git.feature.md Adds the extension command prompt for feature branch creation.
extensions/git/commands/speckit.git.validate.md Adds the extension command prompt for branch validation.
extensions/git/commands/speckit.git.remote.md Adds the extension command prompt for remote detection.
extensions/git/commands/speckit.git.initialize.md Adds the extension command prompt for repo initialization.
extensions/git/commands/speckit.git.commit.md Adds the extension command prompt for auto-commit behavior.
extensions/git/scripts/bash/create-new-feature.sh Adds bash script for feature branch + specs dir creation.
extensions/git/scripts/bash/initialize-repo.sh Adds bash script for git init + initial commit.
extensions/git/scripts/bash/auto-commit.sh Adds bash script for config-driven auto-commit.
extensions/git/scripts/bash/git-common.sh Adds bash git helper functions (repo detection + branch validation).
extensions/git/scripts/powershell/create-new-feature.ps1 Adds PowerShell script for feature branch + specs dir creation.
extensions/git/scripts/powershell/initialize-repo.ps1 Adds PowerShell script for git init + initial commit.
extensions/git/scripts/powershell/auto-commit.ps1 Adds PowerShell script for config-driven auto-commit.
extensions/git/scripts/powershell/git-common.ps1 Adds PowerShell git helper functions (repo detection + branch validation).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 1

BSD grep (macOS) doesn't support \b as a word boundary. Replace with
grep -qw which is POSIX-portable.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in, bundled extensions/git extension that encapsulates Spec Kit’s Git branching/initialization/auto-commit behaviors and wires extension hook checks into the remaining core command templates, while updating validation/docs/tests to support hooks-only extensions.

Changes:

  • Introduces bundled extensions/git/ with commands, hooks, config template, and cross-platform scripts (+ extensive tests).
  • Expands core command templates (analyze, checklist, clarify, constitution, taskstoissues) to include before/after hook-check instructions.
  • Updates extension manifest validation to allow hooks-only extensions and adds bundled-extension resolution during specify extension add.
Show a summary per file
File Description
tests/test_extensions.py Updates/extends manifest validation tests (hooks-only + type checks).
tests/extensions/git/test_git_extension.py Adds integration-style tests for bundled git extension manifest, install, and scripts.
tests/extensions/git/init.py Declares git extension tests package.
tests/extensions/init.py Declares extensions tests package.
templates/commands/taskstoissues.md Adds pre/post hook-check instructions for tasks→issues command.
templates/commands/constitution.md Adds pre/post hook-check instructions for constitution command.
templates/commands/clarify.md Adds pre/post hook-check instructions for clarify command.
templates/commands/checklist.md Adds pre/post hook-check instructions for checklist command.
templates/commands/analyze.md Adds pre/post hook-check instructions for analyze command.
src/specify_cli/extensions.py Allows hooks-only manifests; adds type validation for commands/hooks containers.
src/specify_cli/init.py Adds _locate_bundled_extension() and prefers bundled install in extension add.
pyproject.toml Force-includes extensions/git into the wheel under core_pack/.
extensions/git/scripts/powershell/initialize-repo.ps1 Implements repo init + initial commit (PS).
extensions/git/scripts/powershell/git-common.ps1 Adds PS git helpers for repo/branch validation.
extensions/git/scripts/powershell/create-new-feature.ps1 Implements PS feature branch + spec dir creation.
extensions/git/scripts/powershell/auto-commit.ps1 Implements PS auto-commit driven by config + event name.
extensions/git/scripts/bash/initialize-repo.sh Implements repo init + initial commit (bash).
extensions/git/scripts/bash/git-common.sh Adds bash git helpers for repo/branch validation.
extensions/git/scripts/bash/create-new-feature.sh Implements bash feature branch + spec dir creation.
extensions/git/scripts/bash/auto-commit.sh Implements bash auto-commit driven by config + event name.
extensions/git/README.md Documents git extension commands, hooks, config, and usage.
extensions/git/git-config.yml Provides default config (copied on install).
extensions/git/extension.yml Declares git extension commands, hooks, and config template.
extensions/git/config-template.yml Template for git-config.yml on install.
extensions/git/commands/speckit.git.validate.md Command template: validate feature branch naming.
extensions/git/commands/speckit.git.remote.md Command template: detect git remote URL.
extensions/git/commands/speckit.git.initialize.md Command template: initialize repository.
extensions/git/commands/speckit.git.feature.md Command template: create feature branch + spec dir.
extensions/git/commands/speckit.git.commit.md Command template: auto-commit hook behavior.
extensions/EXTENSION-USER-GUIDE.md Updates documented hook events list (removes planned commit hooks).
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Documents commands as optional; expands hook points and clarifies hook commands.
extensions/EXTENSION-API-REFERENCE.md Updates hook event examples/list to include newly supported events.
extensions/catalog.json Adds bundled git extension entry and updates catalog timestamp.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 3

- Validate each hook value is a dict with a 'command' field during
  manifest _validate() (prevents crash at install time)
- Validate --number is a non-negative integer in bash create-new-feature
  (clear error instead of cryptic shell arithmetic failure)
- Route PowerShell no-git warning to stderr in JSON mode so stdout
  stays valid JSON
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an opt-in, bundled git extension (extensions/git/) that encapsulates Spec Kit’s git initialization, feature branch creation, branch validation, remote detection, and auto-commit behavior, and wires hook support into additional core command templates so extensions can run before/after all core workflows.

Changes:

  • Add a bundled git extension (manifest, commands, scripts, default config, docs) plus comprehensive cross-platform tests.
  • Extend manifest validation to allow hooks-only extensions, and add bundled-extension discovery/installation via specify extension add.
  • Update additional core command templates (constitution, clarify, checklist, analyze, taskstoissues) to include pre/post hook handling instructions; refresh extension docs and catalog.
Show a summary per file
File Description
src/specify_cli/extensions.py Allows hooks-only extension manifests; adds hook validation and makes commands property resilient to missing commands.
src/specify_cli/__init__.py Adds _locate_bundled_extension() and updates extension add flow to prefer bundled extensions before catalog downloads.
pyproject.toml Force-includes extensions/git into the wheel under core_pack/extensions/.
extensions/git/extension.yml Declares the git extension’s commands, hooks, tools, and defaults.
extensions/git/README.md Documents extension behavior, hooks, config, and installation/disable flow.
extensions/git/config-template.yml / extensions/git/git-config.yml Provides default configuration for numbering/init commit message/auto-commit toggles.
extensions/git/commands/*.md Adds the five git extension command definitions.
extensions/git/scripts/bash/*.sh Adds bash implementations for init/branching/auto-commit/git helpers.
extensions/git/scripts/powershell/*.ps1 Adds PowerShell implementations for init/branching/auto-commit/git helpers.
templates/commands/analyze.md Adds pre-execution hook instructions and post-execution hook check section for analyze.
templates/commands/checklist.md Adds pre/post hook instructions for checklist.
templates/commands/clarify.md Adds pre/post hook instructions for clarify.
templates/commands/constitution.md Adds pre/post hook instructions for constitution.
templates/commands/taskstoissues.md Adds pre/post hook instructions for taskstoissues.
extensions/EXTENSION-USER-GUIDE.md Updates documented hook events list to include all newly supported core commands.
extensions/EXTENSION-DEVELOPMENT-GUIDE.md Updates guidance: commands are optional as long as hooks exist; documents additional hook points.
extensions/EXTENSION-API-REFERENCE.md Updates hook event reference list to remove planned commit hooks and add new core events.
extensions/catalog.json Adds bundled git extension entry for discovery and updates catalog timestamp.
tests/test_extensions.py Updates/extends manifest validation tests for hooks-only extensions and type checks.
tests/extensions/git/test_git_extension.py Adds end-to-end tests for manifest, install, bundled locator, and scripts (bash + pwsh where available).
tests/extensions/__init__.py / tests/extensions/git/__init__.py Initializes test packages for git extension tests.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 33/33 changed files
  • Comments generated: 0 new

@mnriem mnriem merged commit 1a9e4d1 into main Apr 7, 2026
13 checks passed
@mnriem mnriem deleted the copilot/extract-git-branching-operations branch April 7, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract Git/Branching Operations into extensions/git Extension (Opt-Out, Auto-Enabled)

3 participants