3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【WSL経由】最強エージェントコーディングツール「Claude Code」を使う

Last updated at Posted at 2025-03-03

目的

つい先日、Anthropic社からClaude 3.7 Sonnet と Claude Code が発表されました。

今回はこのClaude Codeに焦点を当てて、実行までの手順を示します。

Claude Code は、コードの検索と読み取り、ファイルの編集、テストの作成と実行、GitHub へのコードのコミットとプッシュ、コマンドラインツールの使用など、すべてのステップで最新情報を入手できるアクティブなコラボレーターです。

現在、Claude Code は Windows で直接実行されず、代わりにWSLが必要になります。
以下にWSL経由のWindowsで使えるようにするまでの手順を示します。

手順

公式ドキュメントはこちら↓

前提条件

まず、Claude Codeを使う条件として以下のシステム要件があります。

  • オペレーティングシステム:macOS 10.15+、Ubuntu 20.04+/Debian 10+、またはWSL経由のWindows
  • ハードウェア:最小4GBのRAM
  • ソフトウェア:
    • Node.js 18+
    • git 2.23+ (オプション)
    • PR ワークフロー用の GitHub または GitLab CLI (オプション)
    • 拡張ファイル検索用のripgrep(RG)(オプション)
  • ネットワーク:認証やAI処理に必要なインターネット接続
  • 場所: サポートされている国でのみ利用可能

そこで、WSL2および、Node.jsのインストールまでは以下のドキュメントを参考に実施済としています。

Claude Codeのインストール

基本的に公式手順に従えば問題ありません。
Ubuntu上でコマンドを打っていきます。

$ npm install -g @anthropic-ai/claude-code
$ cd your-project-directory
$ claude

初回起動時にはテキストスタイルを選択する画面が表示されます。
ここは好みで選んでください。

╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

 Let's get started.

 Choose the text style that looks best with your terminal:
 To change this later, run /config

 ❯ Light text
   Dark text
   Light text (colorblind-friendly)
   Dark text (colorblind-friendly)


 Preview
 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ 1 function greet() {                                                                                              │
 │ 2    console.log("Hello, World!");                                                                                 │ 2    console.log("Hello, Claude!");                                                                                │ 3 }                                                                                                               │
 ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Claude Codeが起動したらEnterを押してください。
Anthropic Console へのログインが開始されます。

╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

  ██████╗██╗      █████╗ ██╗   ██╗██████╗ ███████╗
 ██╔════╝██║     ██╔══██╗██║   ██║██╔══██╗██╔════╝
 ██║     ██║     ███████║██║   ██║██║  ██║█████╗
 ██║     ██║     ██╔══██║██║   ██║██║  ██║██╔══╝
 ╚██████╗███████╗██║  ██║╚██████╔╝██████╔╝███████╗
  ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
  ██████╗ ██████╗ ██████╗ ███████╗
 ██╔════╝██╔═══██╗██╔══██╗██╔════╝
 ██║     ██║   ██║██║  ██║█████╗
 ██║     ██║   ██║██║  ██║██╔══╝
 ╚██████╗╚██████╔╝██████╔╝███████╗
  ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝

 Claude Code is billed based on API usage through your Anthropic Console account.

 Pricing may evolve as we move towards general availability.

 Press Enter to login to your Anthropic Console account…

ブラウザ上でAnthropic Consoleが開かれたら、「Authorize」を押下して認証を通してください。
image.png

認証後、APIが発行されますので、それをコピーしてターミナルに貼り付けます。
スクリーンショット 2025-03-03 131620.png

╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

  ██████╗██╗      █████╗ ██╗   ██╗██████╗ ███████╗
 ██╔════╝██║     ██╔══██╗██║   ██║██╔══██╗██╔════╝
 ██║     ██║     ███████║██║   ██║██║  ██║█████╗
 ██║     ██║     ██╔══██║██║   ██║██║  ██║██╔══╝
 ╚██████╗███████╗██║  ██║╚██████╔╝██████╔╝███████╗
  ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
  ██████╗ ██████╗ ██████╗ ███████╗
 ██╔════╝██╔═══██╗██╔══██╗██╔════╝
 ██║     ██║   ██║██║  ██║█████╗
 ██║     ██║   ██║██║  ██║██╔══╝
 ╚██████╗╚██████╔╝██████╔╝███████╗
  ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝

 Browser didn't open? Use the url below to sign in:

