Skip to Content
DocsAIAI Coding Assistants (CLI)

AI Coding Assistants (CLI)

Command-line AI coding assistants let you interact with large language models directly in the terminal to write, debug, refactor code, perform Git operations, and more. For developers who prefer terminal workflows, these tools can dramatically boost productivity.

Claude Code

Claude Code is Anthropic’s official CLI coding assistant, powered by Claude models. It can understand entire codebases, execute commands, and edit files, making it one of the most powerful terminal AI programming tools.

Install Claude Code

# Ensure Node.js 18+ is installed node --version # If Node.js is not installed, install it first curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - sudo apt install -y nodejs # Install Claude Code globally via npm npm install -g @anthropic-ai/claude-code # Verify installation claude --version

Basic Usage

# Start Claude Code in your project directory cd ~/my-project claude # Direct query mode (non-interactive) claude "Explain this project's architecture" # Pipe mode -- pass file contents to Claude cat error.log | claude "Analyze this error log and find the root cause" # Execute a single task and exit claude --print "Generate a Python .gitignore file"

Interactive Sessions

After starting claude, you enter an interactive session where you can:

> Read all Python files in the src/ directory and summarize the project structure > Add a logging decorator function to utils.py > Find all unhandled exceptions and fix them > Run the tests and fix any failing cases > Write a Dockerfile to containerize this project

Configuration

# Set API key export ANTHROPIC_API_KEY="sk-ant-xxxxx" # Write to shell config for persistence echo 'export ANTHROPIC_API_KEY="sk-ant-xxxxx"' >> ~/.bashrc source ~/.bashrc

Project-level configuration:

Create a CLAUDE.md file in the project root to define project context and AI behavior rules:

cat > CLAUDE.md << 'EOF' # Project Description This is a Python Flask web application project. ## Tech Stack - Python 3.12 - Flask 3.x - PostgreSQL 16 - Redis ## Code Standards - Use Black for code formatting - Use mypy for type checking - All functions must have docstrings - Tests use pytest ## Project Structure - `app/` -- Main application code - `tests/` -- Test files - `migrations/` -- Database migrations EOF

Command Quick Reference

# Enter interactive mode claude # Resume last session claude --continue # Use a specific model claude --model claude-sonnet-4-20250514 # Output as plain text (suitable for scripts) claude --print "Generate a UUID" # View help claude --help
Tip

Claude Code automatically reads project files to understand code context. In large projects, writing a good CLAUDE.md file helps the AI understand your project structure and coding standards more accurately, significantly improving interaction quality.


Aider

Aider is an open-source terminal AI pair programming tool that supports connecting to multiple models (Claude, GPT-4, local models, etc.) and can directly edit code files and automatically generate Git commits.

Install Aider

# Ensure Python 3.10+ is installed python3 --version # Method 1: Install via pipx (recommended) sudo apt install -y pipx pipx ensurepath pipx install aider-chat # Method 2: Install via pip inside a virtual environment (PEP 668: no pip into the system Python) python3 -m venv ~/aider-env source ~/aider-env/bin/activate pip install aider-chat # Method 3: Via official install script curl -LsSf https://aider.chat/install.sh | bash # Verify installation aider --version

Connect to Models

# Use Claude (set API key) export ANTHROPIC_API_KEY="sk-ant-xxxxx" aider --model claude-sonnet-4-20250514 # Use OpenAI GPT-4 export OPENAI_API_KEY="sk-xxxxx" aider --model gpt-4o # Use local Ollama model aider --model ollama/qwen2.5-coder:14b # Use DeepSeek export DEEPSEEK_API_KEY="your-key" aider --model deepseek/deepseek-chat

Basic Usage

# Start Aider in a Git repository cd ~/my-project aider # Specify files to edit aider src/main.py src/utils.py # Use architect mode (design first, then code) aider --architect

In the Aider interactive interface:

> Add command-line argument parsing to main.py > /add tests/test_main.py # Add a file to the session > /run pytest # Run a command > /diff # View what AI changed > /undo # Undo the last AI change > /help # View all commands

Configuration File

Create .aider.conf.yml in the project root:

# .aider.conf.yml model: claude-sonnet-4-20250514 auto-commits: true dark-mode: true stream: true
Note

