Créer un commit signé

VérifiéSûr

Crée un commit signé dans un dépôt Git local, en créant automatiquement une nouvelle branche si la branche courante est main ou master. Ajoute automatiquement toutes les modifications et génère un message de commit descriptif basé sur les types de fichiers modifiés (ex. compétences, documentation, workflows). Nécessite une configuration de signature GPG, et échoue si celle-ci n'est pas configurée.

Spar Skills Guide Bot
DeveloppementIntermédiaire
6002/06/2026
Claude CodeCursorWindsurfCopilotCodex
#commit#git#gpg#version-control#signing

Recommandé pour

Notre avis

Crée un commit signé dans le dépôt Git local, en créant automatiquement une nouvelle branche si nécessaire sur main/master et en générant un message de commit descriptif basé sur les modifications.

Points forts

  • Automatise la création de commits signés avec GPG
  • Gère la protection des branches en créant des branches sémantiques
  • Génère des messages de commit contextuels selon les fichiers modifiés
  • Vérifie les prérequis (GPG configuré) avant de commiter

Limites

  • Nécessite que GPG soit configuré (gpg.key et user.email)
  • Les messages de commit sont générés par des heuristiques simples, pas toujours adaptés
  • Échoue si aucun changement n'est détecté
Quand l'utiliser

Utilisez cette compétence lorsque vous souhaitez effectuer un commit rapide et signé sans avoir à rédiger manuellement le message.

Quand l'éviter

Ne l'utilisez pas si vous préférez rédiger votre propre message de commit ou si GPG n'est pas configuré.

Analyse de sécurité

Sûr
Score qualité75/100

The skill runs trusted local Python scripts and git commands; it does not download external content, exfiltrate data, or disable security features. GPG signing is enforced, and no destructive actions are instructed. The use of bash and git is for standard version control operations.

Aucun point d'attention détecté

Exemples

Commit all changes
Commit my changes with a signed commit.
Commit after changes
Create a signed commit for the current changes.
Save and commit work
Save my work and create a commit with a descriptive message.

name: commit description: Creates a signed commit in the local repository. If on main or master branch, creates a new branch first. Fails if GPG signing is not configured.

Commit Skill

This skill creates a signed commit with the current changes in the repository.

When to Use

  • User asks to commit changes
  • User asks to create a commit
  • User wants to save changes with a commit

Prerequisites

  • Git must be installed
  • GPG signing must be configured (user.email must be set and gpg.key configured)
  • There must be changes to commit (unstaged or staged)

Instructions

Step 1: Run Pre-Commit Script

Run the pre-commit script to verify GPG signing and handle branch creation:

python3 ./scripts/pre-commit.py [optional_branch_prefix]

This script will:

  1. Verify GPG signing is configured
  2. Check current branch
  3. Create semantic branch if on main/master
  4. Check for changes to commit

If the script exits with an error, fail with the error message.

Step 2: Stage All Changes

Stage all changes:

git add -A

Step 3: Analyze Changes

First, run the uncommitted changes script to see what has been modified:

python3 ./scripts/uncommitted-changes.py

This script displays all local changes including staged files, unstaged modifications, and untracked files.

Step 4: Create Signed Commit

Create a commit with a message based on the changes being made. Analyze the staged files to generate an appropriate commit message:

# Analyze what changed and create appropriate message
CHANGED_FILES=$(git diff --cached --name-only)
ADDED_FILES=$(git diff --cached --name-only --diff-filter=A)
MODIFIED_FILES=$(git diff --cached --name-only --diff-filter=M)
DELETED_FILES=$(git diff --cached --name-only --diff-filter=D)

# Create commit message based on changes
if [ -n "$ADDED_FILES" ] && [ -z "$MODIFIED_FILES" ] && [ -z "$DELETED_FILES" ]; then
    # Only additions
    if echo "$ADDED_FILES" | grep -q "^skills/"; then
        COMMIT_MSG="Add $(echo "$ADDED_FILES" | head -1 | xargs basename)"
    elif echo "$ADDED_FILES" | grep -q "^\.github/workflows/"; then
        COMMIT_MSG="Add GitHub Actions workflow"
    elif echo "$ADDED_FILES" | grep -q "^docs/\|README\|DEVELOP\|HISTORY"; then
        COMMIT_MSG="Add documentation: $(echo "$ADDED_FILES" | head -1 | xargs basename)"
    else
        COMMIT_MSG="Add $(echo "$ADDED_FILES" | head -1 | xargs basename)"
    fi
elif [ -n "$MODIFIED_FILES" ] && [ -z "$ADDED_FILES" ] && [ -z "$DELETED_FILES" ]; then
    # Only modifications
    if echo "$MODIFIED_FILES" | grep -q "^skills/"; then
        SKILL_NAME=$(echo "$MODIFIED_FILES" | grep "^skills/" | head -1 | cut -d'/' -f2)
        COMMIT_MSG="Update $SKILL_NAME skill"
    elif echo "$MODIFIED_FILES" | grep -q "\.md$"; then
        COMMIT_MSG="Update documentation"
    elif echo "$MODIFIED_FILES" | grep -q "^\.github/"; then
        COMMIT_MSG="Update GitHub Actions configuration"
    else
        COMMIT_MSG="Update $(echo "$MODIFIED_FILES" | head -1 | xargs basename)"
    fi
elif [ -n "$DELETED_FILES" ] && [ -z "$ADDED_FILES" ] && [ -z "$MODIFIED_FILES" ]; then
    # Only deletions
    COMMIT_MSG="Remove $(echo "$DELETED_FILES" | head -1 | xargs basename)"
else
    # Mixed changes
    if echo "$CHANGED_FILES" | grep -q "^skills/"; then
        COMMIT_MSG="Update skills configuration and implementation"
    elif echo "$CHANGED_FILES" | grep -q "^\.github/"; then
        COMMIT_MSG="Update CI/CD and repository configuration"
    elif echo "$CHANGED_FILES" | grep -q "\.md$"; then
        COMMIT_MSG="Update documentation"
    else
        COMMIT_MSG="Update repository files"
    fi
fi

# Get the AI model being used (from environment or default)
AI_MODEL="${OPENCODE_MODEL:-Kimi K2.5}"

# Create the signed commit with the generated message and model info
git commit -S -m "$COMMIT_MSG" -m "Generated by: $AI_MODEL"

The commit message should be concise but descriptive, based on what files were changed and the nature of the changes.

Step 4: Verify Commit is Signed

Verify the commit was created and is signed:

git log -1 --show-signature

If the commit is not signed, fail with error: "Commit was not signed properly"

Error Handling

  • If GPG signing fails, fail with error: "GPG signing failed. Check your GPG configuration."
  • If there are no changes to commit, inform the user and ask what changes they want to commit
  • If git command fails, display the error message and fail

Important Notes

  • Always use -S flag with git commit to enable GPG signing
  • The commit MUST be signed - do not proceed if signing fails
  • This skill works with local repositories only
  • See scripts/pre-commit.py for the deterministic pre-commit logic
  • See scripts/uncommitted-changes.py to view all uncommitted changes (works in any repository)
Skills similaires