Skip to Content
ドキュメントAIAI コーディング アシスタント (CLI)

AI コーディング アシスタント (CLI)

コマンドライン AI コーディング アシスタントを使用すると、ターミナルで大規模な言語モデルを直接操作して、コードの作成、デバッグ、リファクタリング、Git 操作の実行などを行うことができます。ターミナル ワークフローを好む開発者にとって、これらのツールは生産性を大幅に向上させることができます。

クロード・コード

Claude Code は、Claude モデルを利用した Anthropic の公式 CLI コーディング アシスタントです。コードベース全体を理解し、コマンドを実行し、ファイルを編集できるため、最も強力なターミナル AI プログラミング ツールの 1 つとなります。

クロードコードをインストールする

# 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

基本的な使い方

# 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"

インタラクティブなセッション

claude を開始した後、対話型セッションに入り、次のことを行うことができます。

> 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

構成

# 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

プロジェクトレベルの構成:

プロジェクト ルートに CLAUDE.md ファイルを作成して、プロジェクト コンテキストと AI 動作ルールを定義します。

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

コマンドクイックリファレンス

# 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 はプロジェクト ファイルを自動的に読み取り、コードのコンテキストを理解します。大規模なプロジェクトでは、適切な CLAUDE.md ファイルを作成すると、AI がプロジェクトの構造とコーディング標準をより正確に理解できるようになり、インタラクションの品質が大幅に向上します。


補助者

Aider は、複数のモデル (Claude、GPT-4、ローカル モデルなど) への接続をサポートし、コード ファイルを直接編集して Git コミ​​ットを自動的に生成できる、オープンソースのターミナル AI ペア プログラミング ツールです。

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

モデルに接続する

# 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

基本的な使い方

# 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

Aider インタラクティブ インターフェイスで:

> 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

設定ファイル

プロジェクト ルートに .aider.conf.yml を作成します。

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

Aider は、AI の変更ごとに Git コミットを自動的に作成します。自動コミットを望まない場合は、--no-auto-commits フラグから始めます。


GitHub コパイロット CLI

GitHub Copilot CLI は、Copilot の機能を端末にもたらし、シェル コマンドの生成やコマンドの意味の説明に役立ちます。

インストール

古い gh extension install github/gh-copilot 拡張機能は非推奨になりました。代わりに、npm 経由でスタンドアロン Copilot CLI をインストールします。

# 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

基本的な使い方

# 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"

インタラクティブなセッションでは、自然言語で意図を説明します。 Copilot はコマンドまたは説明を提案し、実行前に確認を求めます。

Tip

GitHub Copilot CLI には有効な GitHub Copilot サブスクリプションが必要です。最初の実行では、GitHub アカウントへのサインインが指示されます。


ジェミニ CLI

Gemini CLI は、Gemini モデルを利用した Google のターミナル AI ツールで、コード理解、ファイル操作、マルチモーダル機能をサポートします。

インストール

# 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

構成と使用法

# 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"

インタラクティブモードの場合:

> 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 の特別な機能

# 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 は、オープンソースのターミナル AI コーディング アシスタント (プロジェクトは現在 github.com/sst/opencode  にあります) であり、Claude、OpenAI、Google、ローカル モデルなどをサポートしています。

インストール

# 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

構成

プロジェクト ディレクトリに構成ファイル opencode.json または ~/.config/opencode/ を作成します。

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

基本的な使い方

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

OpenCode は、ファイル ツリー、会話パネル、ターミナル出力を備えた IDE のようなターミナル ユーザー インターフェイス (TUI) を提供します。


CLI ツールの比較

特徴クロード・コード補助者コパイロット CLIジェミニ CLIオープンコード
開発者人間的オープンソースGitHubグーグルオープンソース
デフォルトモデルクロードマルチモデル副操縦士モデルジェミニマルチモデル
ローカルモデル限定サポートされていますサポートされていませんサポートされていませんサポートされています
ファイル編集直接編集直接編集直接編集直接編集直接編集
Git の統合サポートされています自動コミットサポートされていますサポートされていますサポートされています
コマンドの実行サポートされていますサポートされていますサポートされていますサポートされていますサポートされています
インタフェースREPLREPLREPLREPLトゥイ
価格設定APIの課金APIの課金サブスクリプションAPIの課金APIの課金

環境準備の概要

これらの CLI ツールを使用する前に、次の環境を準備します。

# 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

すべての CLI ツールは、処理のためにコードをクラウド API に送信します (ローカル モデルを使用する場合を除く)。機密コードやプライベート コードを扱う場合は、各ツールのデータ プライバシー ポリシーを必ず理解してください。ローカル モデル (例: Aider + Ollama 経由) を使用すると、データの外部送信を完全に回避できます。