Aider automatically creates a Git commit for each AI change. If you don’t want automatic commits, start with the --no-auto-commits flag.


GitHub Copilot CLI

GitHub Copilot CLI brings Copilot’s capabilities to the terminal, helping you generate shell commands and explain command meanings.

Installation

The old gh extension install github/gh-copilot extension is deprecated. Install the standalone Copilot CLI via npm instead:

# First ensure you have Node.js (if not installed) curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - sudo apt install -y nodejs # Install GitHub Copilot CLI via npm npm install -g @github/copilot # Verify installation copilot --version

Basic Usage

# Start an interactive session copilot # Pass a prompt directly (the prompt is a positional argument) copilot "Find all files larger than 100MB in the current directory"

In an interactive session you describe your intent in natural language; Copilot proposes commands or explanations and asks for confirmation before executing.

Tip

GitHub Copilot CLI requires a valid GitHub Copilot subscription, and the first run guides you through signing in to your GitHub account.


Gemini CLI

Gemini CLI is Google’s terminal AI tool, powered by Gemini models, supporting code understanding, file operations, and multimodal capabilities.

Installation

# First ensure you have Node.js (if not installed) curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - sudo apt install -y nodejs # Install Gemini CLI via npm npm install -g @google/gemini-cli # Verify installation gemini --version

Configuration and Usage

# Set API key export GOOGLE_API_KEY="your-api-key" # Or use Google Cloud authentication # gcloud auth application-default login # Start Gemini CLI cd ~/my-project gemini # Direct query gemini "Explain this project's directory structure"

In interactive mode:

> Analyze code quality of all files under src/ > Help me refactor database.py to use connection pooling > Check package.json and update outdated dependencies

Gemini CLI Special Features

# Multimodal capabilities -- analyze images gemini "Describe the UI layout in this screenshot" < screenshot.png # Handle large codebases (Gemini supports very large context windows) gemini "Summarize all API endpoints in this repository"

OpenCode

OpenCode is an open-source terminal AI coding assistant (the project now lives at github.com/sst/opencode ), supporting Claude, OpenAI, Google, and local models, among others.

Installation

# Method 1 (recommended): official install script curl -fsSL https://opencode.ai/install | bash # Method 2: install via npm npm install -g opencode-ai@latest # Verify installation opencode --version

Configuration

Create a configuration file opencode.json in the project directory or ~/.config/opencode/:

{ "provider": "anthropic", "model": "claude-sonnet-4-20250514", "mcpServers": {} }

Basic Usage

# Set API key export ANTHROPIC_API_KEY="sk-ant-xxxxx" # Start in your project cd ~/my-project opencode

OpenCode provides an IDE-like terminal user interface (TUI) with a file tree, conversation panel, and terminal output.


CLI Tool Comparison

FeatureClaude CodeAiderCopilot CLIGemini CLIOpenCode
DeveloperAnthropicOpen sourceGitHubGoogleOpen source
Default modelClaudeMulti-modelCopilot modelsGeminiMulti-model
Local modelsLimitedSupportedNot supportedNot supportedSupported
File editingDirect editDirect editDirect editDirect editDirect edit
Git integrationSupportedAuto-commitSupportedSupportedSupported
Command executionSupportedSupportedSupportedSupportedSupported
InterfaceREPLREPLREPLREPLTUI
PricingAPI billingAPI billingSubscriptionAPI billingAPI billing

Environment Preparation Summary

Before using these CLI tools, prepare the following environment:

# Install Node.js (required for Claude Code, Gemini CLI, Copilot CLI) curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - sudo apt install -y nodejs # Install Python and pipx (pipx recommended for Aider) sudo apt install -y python3 python3-pip python3-venv pipx pipx ensurepath # Create API key configuration file cat >> ~/.bashrc << 'EOF' # AI API Keys export ANTHROPIC_API_KEY="" export OPENAI_API_KEY="" export GOOGLE_API_KEY="" EOF source ~/.bashrc
Note

All CLI tools send your code to cloud APIs for processing (unless using local models). When working with sensitive or private code, make sure you understand each tool’s data privacy policy. Using local models (e.g., via Aider + Ollama) completely avoids sending data externally.

Last updated on