Validation de commits Git conformes

VérifiéSûr

Crée des commits locaux avec des messages conventionnels et des références automatiques aux issues. Utilise les hooks pre-commit et détecte les issues GitHub.

Spar Skills Guide Bot
DeveloppementIntermédiaire
26/07/2026
Claude Code
#git#commit-messages#conventional-commits#version-control#issue-tracking

Recommandé pour

Synthèse automatique

Crée des commits locaux en respectant les Conventional Commits, en lançant les hooks pre-commit et en ajoutant les références aux tickets GitHub détectés.

Points forts

  • Décrit un flux complet : inspection de l'état Git, staging explicite, exécution des hooks puis création du commit.
  • Fournit un tableau des types de commits conventionnels et de leur impact sur les versions.
  • Détecte les tickets GitHub liés à partir des chemins, messages d'erreur ou noms de fonctions.
  • Rappelle les pièges d'échappement des heredocs dans les messages de commit.

Limites

  • Ne pousse pas les commits ni ne crée de pull request ; il faut utiliser git-push ou un skill chaîné.
  • La détection des tickets dépend de gh CLI et d'une liste limitée d'issues ouvertes.
  • Suppose que l'utilisateur ou l'agent choisit correctement les fichiers à indexer ; aucun garde-fou métier n'est décrit.
Quand l'utiliser

À utiliser lorsqu'il faut enregistrer des modifications dans un commit local propre, avec message conventionnel et références de tickets.

Quand l'éviter

À éviter si l'objectif est de pousser vers le dépôt distant, d'ouvrir une PR ou de gérer un historique complexe multi-commits.

Analyse de sécurité

Sûr
Score qualité88/100

The skill is a narrowly scoped local git workflow. Every bash invocation is an explicit, non-destructive git/gh read or commit command; there is no piping to shell, no deletion, no credential or token handling, and no attempt to disable safety or hide intent. The heredoc guidance is correct and even warns against accidental escaping. The only residual risks are inherent to running repo-defined pre-commit hooks and a read-only GitHub API call, both legitimate for the stated purpose.

Points d'attention
  • •`git restore` and `gh issue` are in allowed-tools but `git restore` is never described or scoped in the workflow
  • •`pre-commit run --all-files` executes repo-local hook scripts, which is a supply-chain surface if the user commits into an untrusted repository
  • •`gh issue list` performs a read-only network call to GitHub
Comment cette analyse est faite

Exemples

Local commit with issue link
Commit these changes locally using a conventional message and add Fixes #123 if it matches the staged files.
Stage and save work
Stage src/auth.ts and tests/auth.test.ts, run pre-commit, and save my work as a fix commit.
Conventional commit only
Create a commit for the current changes with an appropriate conventional type and scope, but don't push.

created: 2026-01-21 modified: 2026-05-30 reviewed: 2026-04-25 name: git-commit description: Create commits with conventional messages and issue references. Use when user says "commit", "save changes", or "stage and commit". Local commits only — see git-push for remote. user-invocable: false allowed-tools: Bash(git status *), Bash(git diff *), Bash(git log *), Bash(git add *), Bash(git commit *), Bash(git restore *), Bash(pre-commit *), Bash(gh issue *), Read, Grep, Glob, TodoWrite

Git Commit

When to Use This Skill

| Use this skill when... | Use the alternative when... | |---|---| | Creating a local commit with conventional message and pre-commit hooks | Use git-push afterwards to send the commit to remote | | Auto-detecting related GitHub issues and inserting Fixes #N references | Use github-issue-autodetect to study the detection patterns themselves | | Staging and committing without pushing or opening a PR | Use git-commit-push-pr to chain commit + push + PR creation in one step | | Applying repo conventions (humble tone, logical grouping) to a single commit | Use git-commit-workflow for the broader staging + message convention guidance |

Create local commits with proper conventional messages and issue references.

When to Use

Trigger phrases:

  • "commit" / "commit locally" / "commit these changes"
  • "save changes" / "save my work"
  • "stage and commit"
  • "create a commit"

Context signals:

  • User has made code changes
  • git status shows modified/untracked files
  • No mention of "push", "remote", or "PR"

Workflow

1. Assess State

# Check branch and status
git branch --show-current
git status --porcelain=v2 --branch

# View changes
git diff --stat                    # Unstaged
git diff --cached --stat           # Already staged

2. Stage Changes

Explicit staging (preferred):

git add src/feature.ts
git add tests/feature.test.ts
git status --porcelain              # Verify

