Skip to content
Development
Command

/quick-commit

Quick commit with automatic formatting, linting, and conventional commit message

From plugin
solana-ai-kit
10130 skills15 agents30 commands7 MCP
Install
> /plugin marketplace add solanabr/solana-ai-kit
> /plugin install solana-ai-kit@stbr

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/quick-commit

Context preview

What this command does when you run it.

Quick commit with automatic formatting, linting, and conventional commit message

Command definition

quick-commit.md
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: 1. **Check if new task** → create feature branch 2. Stage changes (or confirm staged changes) 3. Format and lint code 4. Run quick tests 5. Generate conventional commit message 6. Create commit

Step 0: Check for New Task / Feature Branch

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

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 --short

Step 2: Stage Changes

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

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
        ruff format .
        echo "  ✅ Python files formatted"
    fi
fi

# Re-stage formatted files
git add -u

echo "✅ Formatting complete"

Step 4: Run Quick Lints

echo ""
echo "🔍 Running quick lints..."

LINT_FAILED=0

# Rust: clippy check
if [ -f "Cargo.toml" ]; then
    echo "  Running clippy..."
    if ! cargo clippy --all-targets -- -D warnings 2>/dev/null; then
        echo "  ⚠️  Clippy warnings found (non-blocking)"
        # Don't fail commit, just warn
    else
        echo "  ✅ Clippy passed"
    fi
fi

# TypeScript: eslint check (if configured)
if [ -f "package.json" ] && grep -q "eslint" package.json; then
    echo "  Running eslint..."
    if ! npm run lint --silent 2>/dev/null; then
        echo "  ⚠️  ESLint warnings found (non-blocking)"
    else
        echo "  ✅ ESLint passed"
    fi
fi

echo "✅ Linting complete"

Step 5: Run Quick Tests (Optional)

# Quick tests only for small changes
# Skip for large changes to keep commits fast

CHAN
Read more
Ships withsolana-ai-kit

Production-ready Claude Code configuration for full-stack Solana development. Combines best practices from multiple sources into an agent-optimized, token-efficient config you can install and adapt to your specific project.

Get the whole plugin

Other commands on solana-ai-kit.