4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ダッシュボード:
https://qiita.com/takulabo/items/d5f56132c02d4136687c


Claude Codeを使ってみよう

ClaudeCodeを利用する方法には複数あります
・ClaudeCodeDesktop
・ClaudeCode + VScode
・ClaudoCode(CLI)
ここでは、ローカルLLMと連携利用する方法を案内します。
ClaudeCode(CLI)の案内が対象になります。
2回に分けて解説していきます。

  • 第1回 ClaudeCodeセットアップ
  • 第2回 ClaudeCode + LMStudio連携
    リンクはこちら

セットアップ環境

・Windows x86
・LMStudio

■ ClaudeCode (CLI)

最も柔軟性があり高度な使い方ができます。

ClaudeCodeセットアップ手順

powershellを立ち上げます。

Windwsでpowershellを起動しましょう
検索欄にpowershell+ [Enter]などで起動。
image.png

ClaudeCodeインストール

powershell
irm https://claude.ai/install.ps1 | iex

10分ほどかかります。

パス確認コマンド

powershell
$env:PATH -split ';' | Select-String 'local\\bin'

パス設定コマンド

powershell
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')

ターミナルを閉じます。
右上の「×」か、「exit」コマンドに手終了します。

■インストール確認

powershellを再度起動しコマンドを打ちます。

powershell
claude --version

出力例:2.1.87 (Claude Code)
バージョンが表示されることを確認。
インストールは完了です。

■ 作業ディレクトリの作成

作業フォルダを作成しましょう。
今回は「C:\AI\claude-cli\test」フォルダを作成しました。

フォルダを移動します。

powershell
cd C:\AI\claude-cli\test

■ claudeを起動します

powershell
claude

image.png
上記が表示されればインストールはできています。
[Ctrl]+C
2回入力して終了します。

モード選択

☑ 1.Dark mode (default)

「2. Light mode」などを選んでもOKです。

■LMStudioでLLMサーバを起動します。

手順は以前の記事を参照してください。
LMStudioセットアップ:https://qiita.com/takulabo/items/4edad54db8e5385daace
LMStudio初期設定:https://qiita.com/takulabo/items/4edad54db8e5385daace
※起動中のモデル名が必要になります。
 確認してコピーしておいてください。

■環境変数を設定する

powershell
$env:ANTHROPIC_BASE_URL="http://localhost:1234/v1"
$env:ANTHROPIC_API_KEY="lm-studio"

※環境に合わせて[localhost]の値は変更してください。
 LLMサーバを動作させているIPアドレスなど。

■Claude Codeを起動する

モデルを指定してClaudeCodeを起動する。

※[qwen/qwen3.5-35b-a3b]の値はLMstudioで
 起動中のモデルを記載してください。

powershell
claude --model qwen/qwen3.5-35b-a3b

■APIキーを選択

「1. Yes」を選択してください。
 ※2.を選ばないように注意

  ANTHROPIC_API_KEY: sk-ant-...lm-studio
  Do you want to use this API key?
    1. Yes
    2. No (recommended)

■注意喚起表示

[Enter]で進みます。

 Security notes:
 1. Claude can make mistakes
    You should always review Claude's responses, especially when
    running code.
 2. Due to prompt injection risks, only use it with code you trust
    For more details see:
    https://code.claude.com/docs/en/security

■権限の確認

「1. Yes, I trust this folder」を選択します。
 ※Claude Codeは👇できるため権限の確認です。
  「ファイル読み取り、ファイル編集、コマンド実行」
  専用のフォルダを作成済みで実行するためOKです。

 Accessing workspace:
 C:\AI\claude-cli\test
 Quick safety check: Is this a project you created or one you trust? (Like your own code, a well-known open source
 project, or work from your team). If not, take a moment to review what's in this folder first.
 Claude Code'll be able to read, edit, and execute files here.
 Security guide
 > 1. Yes, I trust this folder
   2. No, exit
 Enter to confirm · Esc to cancel

■起動完了

下の画面が確認できれば起動完了です。
image.png

まとめ

ClaudeCodeのセットアップは完了になります。
ClaudeCodeの契約があればこのまま使うことも可能です。
次回は、LMstudioと連携したセットアップを案内します。
完全無料で利用できます。

第2回:ClaudeCode + LMStudioセットアップ(リンク)

ダッシュボード:
https://qiita.com/takulabo/items/d5f56132c02d4136687c

4
2
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?