Debugging et maintenancesource GitHub
Commit rapide (git)
/quick-commitCette commande automatise le processus de validation :
// contenu du skill
description: "Quick commit with automatic formatting, linting, and conventional commit message"
You are creating a quick commit. This command formats code, runs lints, generates a conventional commit message, and commits changes. If starting a new task, it creates a feature branch first.
Overview
This command automates the commit workflow:
- Check if new task → create feature branch
- Stage changes (or confirm staged changes)
- Format and lint code
- Run quick tests
- Generate conventional commit message
- Create commit
Step 0: Check for New Task / Feature Branch
bash
echo "🌿 Checking branch status..."
# Check if we're in a git repository
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ Not a git repository"
exit 1
fi
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
# Check if we're on main/master (starting a new task)
if [ "$CURRENT_BRANCH" = "main" ] || [ "$CURRENT_BRANCH" = "master" ]; then
echo ""
echo "📌 You're on $CURRENT_BRANCH. Starting a new task?"
echo ""
# Get today's date in DD-MM-YYYY format
TODAY=$(date +%d-%m-%Y)
# Analyze changes to determine branch type and name
analyze_for_branch() {
local diff_output=$(git diff --name-status)
local staged_output=$(git diff --cached --name-status)
local all_changes="$diff_output$staged_output"
# Determine type
if echo "$all_changes" | grep -q "test"; then
BRANCH_TYPE="test"
elif echo "$all_changes" | grep -q "\.md$"; then
BRANCH_TYPE="docs"
elif echo "$all_changes" | grep -qE "\.(ts|tsx|js|jsx)$" && echo "$all_changes" | grep -qv "^programs/"; then
BRANCH_TYPE="feat"
elif echo "$all_changes" | grep -q "^programs/\|\.rs$"; then
BRANCH_TYPE="feat"
else
BRANCH_TYPE="feat"
fi
# Get descriptive name from first significant file
local first_file=$(echo "$all_changes" | head -1 | awk '{print $2}')
local file_basename=$(basename "$first_file" 2>/dev/null | sed 's/\.[^.]*$//' | tr '_' '-' | tr '[:upper:]' '[:lower:]')
# Determine scope for name
if echo "$all_changes" | grep -q "^programs/"; then
BRANCH_SCOPE="program"
elif echo "$all_changes" | grep -qE "^(app|src|components)/"; then
BRANCH_SCOPE="frontend"
elif echo "$all_changes" | grep -q "^tests/"; then
BRANCH_SCOPE="tests"
else
BRANCH_SCOPE=""
fi
# Generate branch name
if [ -n "$BRANCH_SCOPE" ]; then
SUGGESTED_BRANCH="$BRANCH_TYPE/$BRANCH_SCOPE-$file_basename-$TODAY"
else
SUGGESTED_BRANCH="$BRANCH_TYPE/$file_basename-$TODAY"
fi
}
analyze_for_branch
echo "💡 Suggested branch: $SUGGESTED_BRANCH"
echo ""
echo "Options:"
echo " 1. Create branch: $SUGGESTED_BRANCH"
echo " 2. Enter custom branch name"
echo " 3. Stay on $CURRENT_BRANCH (not recommended)"
echo ""
# ASK USER which option they prefer
# Default: create the suggested branch
# Create branch
echo "Creating branch: $SUGGESTED_BRANCH"
git checkout -b "$SUGGESTED_BRANCH"
if [ $? -eq 0 ]; then
echo "✅ Created and switched to: $SUGGESTED_BRANCH"
CURRENT_BRANCH="$SUGGESTED_BRANCH"
else
echo "❌ Failed to create branch"
exit 1
fi
fi
echo ""Step 1: Check Working Directory Status
bash
echo "📊 Checking git status..."
# Check for changes
if git diff --quiet && git diff --cached --quiet; then
echo "ℹ️ No changes to commit"
exit 0
fi
# Show current status
git status --shortStep 2: Stage Changes
bash
echo ""
echo "📝 Staging changes..."
# Check if there are staged changes
if git diff --cached --quiet; then
# No staged changes, stage modified and new files
echo "No staged changes. Staging all modified and new files..."
# Get list of modified and new files
git add -A
echo "✅ Changes staged"
else
echo "✅ Using existing staged changes"
fi
# Show what will be committed
echo ""
echo "Files to be committed:"
git diff --cached --name-status
echo ""Step 3: Format Code
bash
echo "📝 Formatting code..."
# Format Rust files
if [ -f "Cargo.toml" ]; then
cargo fmt
echo " ✅ Rust files formatted"
fi
# Format TypeScript/JavaScript files
if find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" \) | head -1 | grep -q .; then
if command -v npx >/dev/null 2>&1; then
npx prettier --write "**/*.{ts,tsx,js,jsx,json}" 2>/dev/null || true
echo " ✅ TypeScript/JavaScript files formatted"
fi
fi
# Format Python files (if any)
if find . -type f -name "*.py" | head -1 | grep -q .; then
if command -v ruff >/dev/null 2>&1; then
// source originale publique
solanabr/solana-claude-config/.claude/commands/quick-commit.md
Licence : MIT License
Projet indépendant, non affilié à Anthropic. Ce skill reste la propriété de son auteur original.