いい加減、AIを活用した形での開発というものに対応していかないと、ということで、Claudeに課金もしているのでClaude codeを試してみることにしました。
ちなみに、やっていく過程で知ったのですが、チャットのClaudeへの課金とAPI利用となるClaude codeの課金は別に必要でした。。。
WSL環境としての準備
のほほんと、@anthropic-ai/claude-codeをインストールしようとしたところ、Windows非対応と怒られてしまいました。
Windows環境でClaude codeを使うにはWSL上で呼び出して上げる必要があるようです。
WSLの起動
WSLの起動自体は”wsl”コマンドを打つだけです
wsl
ubuntuがインストールされていなかったり、デフォルトがubuntuではなくなっている可能性もあり、その場合はエラーが出てしまいます
> wsl
<3>WSL (24 - Relay) ERROR: CreateProcessParseCommon:863: Failed to translate C:\Users\krote
<3>WSL (24 - Relay) ERROR: CreateProcessParseCommon:909: getpwuid(0) failed 2
この場合は、一覧を確認し、デフォルトをUbuntuに変更しておきましょう
> wsl -l -v
NAME STATE VERSION
* docker-desktop-data Running 2
Ubuntu Running 2
docker-desktop Running 2
> wsl --setdefault ubuntu
この操作を正しく終了しました。
> wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
docker-desktop-data Running 2
nodeのインストール
WSL環境に、nodejsをインストールします
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
Claude code のインストール
下準備が揃ったので、Claude code をインストールします
su
npm install -g @anthropic-ai/claude-code
問題なくインストールが終わりバージョン確認ができればOKです
> claude -v
0.2.69 (Claude Code)
4/13日時点では0.2.69ということで、まだresearch preview。バージョン1には満たない状態です。
インストール時のエラー
npm install を実行したときに下記エラーが起きました。
npm install -g @anthropic-ai/claude-code
npm error code 1
npm error path C:\Users\XXX\AppData\Roaming\fnm\node-versions\v22.14.0\installation\node_modules\@anthropic-ai\claude-code
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/preinstall.js
npm error Error: Claude Code is not supported on Windows.
npm error Claude Code requires macOS or Linux to run properly.
npm error If you are using WSL (Windows Subsystem for Linux):
npm error 1. Make sure you are running npm install from within the WSL terminal, not from PowerShell or CMD
npm error 2. If you're still seeing this message in WSL, your environment may be incorrectly reporting as Windows
npm error Please visit https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#check-system-requirements for troubleshooting information.
これは、エラーメッセージにも書かれているように、WSL上ではなくPowershellやCMD上で実行されている事によるエラーです。
WSL上のTerminalで実行する必要があります
Claude code の実行
早速使ってみたいと思います。
claude

コマンドを実行すると起動します

注意書きが続き。。。

アカウントとの紐づけをリクエストしてきますので紐づけます

一通り終わると、チャットウィンドウが残り使えるようになるので、早速エラーが出て若干放置気味だったプロジェクトで内容確認を試してみたのですが。。。
> このコードベースを説明してください
⎿ Credit balance too low · Add funds: https://console.anthropic.com/settings/billing
> /init is analyzing your codebase…
⎿ Credit balance too low · Add funds: https://console.anthropic.com/settings/billing
ということで、カネがないと。
ここで、チャット側で課金していてもAPIは別だということを知ります。
しょうがないので、$5課金してもう一度試してみたところ
● Task(Please analyze this codebase and explain what it does. Look at the main files and structure to understand the project's …
purpose and architecture. Focus on:…)
⎿ Done (7 tool uses · 12.6k tokens · 28.5s)
● これはXXXX用のElectron+Next.jsデスクトップアプリケーションです。SQLiteデータベースを使用し、データの表示・分析機能を提供し
ます。TypeScriptで記述され、TailwindCSSでスタイリングされています。メイン機能はSQLクエリ実行、データ可視化(グラフ)、結果表示
などです。Electronのプリロードスクリプトを通じてUIとデータベース操作を安全に連携させています。
読み込んでくれました!
この一発でAPIとしては、$0.15ほど消費したようです

ここから
ようやく環境としてはできたので、ここからですね。
少し、今のコードベース上で発生していた起動時のエラーに関しての修正を指示したところそれなりに動いてくれました。
どういう形で回していくとより良いのか。いじっていきたいと思います。