Modified tracked files:

git add -u                          # Stage all modified tracked files

3. Run Pre-commit Hooks

If .pre-commit-config.yaml exists:

pre-commit run --all-files

# If hooks modify files (formatters), re-stage:
git add -u
pre-commit run --all-files          # Should pass now

4. Detect Related Issues

Scan open issues for matches (see github-issue-autodetect skill):

gh issue list --state open --json number,title,labels --limit 30

Match staged changes to issues by:

  • File paths mentioned in issue body (high confidence)
  • Error messages or function names (high confidence)
  • Directory/component matches (medium confidence)

5. Create Commit

IMPORTANT: Use HEREDOC directly in the git commit command.

git commit -m "$(cat <<'EOF'
type(scope): concise description

Optional body explaining the change.

Fixes #123
Refs #456

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
EOF
)"

Inside a quoted heredoc (<<'EOF'), backticks, $, and \ are already literal — never backslash-escape them. A reflexive \`` produces a literal backslash in the commit message that survives into git logand needs an--amend` to clean up.

For trailer conventions (Co-authored-by, Signed-off-by, BREAKING CHANGE, Release-As), see git-commit-trailers skill.

Conventional Commit Types

| Type | Use Case | Version Bump | |------|----------|--------------| | feat | New feature | Minor | | fix | Bug fix | Patch | | perf | Performance improvement | Patch | | refactor | Code restructuring | None | | docs | Documentation | None | | test | Adding tests | None | | chore | Maintenance, deps | None | | ci | CI/CD config | None | | build | Build system, deps | None |

See Conventional Commits Standards for complete reference.

Issue References

| Keyword | Effect | |---------|--------| | Fixes #N | Closes issue on merge (bug fixes) | | Closes #N | Closes issue on merge (features) | | Refs #N | Links without closing (partial work) |

Output

On success, report:

Created commit: abc1234
Message: feat(auth): add OAuth2 support

Fixes #123
Refs #456

Ready for: push to remote, create PR, or continue working

Composability

This skill creates local commits only. For remote operations:

  • git-push skill: Push commits to remote
  • git-pr skill: Create pull request

Common compositions:

  • "commit" → git-commit only
  • "commit and push" → git-commit → git-push
  • "commit and create PR" → git-commit → git-push → git-pr

Before building further on an existing PR branch (an additional in-session request continuing earlier work), invoke /git:pr-sync-check first. If the verdict is anything other than in_sync / no_pr / no_remote — e.g. pr_merged or behind — stop and reconcile (branch off the updated default, or git pull --rebase) before committing. See .claude/rules/pr-branch-sync.md.

Error Handling

No changes to commit:

Nothing to commit. Working tree clean.

Pre-commit hook fails:

# Fix the issue, then:
git add -u
pre-commit run --all-files
# Then commit

Merge conflict markers:

Cannot commit: unresolved merge conflicts in <file>

Best Practices

  1. One logical change per commit - Easier to review and revert
  2. Always reference issues - Maintains traceability
  3. Run pre-commit before staging - Avoids re-staging formatter changes
  4. Keep subject under 72 chars - Better display in git log
  5. Use imperative mood - "Add feature" not "Added feature"
  6. Add appropriate trailers - Co-authored-by for pair/AI work, Signed-off-by for DCO projects, BREAKING CHANGE for major versions (see git-commit-trailers)

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/local-git-commit-ms1aw47q/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/local-git-commit-ms1aw47q' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/local-git-commit-ms1aw47q/download' --output '.skill-downloads/local-git-commit-ms1aw47q/SKILL.md.part' && mv '.skill-downloads/local-git-commit-ms1aw47q/SKILL.md.part' '.skill-downloads/local-git-commit-ms1aw47q/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Outils déclarés par l’auteur (à vérifier dans votre agent) : Bash(git status *), Bash(git diff *), Bash(git log *), Bash(git add *), Bash(git commit *), Bash(git restore *), Bash(pre-commit *), Bash(gh issue *), Read, Grep, Glob, TodoWrite

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/local-git-commit-ms1aw47q/SKILL.md' && test -s '.skill-downloads/local-git-commit-ms1aw47q/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/git-commit' && cp -R '.skill-downloads/local-git-commit-ms1aw47q' '.claude/skills/git-commit'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/local-git-commit-ms1aw47q'

openskills read 'local-git-commit-ms1aw47q'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/local-git-commit-ms1aw47q/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires