Getting Started

CLI Usage Guide

Learn how to use AI Developer Assistant from the command line

CLI Usage Guide

AI Developer Assistant is primarily designed as a command-line tool that integrates seamlessly into your development workflow. This guide covers the essential commands and usage patterns.

Basic Command Structure

All AI Developer Assistant commands follow this pattern:

ai-dev <command> [options] [arguments]

Core Commands

1. Code Review

Analyze your code for issues, improvements, and best practices:

# Review your latest changes
ai-dev review

# Review staged changes only
ai-dev review --staged

# Review specific files
ai-dev review --file-patterns "src/**/*.ts"

# Review with verbose output
ai-dev review --verbose

# Review and post to GitHub PR
ai-dev review --post-github --github-owner your-org --github-repo your-repo --pr 123

2. Code Explanation

Get plain English explanations of your code:

# Explain your last commit
ai-dev explain

# Get detailed explanation
ai-dev explain --level detailed --include-examples

# Explain specific files
ai-dev explain --file-patterns "src/utils/**/*.ts"

3. Commit Message Generation

Auto-generate commit messages based on your changes:

# Generate commit message for staged changes
ai-dev commit-msg --staged

# Generate with conventional commit format
ai-dev commit-msg --style conventional --include-body

# Generate with specific length
ai-dev commit-msg --max-length 100

4. Security Scanning

Find vulnerabilities and security issues:

# Basic security scan
ai-dev security-scan

# Scan with specific severity levels
ai-dev security-scan --severity high,critical

# Scan including dependencies
ai-dev security-scan --include-dependencies

5. Test Generation

Generate test cases with automatic framework detection:

# Generate test suggestions
ai-dev test-suggest

# Generate for specific framework
ai-dev test-suggest --framework jest --type unit

# Generate with coverage target
ai-dev test-suggest --coverage-target 80

6. Documentation Generation

Create comprehensive documentation:

# Generate documentation
ai-dev docs

# Generate API documentation
ai-dev docs --format jsdoc --include-examples

# Generate for specific files
ai-dev docs --file-patterns "src/api/**/*.ts"

Advanced Usage Patterns

File Pattern Matching

Use powerful glob patterns to target specific files:

# Multi-language project analysis
ai-dev review --file-patterns "frontend/**/*.{ts,tsx}"  # Frontend TypeScript
ai-dev review --file-patterns "backend/**/*.py"        # Backend Python
ai-dev review --file-patterns "mobile/**/*.dart"       # Mobile Dart/Flutter

# Exclude patterns
ai-dev review --file-patterns "src/**/*.ts" --exclude-patterns "*test*"

Output Formats

Choose different output formats for different use cases:

# Console output (default)
ai-dev review

# Markdown output
ai-dev review --format markdown --output-path review.md

# JSON output
ai-dev review --format json --output-path review.json

# HTML output
ai-dev review --format html --output-path review.html

Configuration Override

Override configuration settings via command line:

# Use different LLM provider
ai-dev review --llm-provider openai --openai-api-key your-key

# Use different model
ai-dev review --llm-model gpt-4 --llm-temperature 0.5

# Enable verbose mode
ai-dev review --verbose --output-colorize

Common Workflows

Daily Development Workflow

# 1. Make your changes
git add .

# 2. Review your changes
ai-dev review --staged

# 3. Generate commit message
ai-dev commit-msg --staged --style conventional

# 4. Commit with the generated message
git commit -m "$(ai-dev commit-msg --staged)"

Pull Request Workflow

# 1. Create PR and get PR number
# 2. Review with GitHub integration
ai-dev review --post-github --github-owner your-org --github-repo your-repo --pr 123

# 3. Generate PR summary
ai-dev pr-summary --pr 123

Security Review Workflow

# 1. Full security scan
ai-dev security-scan --include-dependencies

# 2. Generate security report
ai-dev security-scan --format markdown --output-path security-report.md

Documentation Workflow

# 1. Generate documentation for new code
ai-dev docs --format markdown --include-examples

# 2. Generate API documentation
ai-dev docs --format jsdoc --target "src/api/**/*.ts"

Environment Variables

Set up environment variables for seamless usage:

# Add to your shell profile (.bashrc, .zshrc, etc.)
export LLM_PROVIDER="gemini"
export GEMINI_API_KEY="your-gemini-api-key"
export LLM_MODEL="gemini-2.0-flash"

# Then simply run commands without specifying provider
ai-dev review                    # Uses your environment variables automatically
ai-dev explain                   # No need to specify API keys or provider
ai-dev security-scan            # All settings inherited from environment

Getting Help

# Get help for any command
ai-dev <command> --help

# List all available commands
ai-dev --help

# Check version and configuration
ai-dev version
ai-dev config show

Integration with IDEs

VS Code Integration

Create a VS Code task for quick access:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "AI Code Review",
      "type": "shell",
      "command": "ai-dev",
      "args": ["review", "--file-patterns", "${file}"],
      "group": "build",
      "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "new"
      }
    }
  ]
}

Shell Aliases

Add convenient aliases to your shell:

# Add to your shell profile
alias ai-review="ai-dev review --verbose"
alias ai-explain="ai-dev explain --level detailed"
alias ai-security="ai-dev security-scan --severity high,critical"
alias ai-tests="ai-dev test-suggest --include-setup"
The CLI is designed to be fast and efficient. Most commands complete in seconds, making it perfect for integration into your daily development workflow.

Troubleshooting CLI Issues

Common Issues

Command not found:

# Make sure ai-dev is in your PATH
which ai-dev

# Reinstall globally if needed
npm install -g kg6-codex

Permission errors:

# Make sure the binary is executable
chmod +x $(which ai-dev)

# Or use npx
npx ai-dev review

Configuration errors:

# Validate your configuration
ai-dev config validate

# Show current configuration
ai-dev config show
For more advanced usage and configuration options, see the Configuration Guide.