Skip to main content
ClaudeWave
Slash Command97 repo starsupdated 1mo ago

quick-commit

The quick-commit command automates Solana development workflows by creating feature branches when starting new tasks, then staging changes, formatting and linting code, running tests, and generating conventional commit messages before committing. Use this command to maintain consistent code quality and commit conventions while reducing manual formatting and branching overhead.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/solanabr/solana-ai-kit/HEAD/.claude/commands/quick-commit.md -o ~/.claude/commands/quick-commit.md
Then start a new Claude Code session; the slash command loads automatically.

quick-commit.md

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

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

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

# Re-stage formatted files
git add -u

echo "✅ Formatting complete"
```

## Step 4: Run Quick Lints

```bash
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)

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

CHANGED_FILES=$(git diff --cached --name-only | wc -l)

if [ "$CHANGED_FILES" -lt 5 ]; then
    echo ""
anchor-engineerSubagent

Anchor framework specialist for rapid Solana program development. Use for building programs with Anchor macros, IDL generation, account validation, and standardized patterns. Prioritizes developer experience while maintaining security.\\n\\nUse when: Building new programs quickly, team projects needing standardization, projects requiring IDL for client generation, or when developer experience is prioritized over maximum CU optimization.

defi-engineerSubagent

DeFi integration specialist for composing with Solana protocols including Jupiter, Drift, Kamino, Raydium, Orca, Meteora, Marginfi, and Sanctum. Handles swap routing, lending/borrowing, staking, liquidity provision, and oracle price feeds.\n\nUse when: Integrating DeFi protocols, building swap interfaces, implementing lending/borrowing, setting up yield strategies, working with Pyth/Switchboard oracles, or composing multi-protocol transactions.

devops-engineerSubagent

CI/CD, infrastructure, and deployment specialist for Solana projects. Handles GitHub Actions, Docker, monitoring, RPC management, and Cloudflare Workers edge deployment.\n\nUse when: Setting up CI/CD pipelines, containerizing Solana validators or programs, configuring monitoring and alerting, managing RPC infrastructure, deploying edge workers, or automating build and deploy workflows.

game-architectSubagent

Senior Solana game architect for game system design, Unity/C# architecture, on-chain game state, player progression, NFT integration, and PlaySolana ecosystem. Use for high-level game design decisions, architecture reviews, and planning complex game systems.\n\nUse when: Designing new Solana games from scratch, planning game state on-chain, Unity project architecture, integrating with PlaySolana/PSG1, or deciding between implementation approaches.

mobile-engineerSubagent

React Native and Expo specialist for building Solana mobile dApps. Handles mobile wallet adapter integration, transaction signing UX, deep linking, and mobile-specific performance optimization.\n\nUse when: Building React Native or Expo mobile apps with Solana integration, implementing mobile wallet adapter flows, setting up deep links for transaction signing, or optimizing mobile dApp performance.

pinocchio-engineerSubagent

CU optimization specialist using Pinocchio framework. Use for performance-critical programs requiring 80-95% CU reduction vs Anchor. Specializes in zero-copy access, manual validation, and minimal binary size.\\n\\nUse when: CU limits are being hit, transaction costs are significant at scale, binary size must be minimized, or maximum throughput is required.

rust-backend-engineerSubagent

Rust backend specialist for building async services that interact with Solana blockchain. Builds APIs, indexing services, and off-chain processing using Axum, Tokio, and modern async patterns.\n\nUse when: Building REST/WebSocket APIs for Solana dApps, implementing transaction indexers, creating webhook services, or any Rust backend that interacts with Solana.

solana-architectSubagent

Senior Solana program architect for system design, account structures, PDA schemes, token economics, and cross-program composability. Use for high-level design decisions, architecture reviews, and planning complex multi-program systems.\n\nUse when: Designing new programs from scratch, planning account structures, optimizing PDA schemes, reviewing architecture for security, or deciding between implementation approaches.