Notre avis
Fournit des commandes Git optimisées pour les agents IA, utilisant des formats stables (porcelain) pour une sortie machine-readable.
Points forts
- Utilise des formats de sortie stables et fiables (porcelain v1/v2)
- Suites de commandes cohérentes pour les vérifications de statut, diff, log et branches
- Réduit la dépendance aux alias ou configurations utilisateur
Limites
- Nécessite une connaissance de base des commandes Git
- Ne couvre pas les workflows avancés comme le rebase interactif ou les submodules complexes
- La sortie porcelain peut être moins lisible pour les humains
Lorsque vous automatisez des opérations Git dans un script d'agent IA et que vous avez besoin de résultats prévisibles et facilement analysables.
Pour des tâches Git ponctuelles où une sortie humaine enrichie (couleurs, alias) est préférable.
Analyse de sécurité
SûrThe skill only uses standard git porcelain commands that do not involve external network requests, destructive operations beyond normal git, or exfiltration of sensitive data. All actions are within git's intended functionality and safe for AI agent usage.
Aucun point d'attention détecté
Exemples
Run git status --porcelain=v2 --branch to show current branch and all changes in a stable machine-readable format.Use git log --format='%H|%an|%s' -n 5 to display hash, author, and subject of the last 5 commits.Run git status --porcelain | wc -l to count the number of files with uncommitted changes.model: haiku name: git-cli-agentic description: Git commands optimized for AI agent workflows with porcelain output and deterministic execution patterns. user-invocable: false allowed-tools: Bash(git status *), Bash(git diff *), Bash(git log *), Bash(git branch *), Bash(git remote *), Bash(git add *), Bash(git commit *), Bash(git push *), Bash(git restore *), Read created: 2025-01-16 modified: 2026-01-31 reviewed: 2025-01-16
Git CLI Agentic Patterns
Optimized git commands for AI agent consumption using porcelain output and stable formats.
Core Principle
Use --porcelain for machine-readable output that remains stable across Git versions and user configurations.
Working Directory
Run git commands directly — your working directory is the repo:
git status
git log --oneline -5
git diff --stat
The -C flag is only needed when targeting a different repository from your current directory:
# Submodule: run command against parent repo
git -C "$(git rev-parse --show-toplevel)" remote get-url origin
# Script: iterate over multiple repos
for repo in repos/*; do
git -C "$repo" status --porcelain
done
Status Operations
Porcelain Status
# Version 2 porcelain with branch info (recommended)
git status --porcelain=v2 --branch
# Version 1 porcelain (simpler)
git status --porcelain
# Short format (human-readable but stable)
git status --short --branch
Porcelain v2 Format:
# branch.oid <commit>
# branch.head <branch>
# branch.upstream <upstream>
# branch.ab +<ahead> -<behind>
1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>
2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path><tab><origPath>
? <path>
! <path>
Status Codes:
| Code | Meaning | |------|---------| | M | Modified | | A | Added | | D | Deleted | | R | Renamed | | C | Copied | | ? | Untracked | | ! | Ignored |
Quick Checks
# Check if clean (empty output = clean)
git status --porcelain
# Count changed files
git status --porcelain | wc -l
# Check for uncommitted changes
git diff --quiet || echo "has changes"
Diff Operations
Stat Output
# File change summary
git diff --stat
# Numeric stats (machine-readable)
git diff --numstat
# Name and status only
git diff --name-status
# Names only
git diff --name-only
Numstat Format: <added>\t<deleted>\t<filename>
Staged vs Unstaged
# Unstaged changes
git diff --numstat
# Staged changes
git diff --cached --numstat
# Both (working tree vs HEAD)
git diff HEAD --numstat
Specific Comparisons
# Against specific commit
git diff $COMMIT --numstat
# Between branches
git diff main..feature --numstat
# Between commits
git diff $COMMIT1..$COMMIT2 --name-status
Log Operations
Custom Format
# Hash and subject only
git log --format='%H %s' -n 10
# Oneline (built-in)
git log --oneline -n 10
# With stats
git log --oneline --stat -n 5
# Machine-parseable with multiple fields
git log --format='%H|%an|%ae|%s' -n 10
Format Placeholders:
| Placeholder | Meaning |
|-------------|---------|
| %H | Full commit hash |
| %h | Short hash |
| %s | Subject |
| %b | Body |
| %an | Author name |
| %ae | Author email |
| %ad | Author date |
| %cn | Committer name |
Filtering
# By author
git log --author="name" --oneline -n 10
# By date range
git log --since="2025-01-01" --oneline
# By path
git log --oneline -n 10 -- path/to/file
# Merge commits only
git log --merges --oneline -n 5
Branch Operations
Branch Info
# List with tracking info
git branch -vv
# Formatted output
git branch --format='%(refname:short) %(upstream:short) %(upstream:track)'
# Current branch only
git branch --show-current
# Remote branches
git branch -r --format='%(refname:short)'
Tracking Status
# Ahead/behind count
git rev-list --left-right --count origin/main...HEAD
# Output: <behind>\t<ahead>
Remote Operations
# List remotes with URLs
git remote -v
# Get specific remote URL
git remote get-url origin
# Show remote details
git remote show origin
Staging Operations
# Stage specific files
git add path/to/file
# Stage all modified tracked files
git add -u
# Stage everything
git add -A
# Unstage file
git restore --staged path/to/file
# Discard changes
git restore path/to/file
Commit Operations
# Simple commit
git commit -m "message"
# With body (heredoc)
git commit -m "$(cat <<'EOF'
Subject line
Body paragraph.
Co-Authored-By: Name <email>
EOF
)"
# Amend last commit (use carefully)
git commit --amend -m "new message"
Push Operations
# Push current branch
git push origin HEAD
# Push to different remote branch (main-branch development)
git push origin main:feature-branch
# Push commit range
git push origin start^..end:feature-branch
# Set upstream
git push -u origin HEAD
Agentic Optimizations
| Context | Command |
|---------|---------|
| Quick status | git status --porcelain=v2 --branch |
| Changed files | git diff --name-status |
| Staged changes | git diff --cached --numstat |
| Recent commits | git log --format='%h %s' -n 5 |
| Branch tracking | git branch -vv --format='%(refname:short) %(upstream:track)' |
| Current branch | git branch --show-current |
Error Handling in Context
Use 2>/dev/null to suppress errors in context expressions (do NOT use || fallbacks - blocked by Claude Code 2.1.7+):
- Git status: !`git status --porcelain=v2 --branch`
- Current branch: !`git branch --show-current`
- Remote URL: !`git remote get-url origin`
Combining with GH CLI
For GitHub-specific operations, combine with gh commands:
# Get repo owner/name
gh repo view --json nameWithOwner --jq '.nameWithOwner'
# Then use in git operations
git push origin main:$(gh pr view --json headRefName --jq '.headRefName')
Best Practices
- Use porcelain v2 for status when parsing programmatically
- Use --numstat for diff when counting changes
- Use custom --format for log when extracting specific fields
- Always add 2>/dev/null fallback in context expressions
- Prefer git switch/restore over checkout for clarity
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.