https://console.anthropic.com/oauth/authorize?client_id=hogehoge

 Paste code here if prompted >

認証が通ったら「Login successful. Press Enter to continue…」と表示されるので、Enterを押しましょう。

╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

  ██████╗██╗      █████╗ ██╗   ██╗██████╗ ███████╗
 ██╔════╝██║     ██╔══██╗██║   ██║██╔══██╗██╔════╝
 ██║     ██║     ███████║██║   ██║██║  ██║█████╗
 ██║     ██║     ██╔══██║██║   ██║██║  ██║██╔══╝
 ╚██████╗███████╗██║  ██║╚██████╔╝██████╔╝███████╗
  ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
  ██████╗ ██████╗ ██████╗ ███████╗
 ██╔════╝██╔═══██╗██╔══██╗██╔════╝
 ██║     ██║   ██║██║  ██║█████╗
 ██║     ██║   ██║██║  ██║██╔══╝
 ╚██████╗╚██████╔╝██████╔╝███████╗
  ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝

 Browser didn't open? Use the url below to sign in:

https://console.anthropic.com/oauth/authorize?client_id=hogehoge

 Logged in as your-email@hogehoge.com

 Login successful. Press Enter to continue…

ここからは使用上の注意事項のアナウンスになります。
内容を確認し、問題なければEnterで構いません。
※内容は翻訳にかけてください。。

╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

 Security notes:

 1. Claude Code is currently in research preview
    This beta version may have limitations or unexpected behaviors.
    Run /bug at any time to report issues.

 2. Claude can make mistakes
    You should always review Claude's responses, especially when
    running code.

 3. Due to prompt injection risks, only use it with code you trust
    For more details see:
    https://docs.anthropic.com/s/claude-code-security

 Press Enter to continue…
╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

 Using Claude Code effectively:

 1. Start in your project directory
    Files are automatically added to context when needed.

 2. Use Claude Code as a development partner
    Get help with file analysis, editing, bash commands,
    and git history.

 3. Provide clear context
    Be as specific as you would with another engineer.
    The better the context, the better the results.

 For more details on Claude Code, see:
 https://docs.anthropic.com/s/claude-code

 Press Enter to continue…
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                     │
│ Do you trust the files in this folder?                                                                              │
│                                                                                                                     │
│ /home/eiji_noguchi/my-project                                                                                       │
│                                                                                                                     │
│ Claude Code may read files in this folder. Reading untrusted files may lead Claude Code to behave in an unexpected  │
│ ways.                                                                                                               │
│                                                                                                                     │
│ With your permission Claude Code may execute files in this folder. Executing untrusted code is unsafe.              │
│                                                                                                                     │
│ https://docs.anthropic.com/s/claude-code-security                                                                   │
│                                                                                                                     │
│ ❯ Yes, proceed                                                                                                      │
│   No, exit                                                                                                          │
│                                                                                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
   Enter to confirm · Esc to exit

諸々の確認が終わると、いよいよプロンプトの入力画面が表示されます。

╭─────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!              │
│                                                         │
│   /help for help                                        │
│                                                         │
│   cwd: /home/eiji_noguchi/my-project                    │
╰─────────────────────────────────────────────────────────╯

 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude.
 2. Ask Claude questions about your codebase.
 3. Ask Claude to implement changes to your codebase.

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > Try "create a util logging.py that..."                                                                            │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ! for bash mode · / for commands · esc to undo

他のCopilot系のツールを使っている方はイメージつくかと思いますが、
スラッシュコマンド(/)で様々な指示が出せます。
こちらも公式ページに記載があるので参考にしてみてください。

コスト確認

今回のClaude CodeはAnthropic APIをたたくことで実現されています。
ブラウザ上のチャットから使う場合とまた課金体系が異なることを注意してください。

自分のAPI keysの画面を確認すると、Claude Code用のAPI keyが追加されていることが確認できます。
Claude Codeを使えば使うほどこのcostが増えていきますので、お気を付けください。

ClaudeAPI.png

まとめ

研究段階とはいえ、Claude3.7の頭脳を持つエージェントコーディングツールがリリースされました。
使い勝手などはこれからの確認になりますが、ドキュメントを見る限り既に様々なタスクに対応していそうですね。
また、「GtiHub Copilot」や「Amazon Q」などと比べた結果などを見ていければと思います。

エンジニアがコーディングをするのが時代遅れになるのも近いかもしれませんね。。。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?