1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VS Codeを開いたらCLI版Claude Codeも勝手に起動する方法

1
Posted at

はじめに

VS CodeでCLI版のClaude Codeを使っています。
GUI版なら自動起動してくれるのですが、CLI版にしていると自動起動してくれません。
CLI版でも自動起動する手順を備忘として残しておきます。

環境

  • Windows 11
  • VS Code

やり方

1. ユーザータスクの編集

コマンドパレット(Ctrl+Shift+P)から Tasks: Open User Tasks を開きます。

Windowsだと %APPDATA%\Code\User\tasks.json にあります。

tasks.json がまだ空なら、以下をそのまま貼ります。すでに別のタスクがある場合は、tasks の配列に { "label": "Claude Code", ... } の部分だけを足してください。

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Claude Code",   // タスクの名前(ターミナルのタブに出る)
      "type": "shell",          // シェルでコマンドを実行する
      "command": "claude",      // 実行するコマンド
      "runOptions": {
        "runOn": "folderOpen"   // フォルダを開いたときに自動で実行する
      },
      "presentation": {
        "reveal": "always",     // 実行したらターミナルを必ず表示する
        "panel": "dedicated",   // このタスク専用のターミナルを使う
        "focus": true            // ターミナルにフォーカスを移す(すぐ入力できる)
      },
      "problemMatcher": []      // 出力からエラーを拾う機能は使わない
    }
  ]
}

2. 自動タスクを許可する

コマンドパレット(Ctrl+Shift+P)から Preferences: Open User Settings (JSON) を開きます。

ユーザーの settings.json にこれを足します。

既存の { } の中に1行足すだけです(前の行の末尾にカンマを付けるのを忘れずに)。

"task.allowAutomaticTasks": "on"  // フォルダを開いたときの自動タスクを許可する

実際の画面

こんな感じで立ち上がってくれます。
image.png

ほんとは横に出てほしいのですが、最初から横で開かせるのは難しそう。

起動したら、下の赤枠(ターミナルのタブ)をドラッグして横に持って行っています。
image.png

以上。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?