コンテンツにスキップ

Install Claude Code globally using npm

Claude Code CLI チートシート

概要

Claude Codeは、Anthropicによるエージェント型コーディングアシスタントで、ターミナル内に存在します。完全なコードベースを理解し、自然言語の説明から機能を構築し、バグを修正し、面倒な開発タスクを自動化できます。このチートシートは、コマンドラインインターフェース(CLI)の使用に焦点を当てています。

インストール

# Install Claude Code globally using npm
npm install -g @anthropic-ai/claude-code

はじめに

# Navigate to your project directory
cd your-project

# Start an interactive session with Claude Code
claude

コアコマンド

# Ask a question about your codebase
claude "How does the authentication middleware work?"

# Build a new feature
claude -p "Create a new API endpoint for user profiles"

# Fix a bug from an error message
claude -p "Fix this error: 'TypeError: Cannot read property 'id' of undefined'"

# Run a command and pipe the output to Claude
tail -f server.log | claude -p "Alert me if you see any critical errors"

主な機能

  • コードベース認識: プロジェクト構造全体を理解します。
  • エージェント機能: ファイルの読み取り、コマンドの実行、コミットの作成が可能です。
  • 自然言語インターフェース: 平易な英語でコードベースと対話できます。
  • ターミナル統合: 既存のターミナルワークフローにシームレスに統合されます。
  • MCP統合: Google Drive、Figma、Jiraなどの外部ツールに接続します。

一般的なワークフロー

  • 機能開発: 機能を説明すると、Claude Codeが計画と実装を行います。
  • デバッグ: エラーメッセージを貼り付けると、Claudeが根本的な原因を見つけて修正します。
  • コードリファクタリング: 可読性を向上させるために、ファイルや関数のリファクタリングをClaudeに依頼できます。
  • ドキュメンテーション: コードベースの特定の部分のドキュメントを生成します。
  • CI/CD自動化: リント、テスト、リリースノートなどのタスクを自動化します。

高度な使用法

# Use a specific model for a task
claude --model claude-3-opus -p "Analyze the performance of this function"

# Set a custom prompt for a session
claude --prompt "You are a senior security engineer. Review this code for vulnerabilities."

# Integrate with other tools
claude -p "Read the design doc from Google Drive and implement the new UI"

追加リソース