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

VS Codeを開いたらCLI版Claude Codeも勝手に起動する方法How to Auto-Launch the Claude Code CLI When You Open VS Code

元記事を読むRead original articleqiita.com(新しいタブで開きます)(opens in a new tab)
AI 要約AI summary

VS Codeのユーザー用tasks.jsonに起動タスクを登録し、settings.jsonでtask.allowAutomaticTasksをonにすると、フォルダを開くだけでCLI版Claude Codeが立ち上がる。毎回手動で起動する手間を省きたい人に役立つ。

Registering a user-level task in VS Code's tasks.json and turning on task.allowAutomaticTasks in settings.json launches the Claude Code CLI whenever a folder opens, saving manual startup for CLI users.

AI 生成の要約と解説(解説は要約と収集メタデータに基づく)で、元記事全文の転載・翻訳ではありません。日本語版と英語版は言語ごとに独立して生成しています。正確性は元記事 (qiita.com) でご確認ください。AI-generated summary and explainer (the latter based on the summaries and collected metadata), not a copy or translation of the full source article. Generated independently for each language. Verify accuracy at the original source (qiita.com).

VS CodeでCLI版のClaude Codeを使っている場合、フォルダを開くたびに手動で起動する手間がかかる。ユーザー用のタスクと設定を一つずつ追加すれば、フォルダを開くだけで自動起動させられる。

CLI版は自動起動しない

GUI版のClaude Codeは自動で起動してくれる。一方、CLI版を使っていると自動起動は働かない。そこでVS Codeのタスク機能を使い、フォルダを開いたときにCLI版が立ち上がるようにする。

tasks.jsonに登録

最初にコマンドパレット(Ctrl+Shift+P)から「Tasks: Open User Tasks」を開く。Windowsでは、このファイルは %APPDATA%\Code\User\tasks.json にある。

tasks.jsonがまだ空なら、紹介されている内容をそのまま貼り付ければよい。すでに別のタスクを登録している場合は、tasksの配列に { "label": "Claude Code", ... } の部分だけを追記する。

自動タスクを許可する

次に、コマンドパレットから「Preferences: Open User Settings (JSON)」を開く。既存の { } の中に、次の1行を足すだけでよい。

"task.allowAutomaticTasks": "on"

この設定は、フォルダを開いたときの自動タスクを許可するものだ。前の行の末尾にカンマを付け忘れないよう注意が必要とされている。

この2つを済ませると、VS Codeでフォルダを開くだけでCLI版Claude Codeが立ち上がる。

横に出せない点

起動後のターミナルを、本来は画面の横に表示させたいという。ただ、最初から横で開かせるのは難しそうだと説明されている。そのため現状は、起動後にターミナルのタブをドラッグして横へ移動させている。

Auto-launching the CLI version

The author uses the CLI version of Claude Code inside VS Code. According to the article, the GUI version starts automatically, but the CLI version does not. The method described here makes the CLI launch whenever a folder is opened, which saves starting it by hand each time.

Registering the user task

The first step is to open the Command Palette with Ctrl+Shift+P and run "Tasks: Open User Tasks". On Windows, this file is located at %APPDATA%\Code\User\tasks.json.

If tasks.json is still empty, the author says to paste in the provided task definition as it is. If other tasks already exist, only the entry labeled "Claude Code" needs to be added to the existing tasks array. The article does not reproduce the full task contents beyond that label in the portion described here.

Allowing automatic tasks

The second step is to open the Command Palette again and run "Preferences: Open User Settings (JSON)". Inside the existing curly braces, add one line:

"task.allowAutomaticTasks": "on"

The article's comment on this line explains that it permits automatic tasks when a folder is opened. It also reminds readers to add a trailing comma to the previous line so the JSON stays valid.

Together, the user-level task and this setting are what cause the CLI version of Claude Code to start once a folder is opened.

Panel placement caveat

The author notes a limitation. They would prefer the Claude Code terminal to appear on the side, but they say that making it open sideways from the start looks difficult. As a workaround, after it launches, they drag the terminal tab, marked with a red box in the article's screenshot, to the side by hand.

In short, the setup removes the manual launch step for CLI users, while the side-by-side layout still requires a manual drag after startup.

ポコとTECHガイドPoko & TECH Guide

ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.

  1. ポコPoko設定ファイルに1行足すだけで、フォルダを開くとClaude Codeが勝手に立ち上がるの?これって手間が減るの?So adding just one line to a settings file makes Claude Code start when I open a folder? Does that really save much effort?
  2. TECHガイドTECH Guideこの記事だと、GUI版は自動起動するけどCLI版はしない、という悩みが出発点だよ。毎回手動で起動する手間を省けるのがねらいなんだ。The article starts from a gap: the GUI version launches automatically, but the CLI version doesn't. This setup removes that manual startup step every time.
  3. ポコPokotasks.jsonって何? 「タスク」を登録するって、どういうことなのかな。What's tasks.json? What does it mean to register a "task"?
  4. TECHガイドTECH Guideタスクは、VS Codeにやってほしい作業を名前付きで書いておくメモ、くらいの意味だよ。ここでは「Claude Codeを起動する」作業を登録するんだ。Think of a task as a named to-do note for VS Code. Here, the note says "launch Claude Code," and the editor runs it for you.
  5. ポコPoko私なら、毎朝フォルダを開いた瞬間に始められるのがうれしいかも。画面の配置もそのままなのかな?I'd love having it ready the moment I open my folder each morning. Does the window layout come out just right too?
  6. TECHガイドTECH Guideそこは条件があって、筆者は横に出したいけれど最初から横で開かせるのは難しそうとしているよ。起動後にターミナルのタブを横へドラッグして動かしているそうだよ。There's a catch. The author wanted it opened on the side but found that hard to do from the start, so they drag the terminal tab sideways after it launches.
記事情報・収集記録Article details & collection record
出典Source
Qiita VSCodeコミュニティCommunity
公開日時 (JST)Published (JST)
収集日時 (JST)Collected (JST)
配信形式Format
ブログBlog
原文言語Source language
日本語Japanese
重要度の位置づけImportance in this lane
InfoInformational(Claude / Claude Code 167件中、同等以上 167件)(167 of 167 Claude / Claude Code entries are equal or higher)
出典の平均重要度(掲載直近 30 件・最大 30 件)Source average (last 30 listed, up to 30)
1.9 / 31=情報 · 2=中 · 3=高1=Info · 2=Medium · 3=High
情報の寿命Half-life
中期 (チュートリアル)Medium-term (tutorial)

🧡Claude / Claude Code の他の記事More from Claude / Claude Codeもっと見る →View more →

ページ上部へScroll to top