Type: docs Makes the version stamps, Compatible Models footers and locale README badges say only what has been checked. Every claim below was checked against `https://code.claude.com/docs/en/<page>.md` or the raw changelog (2.1.303–2.1.322), not written from memory. ## Part A: English footers at 2.1.310 / 2.1.302 Each file's behavioural claims were checked against every changelog entry after its stamp, up to 2.1.322, and against the current docs. A stamp moves only when every claim checks out. | File | Claims checked | Fixes | Sources | New stamp | |---|---|---|---|---| | `INDEX.md` | ~75: AGENTS.md rule (v2.1.277); skill/agent/MCP install paths; `/mcp__github__list_prs`; 5 hook types, 33 events, task-tool model note; `--plugin-dir`; checkpoint menu (6 options); `/workflows`, ultracode (v2.1.284), size guideline; 6 permission modes; `/loop` and the cron tools; Chrome; Remote Control; `SendMessage`/`ListAgents`/`notify_when_idle`; CLI flags | 1. Workflow size: medium aims for fewer than 10 agents only since v2.1.271 (15 before), and the default is small on a Pro plan. 2. dontAsk: file reads inside the working directories also run, as do *most* calls a `permissions.allow` rule or a `PreToolUse` hook approves (neither can approve critical-path `rm`/`rmdir` or network-path reads), and an installed mod can approve some calls. No version is given: the changelog doesn't say when a mod's `tool.check` allow arrived (it is already referenced in 2.1.290, 2.1.292 and 2.1.299). 3. `SendMessage` also reaches sessions on other machines and in the cloud, from a session connected to Remote Control with a claude.ai sign-in; a cloud session can't answer with `SendMessage`. The L383 use-case column now says the same. 4. The `--model` list adds the Fable models. 5. Plan mode: "Read-only analysis" → researches and proposes, runs shell commands to explore, edits blocked until the plan is approved. | [workflows#set-a-size-guideline](https://code.claude.com/docs/en/workflows#set-a-size-guideline) ("The default is `medium`, or `small` when you're signed in on a Pro plan with Claude Code v2.1.271 or later"); CL 2.1.219 ("aim for fewer than 15 agents"), CL 2.1.271 ("lowered the medium size guideline from 15 to 10 agents"); [permission-modes](https://code.claude.com/docs/en/permission-modes#allow-only-pre-approved-tools-with-dontask-mode) ("a mod you installed can still approve some of those calls"; "Claude still runs … file reads inside your working directories and read-only Bash commands"; "It also denies the built-in `AskUserQuestion` tool even if your allow rules match it"; "An allow rule or `PreToolUse` hook can't approve these: Recognized `rm` and `rmdir` critical-path removals … Reads from a network path"); CL 2.1.292 ("Fixed a plugin's `tool.check` hook answering allow running a tool…"), CL 2.1.299 ("…that a `PreToolUse` hook or a mod's `tool.check` hook allowed"); [permission-modes#analyze-before-you-edit-with-plan-mode](https://code.claude.com/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) ("Claude reads files, runs shell commands to explore, and writes a plan, but does not edit your source. Except in interactive terminal sessions with bypass permissions available, edits stay blocked until you approve the plan."); [cross-session-messaging](https://code.claude.com/docs/en/cross-session-messaging) ("reach your sessions on other machines or in the cloud"; "from a session that is connected to Remote Control, which needs a claude.ai sign-in"; "A cloud session … can't use `SendMessage` to answer a message from another machine"); model-config. The "device card" line checked out against [whats-new/2026-w34](https://code.claude.com/docs/en/whats-new/2026-w34). | **2.1.322** | | `LEARNING-ROADMAP.md` | 33 hook events / 5 types; 6 built-in subagents (Explore, Plan, General-purpose, claude, statusline-setup, claude-code-guide); 60+ commands (commands page has 121 rows); `/design` (v2.1.265); `/plan`, `/rewind`, `/loop 5m`, `/schedule`; 6 permission modes (Manual since v2.1.200); Alt+T; skill `effort`/`shell`; plugin `workflows`/`channels`/`dependencies`; agent-teams env var; `claude mcp add --transport http`; `-r`, `--max-turns`, `--output-format json`; all 17 source links resolve | 1. Remote Control: "generally available" → "out of research preview", the docs' own wording. 2. Extended thinking (L368, Exercise 3, checklist): Opus 5.5, Sonnet 5.5, Haiku 5.5 and the Fable models always use extended thinking, so the exercise uses `/effort` and scopes Alt+T / Option+T to models that allow turning thinking off. 3. Exercise 4: checkpoints are automatic and unnamed, so step 1 no longer creates a named "Clean state" checkpoint and step 5 says which one to `/rewind` to. | [whats-new/2026-w34](https://code.claude.com/docs/en/whats-new/2026-w34): "Any machine running `claude remote-control` now shows up as a device card at the top of the Code tab in the Claude app. Remote Control is also out of research preview."; [interactive-mode](https://code.claude.com/docs/en/interactive-mode): Alt+T "Has no effect on Opus 5.5, Sonnet 5.5, Haiku 5.5, or the Fable models, which always use extended thinking."; [model-config](https://code.claude.com/docs/en/model-config): "the effort level is the primary control for how much thinking happens"; [checkpointing](https://code.claude.com/docs/en/checkpointing): "Every prompt you send that starts a turn creates a new checkpoint" | **2.1.322** | | `resources.md` | Adaptive reasoning on Opus 4.7+, Sonnet 5+, Haiku 5.5 and the Fable models; permission modes; 33 hook events; `/loop` and cron; 7 memory tiers; Chrome; keybinding chords; Code Review; Monitor (2.1.98); `/goal` and `claude agents` (2.1.139); `--json` (2.1.145); all links | none needed | model-config, hooks, memory, agent-view, changelog | **stays 2.1.310**: L253 gives `/run`, `/verify`, `/run-skill-generator` as "(v2.1.145+)". Neither the changelog, the v2.1.145 release notes, the skills/commands docs nor the what's-new pages for weeks 19–22 give a version. | | `03-skills/claude-md/SKILL.md` | `name`/`description` frontmatter, `$ARGUMENTS`; CLAUDE.md locations and loading; "under 200 lines"; AGENTS.md gates (v2.1.277, v2.1.281), blocking files, `/config` Project instructions values and default; `@AGENTS.md`/symlink fallback; `.claude/agents/` | L196: the list of cases where AGENTS.md isn't read now includes a disabled built-in plugin, and limits the upgrade case to "in some cases" after upgrading from v2.1.276 or earlier | [memory#when-agents-md-support-is-unavailable](https://code.claude.com/docs/en/memory#when-agents-md-support-is-unavailable): "You used `/plugin` to disable the built-in plugin that reads `AGENTS.md`"; "In some cases, it's your first session after you upgrade from v2.1.276 or earlier" | **stays 2.1.302**: no primary source states L24 ("~150-200 instructions", "system prompt already uses ~50") or L214 (the system reminder says CLAUDE.md "may or may not be relevant") | | `07-plugins/devops-automation/README.md` | `--plugin-dir` install; commands; agents; hooks; MCP; workflow; source URLs (all 200) | none: the stale claims need a design decision (below) | [plugins/components](https://code.claude.com/docs/en/plugins/components): "Save a command at `commands/<file>.md` and it becomes `/<plugin>:<file>`"; [plugins-reference](https://code.claude.com/docs/en/plugins-reference) standard layout: "Hooks \| `hooks/hooks.json`", "MCP servers \| `.mcp.json`" | **stays 2.1.302**: bare `/deploy`, `/rollback`, `/status` (`/status` is also a built-in), `/incident`; `hooks/*.js` are never registered (no `hooks/hooks.json`); `mcp/kubernetes-config.json` never loads (no `.mcp.json` or `mcpServers`) | | `07-plugins/documentation/README.md` | same | none | same | **stays 2.1.302**: bare command names; `mcp/github-docs-config.json` never loads, so the `GITHUB_TOKEN` setup has no effect | | `07-plugins/pr-review/README.md` | same | none | same | **stays 2.1.302**: bare command names; `hooks/pre-review.js` is not registered; `mcp/github-config.json` never loads | No changelog entry from 2.1.303 to 2.1.322 touched the plugin READMEs or SKILL.md. Their problems predate the stamps, and #209 already listed the hook/MCP files that never load. **Locale copies:** the same factual fixes went into every locale with the same sentence. That's dontAsk and plan mode in all six INDEX files; workflow size in fa and ko; `SendMessage` and the use-case column in fa and ko; the `--model` list in fa and ko; "generally available" in fa and ko LEARNING-ROADMAP; the extended-thinking exercise/checklist and the checkpoint exercise in all six LEARNING-ROADMAP copies; the AGENTS.md cases in all six SKILL.md copies. Locale stamps were not bumped. INDEX and LEARNING-ROADMAP stay at 2.1.310 in every locale, and the SKILL.md copies keep their footers. ## Part B: Compatible Models footers The new list is **Claude Fable 5.2, Claude Fable 5.1, Claude Fable 5, Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5.5, Claude Sonnet 5, Claude Sonnet 4.6, Claude Opus 4.8, Claude Haiku 5.5, Claude Haiku 4.5**. It is used on root docs and module pages alike, and it's the README FAQ's list, so the footers and the FAQ no longer disagree. Why one list for both file types: STYLE_GUIDE's footer rule ("List all compatible models") applies to both. A shorter "current models only" list on module pages would break that rule. Justification from [model-config](https://code.claude.com/docs/en/model-config): - **Current models:** "| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |"; "the `fable` alias resolves to Fable 5 in Claude apps gateway sessions and to Fable 5.2 everywhere else"; "Fable 5.2 requires Claude Code v2.1.321 or later". - **Older models still in use:** - "**Fable 5.1 or Fable 5**: select it by model ID." - "| Claude Platform on AWS | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |". - "biology-flagged requests re-run on Opus 5, and cybersecurity-flagged requests re-run on Opus 4.8". - "**Sonnet 5.5**: cybersecurity-flagged requests re-run on Sonnet 5." - **None are retired.** The [models overview](https://platform.claude.com/docs/en/about-claude/models/overview) that model-config links marks only Opus 4.1, Opus 4 and Sonnet 4 as "retired". All eleven listed models appear there without that mark. Scope: 336 lines in 331 files. The changed lines are the `**Compatible Models**` lines (92, some of them in locale files) and every localized label (`호환 모델`, `مدلهای سازگار`, `Các Mô Hình Tương Thích`, `Сумісні моделі`, `対応モデル`, `互換モデル`, `兼容模型`), plus the italic `*対応:…*` / `*Для …*` / `*适用于 …*` lines in the ja/uk/zh concepts guides. Labels, separators (`, ` `、` `، `) and locale stamps are unchanged. The README FAQ lines and the 05-mcp `tool_reference` note are not footers and were left alone. The footer lines of `CHANGELOG.md`, `fa/CHANGELOG.md` and `ko/CHANGELOG.md` also carry the new list; only the footer line changed, not the entries. ## Part C: locale README badges Real state: the newest version that most (more than half) of the locale's ten module READMEs carry or exceed, backed by the sync commit that brought them there. A badge is marked **(partial)** when one or more of the locale's module READMEs has no version footer (never synced since its first translation), or when the locale is a condensed translation. A module synced to an older version than the badge doesn't make it partial on its own; the majority rule above already covers that. Only zh meets the rule (02-memory and 05-mcp have no footer, and #247 calls zh condensed). | Locale | Old badge / "latest" | Evidence | New | |---|---|---|---| | ja | 2.1.119 (badge, "latest", FAQ) | module footers: 3×2.1.322, 5×2.1.316, 1×2.1.310, 1×2.1.302; 8/10 ≥ 2.1.316 (#230); #247 carried only the sections ja has | **2.1.316** (Oct 2026) | | uk | 2.1.112 (FAQ line; no badge) | 3×2.1.322, 4×2.1.316, 1×2.1.310, 2×2.1.302; 7/10 ≥ 2.1.316 (#230) | **2.1.316** (Oct 2026) | | zh | 2.1.112 (badge, "latest", FAQ) | 2.1.316, 2.1.310 ×2, 2.1.302 ×2, 2.1.300 ×2, 2.1.278; 02 and 05 have no footer (untouched since the first translation); 7/10 ≥ 2.1.300 (#193); #247 was "condensed", model lists only | **2.1.300 (partial)** (Oct 2026): the badge, "latest" and FAQ lines say zh is condensed and that 02-memory and 05-mcp haven't been synced since the April 2026 translation | | ko | 2.1.310 | 5×2.1.322, 5×2.1.310; #228 synced ko to 2.1.310, and #247 says 2.1.316 "was not backfilled" | **2.1.310** (unchanged) | | fa | 2.1.310 | 5×2.1.322, 5×2.1.316; #241 "syncs the translation from v2.1.310 to v2.1.316"; #247 carried only the 2.1.322 P1 changes | **2.1.316** (Oct 2026) | | vi | none (README has no badge or version line) | 4×2.1.322, 6×2.1.316 | no change | Months come from the docs changelog: 2.1.300 was released October 14, 2026 and 2.1.316 October 31, 2026. The README *footers* in fa/ja/ko/uk/zh stay at 2.1.322: #247 checked those files themselves, while the badge describes the whole locale. ## Deliberately left - **Stamps not bumped:** `resources.md` (2.1.310), `03-skills/claude-md/SKILL.md` and the three plugin READMEs (2.1.302), for the reasons in the Part A table. - **Example plugins:** the fix is a design choice between wiring up `hooks/hooks.json` / `.mcp.json` and rewording the READMEs, and renaming commands to `/<plugin>:<name>` touches seven languages plus `07-plugins/README.md` (bare `/review-pr`). It needs a follow-up issue. - **Same unverifiable version elsewhere:** `03-skills/README.md` also said `/run-skill-generator` is v2.1.145+. Handled by #262, now merged into this branch from `main`. - **Older `--model` lists:** ja/uk/vi/zh INDEX have pre-5.x lists (e.g. "Sonnet 4.6, Opus 4.7, Haiku 4.5"). That isn't the English sentence, so it belongs to a locale sync. ## Follow-ups - **LEARNING-ROADMAP `/effort` line (review r3 N13):** line 368 can read as if `/effort` applies only to the models that always use extended thinking; per model-config's effort table it also works on Opus 5, Sonnet 5 and Opus 4.8. Not wrong; clarify in the next pass. - **Compatible Models scope (review S3):** Opus 4.6 is Microsoft Foundry's current `opus`, and Sonnet 4.5 is the current `sonnet` on Bedrock, Google Cloud's Agent Platform and Foundry (deprecated, retiring Nov 30, 2026), per model-config's alias table. Both are still in use, so either add them to the FAQ and every footer (Sonnet 4.5 marked deprecated), or define the list's scope in STYLE_GUIDE (e.g. the models the aliases resolve to on the Anthropic API plus older models in active use) and cite the deprecations table. - **Model order (review N8):** the list puts Opus 4.8 after Sonnet 4.6. Grouping by family (Fable, Opus 5.5/5/4.8, Sonnet, Haiku) would read better; the order is shared by STYLE_GUIDE, the FAQ and every footer, so change it everywhere at once. - **Example plugins:** the follow-up issue proposed above. ## Validation - `SKIP=mermaid,vietnamese-mermaid,japanese-mermaid,korean-mermaid,persian-mermaid pre-commit run --files <338 changed files>`: every hook passes, including link-check (246 URLs per language). The Mermaid hooks can't install here (`language: node must have package.json or additional_dependencies`, the same failure #247 reported). `python scripts/check_mermaid.py --strict` was run directly instead: Pele 1.6.0 rendered all 416 blocks. - `python scripts/check_cross_references.py`: all valid (674 files). - Review fix round 1 (18 files): the same `pre-commit run --files` passes every hook (Mermaid hooks skipped as above; no Mermaid block was touched), and the cross-reference check is still valid after merging `main`. - Review fix round 2 (14 files: the extended-thinking wording in all 7 LEARNING-ROADMAP files, the dontAsk line in all 7 INDEX files): `pre-commit run --files` passes every hook (Mermaid hooks skipped; no Mermaid block touched), and the cross-reference check is valid (674 files) after merging `main` again (#257). - Pre-push secret scan: it flagged `06-hooks/README.md:1683` (en, fa, vi), a false positive. The `sk-…{20,}` pattern matches the docs anchor `hooks#pretooluse-ask-decisions-in-auto-mode`, which has been on `main` since11b2ae3(en),c2f92c8(fa) and8de1820(vi), and is not on a line this PR changes. The PR's added lines have no secret-pattern matches. Closes #256
CLI リファレンス
概観
Claude Code CLI(Command Line Interface)は Claude Code を操作する主要な手段である。クエリの実行、セッション管理、モデル設定、開発ワークフローへの組み込みを行う強力なオプション群を備えている。
アーキテクチャ
graph TD
A["User Terminal"] -->|"claude [options] [query]"| B["Claude Code CLI"]
B -->|Interactive| C["REPL Mode"]
B -->|"--print"| D["Print Mode (SDK)"]
B -->|"--resume"| E["Session Resume"]
C -->|Conversation| F["Claude API"]
D -->|Single Query| F
E -->|Load Context| F
F -->|Response| G["Output"]
G -->|text/json/stream-json| H["Terminal/Pipe"]
ランタイムとパッケージング
v2.1.113 以降、Claude Code CLI は npm のオプション依存を介して プラットフォーム別のネイティブバイナリ(macOS、Linux、Windows)を起動する。バイナリはインストール時に OS とアーキテクチャに合わせて選択される — 旧来のバンドル JavaScript ランタイムは macOS / Linux ではもはやデフォルトではない。
推奨インストール方法はネイティブインストーラーである(curl -fsSL https://claude.ai/install.sh | bash、Windows では irm https://claude.ai/install.ps1 | iex)。公式 README では npm によるインストールは非推奨とされている。ネイティブインストーラー、Homebrew(brew install --cask claude-code)、または WinGet(winget install Anthropic.ClaudeCode)を推奨する。参考までに、npm install -g @anthropic-ai/claude-code(Node.js 22 以上)はプラットフォーム別のオプション依存関係を通じて同じネイティブバイナリをインストールする。npm 12 では Claude Code の postinstall ステップがデフォルトでスキップされるため、このインストールは Error: claude native binary not installed. で終わる。ネイティブインストーラーに切り替えるか、Fix an npm 12 install の手順に従うこと。
ダウンロードホスト(v2.1.116+): ネイティブバイナリ成果物は https://downloads.claude.ai/claude-code-releases から配信される。
企業ネットワーク/プロキシ環境: ネットワークが明示的な許可リストを必要とする場合、プロキシのエグレスルールに
downloads.claude.ai(およびhttps://downloads.claude.ai/claude-code-releases)を追加すること。以前storage.googleapis.comまたは npm レジストリのみを許可していた環境は更新が必要で、未対応のままだとclaude updateや初回インストールが失敗する。
旧来の JavaScript バンドルは Windows 用および固定利用の環境向けに引き続き提供される。これらのインストールでは Glob と Grep が引き続きファーストクラスツールとして同梱される(ツール 節の Glob/Grep 注記を参照)。
CLI コマンド
| コマンド | 説明 | 例 |
|---|---|---|
claude |
対話型 REPL を起動 | claude |
claude "query" |
初期プロンプト付きで REPL を起動 | claude "explain this project" |
claude -p "query" |
プリントモード - クエリ実行後に終了 | claude -p "explain this function" |
cat file | claude -p "query" |
パイプ入力を処理 | cat logs.txt | claude -p "explain" |
claude -c |
直近の会話を継続 | claude -c |
claude -c -p "query" |
プリントモードで継続 | claude -c -p "check for type errors" |
claude -r "<session>" "query" |
ID または名前でセッション再開 | claude -r "auth-refactor" "finish this PR" |
claude update |
最新版に更新 | claude update |
/doctor(スラッシュコマンド) |
インストール、設定、プラグインの健全性を診断する。v2.1.116 以降は Claude が応答中でも開ける ようになり、ステータスアイコンをインライン表示し、f キーで検出された問題を自動修正する |
REPL 内で /doctor を実行 |
claude mcp |
MCP サーバーを設定 | MCP のドキュメント を参照 |
claude mcp serve |
Claude Code を MCP サーバーとして起動 | claude mcp serve |
claude agents |
設定済みのサブエージェントを一覧表示 | claude agents |
claude auto-mode defaults |
自動モードのデフォルトルールを JSON で出力 | claude auto-mode defaults |
claude remote-control |
リモートコントロールサーバーを起動(サーバーモード、ローカルの対話セッションなし。複数セッションを扱う、--capacity デフォルト 32) |
claude remote-control --name "My Project" |
claude --remote-control [name] |
リモートコントロールを有効にした対話セッションを起動(エイリアス --rc) |
claude --rc |
claude plugin |
プラグインを管理(インストール・有効化・無効化) | claude plugin install my-plugin |
claude plugin tag [path] |
[path] のプラグインに対し {name}--v{version} のリリース git タグを作成。plugin.json と(存在すれば)マーケットプレイスのエントリが一致しているか検証する(v2.1.118+) |
claude plugin tag ./my-plugin |
claude install [version] |
指定したネイティブバイナリのバージョンをインストール。stable、latest、明示的なバージョン文字列を受け付ける |
claude install 2.1.119 |
claude auth login |
ログイン(--email、--sso をサポート) |
claude auth login --email user@example.com |
claude auth logout |
現在のアカウントからログアウト | claude auth logout |
claude auth status |
認証状態を確認(ログイン中なら exit 0、未ログインなら 1) | claude auth status |
主要フラグ
| フラグ | 説明 | 例 |
|---|---|---|
-p, --print |
対話モードを使わず応答を出力 | claude -p "query" |
-c, --continue |
直近の会話を読み込む | claude --continue |
-r, --resume |
ID または名前で特定セッションを再開 | claude --resume auth-refactor |
-v, --version |
バージョン番号を出力 | claude -v |
-w, --worktree |
隔離された git ワークツリーで起動 | claude -w |
-n, --name |
セッションの表示名 | claude -n "auth-refactor" |
--from-pr <url-or-number> |
プル/マージリクエストに紐づくセッションを再開する。v2.1.119 以降は GitHub(クラウド + Enterprise)、GitLab MR、Bitbucket PR の URL を受け付ける(以前は GitHub.com のみ) | claude --from-pr 42 または claude --from-pr https://gitlab.example.com/org/repo/-/merge_requests/17 |
--cloud [description|session_id|url] |
指定した説明で claude.ai 上にクラウドセッションを作成、またはセッション ID か claude.ai/code の URL で既存セッションに接続 | claude --cloud "implement API" |
--remote "task" |
--cloud の非推奨エイリアス(既存セッションに接続する形式も含む)。--cloud を使うこと |
claude --remote "implement API" |
--remote-control, --rc |
リモートコントロール付きの対話セッション | claude --rc |
--teleport |
web セッションをローカルで再開 | claude --teleport |
--teammate-mode |
エージェントチームの表示モード | claude --teammate-mode tmux |
--bare |
最小モード(フック、スキル、プラグイン、MCP、自動メモリ、CLAUDE.md をスキップ) | claude --bare |
--enable-auto-mode |
自動権限モードを解禁(Opus 4.7 の Max 加入者には不要) | claude --enable-auto-mode |
--channels |
MCP チャンネルプラグインを購読。各エントリは plugin:<name>@<marketplace> の形式でタグ付けする必要があり、名前のみの指定は拒否される |
claude --channels plugin:discord@my-marketplace |
--chrome / --no-chrome |
Chrome ブラウザ統合を有効化/無効化 | claude --chrome |
--effort |
思考労力レベルを設定 | claude --effort high |
--init / --init-only |
--init はセッション前に初期化(Setup)フックを実行する(print モードのみ)。--init-only は Setup と SessionStart フックを実行して終了する |
claude -p --init "query" |
--maintenance |
セッション前にメンテナンス(Setup)フックを実行する(print モードのみ) | claude -p --maintenance "query" |
--disable-slash-commands |
すべてのスキルとスラッシュコマンドを無効化 | claude --disable-slash-commands |
--no-session-persistence |
セッション保存を無効化(プリントモード) | claude -p --no-session-persistence "query" |
--exclude-dynamic-system-prompt-sections |
プロンプトキャッシュヒット率向上のため、システムプロンプトから動的セクションを除外 | claude -p --exclude-dynamic-system-prompt-sections "query" |
対話モードとプリントモード
graph LR
A["claude"] -->|Default| B["Interactive REPL"]
A -->|"-p flag"| C["Print Mode"]
B -->|Features| D["Multi-turn conversation<br>Tab completion<br>History<br>Slash commands"]
C -->|Features| E["Single query<br>Scriptable<br>Pipeable<br>JSON output"]
対話モード(デフォルト):
# 対話セッションを開始
claude
# 初期プロンプト付きで開始
claude "explain the authentication flow"
プリントモード(非対話):
# 単一クエリ実行後に終了
claude -p "what does this function do?"
# ファイル内容を処理
cat error.log | claude -p "explain this error"
# 他のツールとチェーン
claude -p "list todos" | grep "URGENT"
モデルと設定
| フラグ | 説明 | 例 |
|---|---|---|
--model |
モデルを設定(sonnet、opus、haiku、または完全名) | claude --model opus |
--fallback-model |
過負荷時の自動フォールバックモデル | claude -p --fallback-model sonnet "query" |
--agent |
セッションに使うエージェントを指定 | claude --agent my-custom-agent |
--agents |
JSON でカスタムサブエージェントを定義 | Agents の設定 を参照 |
--effort |
労力レベルを設定(low、medium、high、xhigh、max) | claude --effort xhigh |
モデル選択の例
# 複雑なタスクには Opus 5.5
claude --model opus "design a caching strategy"
# 速いタスクには Haiku(Anthropic API では v2.1.293 以降 Haiku 5.5、Bedrock・Vertex・Foundry では Haiku 4.5)
claude --model haiku -p "format this JSON"
# モデル名のフルネーム指定
claude --model claude-sonnet-4-6 "review this code"
# 信頼性のためフォールバック付き
claude -p --model opus --fallback-model sonnet "analyze architecture"
# opusplan(Opus が計画、Sonnet が実装)
claude --model opusplan "design and implement the caching layer"
システムプロンプトのカスタマイズ
| フラグ | 説明 | 例 |
|---|---|---|
--system-prompt |
デフォルトプロンプト全体を置き換える | claude --system-prompt "You are a Python expert" |
--system-prompt-file |
ファイルからプロンプトを読み込み、デフォルトのプロンプトを置き換える | claude -p --system-prompt-file ./prompt.txt "query" |
--append-system-prompt |
デフォルトプロンプトに追記 | claude --append-system-prompt "Always use TypeScript" |
システムプロンプトの例
# 完全カスタムなペルソナ
claude --system-prompt "You are a senior security engineer. Focus on vulnerabilities."
# 特定の指示を追加
claude --append-system-prompt "Always include unit tests with code examples"
# 複雑なプロンプトをファイルから読み込み
claude -p --system-prompt-file ./prompts/code-reviewer.txt "review main.py"
システムプロンプトフラグの比較
| フラグ | 挙動 | 対話 | プリント |
|---|---|---|---|
--system-prompt |
デフォルトのシステムプロンプト全体を置き換える | ✅ | ✅ |
--system-prompt-file |
ファイルのプロンプトに置き換える | ✅ | ✅ |
--append-system-prompt |
デフォルトに追記する | ✅ | ✅ |
すべてのシステムプロンプトフラグは対話モードとプリントモードの両方で動作する(ファイル形式は v2.1.69 以降)。--system-prompt と --system-prompt-file はデフォルトのプロンプトを置き換え、append 系のフラグはそれに追加する。
ツールと権限の管理
| フラグ | 説明 | 例 |
|---|---|---|
--tools |
利用可能な組み込みツールを制限 | claude -p --tools "Bash,Edit,Read" "query" |
--allowedTools |
確認なしで実行できるツール | "Bash(git log:*)" "Read" |
--disallowedTools |
コンテキストから除外するツール | "Bash(rm:*)" "Edit" |
--dangerously-skip-permissions |
全ての権限プロンプトをスキップ | claude --dangerously-skip-permissions |
--permission-mode |
指定した権限モードで開始 | claude --permission-mode auto |
--permission-prompt-tool |
権限処理用の MCP ツール | claude -p --mcp-config ./mcp.json --permission-prompt-tool mcp__permissions__approve "query" |
--enable-auto-mode |
自動権限モードを解禁 | claude --enable-auto-mode |
Glob / Grep 注記(v2.1.113+): ネイティブな macOS/Linux ビルドでは、
GlobとGrepは独立したファーストクラスツールではなく、Bash ツール経由で呼び出される組み込みのbfsおよびugrepバイナリとして提供される。Windows 版および npm バンドル(JS)版では引き続きスタンドアロンツールとして公開される。サブエージェントのallowedTools/disallowedToolsリストでは、バックエンド側の置換は透過的なため、どのプラットフォームでも設定では引き続きGlob/Grepを参照すればよい。
PowerShell の自動承認(v2.1.119): PowerShell ツールのコマンドは、Bash コマンドとまったく同じ方式で権限モードによる自動承認が可能になった。
Bash(...)ルールで使うのと同じマッチャ構文で PowerShell の権限を絞り込める — 例:PowerShell(Get-ChildItem:*)。
権限の例
# コードレビュー用の読み取り専用モード
claude --permission-mode plan "review this codebase"
# 安全なツールのみに制限
claude --tools "Read,Grep,Glob" -p "find all TODO comments"
# 特定の git コマンドを確認なしで許可
claude --allowedTools "Bash(git status:*)" "Bash(git log:*)"
# 危険な操作をブロック
claude --disallowedTools "Bash(rm -rf:*)" "Bash(git push --force:*)"
出力とフォーマット
| フラグ | 説明 | オプション | 例 |
|---|---|---|---|
--output-format |
出力フォーマット指定(プリントモード) | text、json、stream-json |
claude -p --output-format json "query" |
--input-format |
入力フォーマット指定(プリントモード) | text、stream-json |
claude -p --input-format stream-json |
--verbose |
詳細ログを有効化 | claude --verbose |
|
--include-partial-messages |
ストリーミングイベントを含める | stream-json が必要 |
claude -p --output-format stream-json --include-partial-messages "query" |
--json-schema |
スキーマに沿って検証された JSON を取得 | claude -p --json-schema '{"type":"object"}' "query" |
|
--max-budget-usd |
プリントモードでの最大支出額。v2.1.217以降、上限に達するとバックグラウンドで実行中のサブエージェントも停止し、新規のサブエージェント起動も拒否される(以前はバックグラウンドエージェントは上限を超えても実行され続けていた) | claude -p --max-budget-usd 5.00 "query" |
出力フォーマットの例
# プレーンテキスト(デフォルト)
claude -p "explain this code"
# プログラムから扱うための JSON
claude -p --output-format json "list all functions in main.py"
# リアルタイム処理向けのストリーミング JSON
claude -p --output-format stream-json "generate a long report"
# スキーマ検証付きの構造化出力
claude -p --json-schema '{"type":"object","properties":{"bugs":{"type":"array"}}}' \
"find bugs in this code and return as JSON"
ワークスペースとディレクトリ
| フラグ | 説明 | 例 |
|---|---|---|
--add-dir |
追加の作業ディレクトリを指定 | claude --add-dir ../apps ../lib |
--setting-sources |
カンマ区切りの設定ソース | claude --setting-sources user,project |
/configの永続化(v2.1.119):/configコマンドで対話的に行った変更は~/.claude/settings.jsonに書き込まれ、通常の優先順位チェーン(policy → local → project → user)に組み込まれるようになった。v2.1.119 以前は一部の/config変更がセッション限定だった。完全な優先順位については メモリと設定 を参照。 |--settings| ファイルまたは JSON から設定を読み込む |claude --settings ./settings.json| |--plugin-dir| ディレクトリからプラグインを読み込む(複数指定可) |claude --plugin-dir ./my-plugin|
複数ディレクトリの例
# 複数のプロジェクトディレクトリを横断作業
claude --add-dir ../frontend ../backend ../shared "find all API endpoints"
# カスタム設定の読み込み
claude --settings '{"model":"opus","verbose":true}' "complex task"
MCP の設定
| フラグ | 説明 | 例 |
|---|---|---|
--mcp-config |
JSON から MCP サーバーを読み込む | claude --mcp-config ./mcp.json |
--strict-mcp-config |
指定した MCP 設定のみを使う | claude --strict-mcp-config --mcp-config ./mcp.json |
--channels |
MCP チャンネルプラグインを購読。各エントリは plugin:<name>@<marketplace> の形式でタグ付けする必要があり、名前のみの指定は拒否される |
claude --channels plugin:discord@my-marketplace |
MCP の例
# GitHub MCP サーバーの読み込み
claude --mcp-config ./github-mcp.json "list open PRs"
# 厳密モード - 指定したサーバーのみ
claude --strict-mcp-config --mcp-config ./production-mcp.json "deploy to staging"
セッション管理
| フラグ | 説明 | 例 |
|---|---|---|
--session-id |
特定セッション ID(UUID)を使用 | claude --session-id "550e8400-..." |
--fork-session |
再開時に新しいセッションを作成 | claude --resume abc123 --fork-session |
セッションの例
# 直前の会話を継続
claude -c
# 名前付きセッションを再開
claude -r "feature-auth" "continue implementing login"
# 試行錯誤のためセッションをフォーク
claude --resume feature-auth --fork-session "try alternative approach"
# 特定のセッション ID を使用
claude --session-id "550e8400-e29b-41d4-a716-446655440000" "continue"
セッションのフォーク
既存セッションから分岐したブランチを作成し試行錯誤する:
# 別アプローチを試すためにセッションをフォーク
claude --resume abc123 --fork-session "try alternative implementation"
# カスタムメッセージ付きでフォーク
claude -r "feature-auth" --fork-session "test with different architecture"
ユースケース:
- 元のセッションを失わずに別実装を試す
- 並行して複数のアプローチを試行錯誤する
- 成功した作業からバリエーションのブランチを作る
- メインセッションに影響を与えずに破壊的な変更を試す
元のセッションは変更されず、フォークは新しい独立セッションになる。
高度な機能
| フラグ | 説明 | 例 |
|---|---|---|
--chrome |
Chrome ブラウザ統合を有効化 | claude --chrome |
--no-chrome |
Chrome ブラウザ統合を無効化 | claude --no-chrome |
--ide |
利用可能なら IDE と自動接続 | claude --ide |
--max-turns |
エージェントターンを制限(非対話) | claude -p --max-turns 3 "query" |
--debug |
フィルタ付きデバッグモードを有効化(フィルタは = 形式でのみ適用) |
claude --debug=api,mcp |
--enable-lsp-logging |
詳細な LSP ログを有効化 | claude --enable-lsp-logging |
--betas |
API リクエストのベータヘッダ | claude --betas interleaved-thinking |
--plugin-dir |
ディレクトリからプラグインを読み込む(複数指定可) | claude --plugin-dir ./my-plugin |
--enable-auto-mode |
自動権限モードを解禁 | claude --enable-auto-mode |
--effort |
思考労力レベルを設定 | claude --effort high |
--bare |
最小モード(フック、スキル、プラグイン、MCP、自動メモリ、CLAUDE.md をスキップ) | claude --bare |
--channels |
MCP チャンネルプラグインを購読(plugin:<name>@<marketplace> 形式でタグ付け) |
claude --channels plugin:discord@my-marketplace |
--tmux |
ワークツリー用に tmux セッションを作成(--worktree が必要) |
claude --worktree feature-x --tmux |
--fork-session |
再開時に新しいセッション ID を作成 | claude --resume abc --fork-session |
--max-budget-usd |
最大支出額(プリントモード)。上限に達するとバックグラウンドのサブエージェントも停止する (v2.1.217) | claude -p --max-budget-usd 5.00 "query" |
--json-schema |
検証付き JSON 出力 | claude -p --json-schema '{"type":"object"}' "q" |
プラットフォームとテーマの注記(v2.1.112)
- Windows 版の PowerShell ツール: Windows 向けに専用の PowerShell ツールがロールアウトされ、環境変数で制御できる。
- 「Auto(ターミナルに合わせる)」テーマ: 新しい "Auto (match terminal)" テーマで Claude Code のライト/ダーク表示をターミナルと同期できる。
- 静かな権限プロンプト: 読み取り専用の
Bash呼び出しとGlobパターンは権限プロンプトを発生させなくなった。
高度な例
# 自律アクション数を制限
claude -p --max-turns 5 "refactor this module"
# API 呼び出しをデバッグ
claude --debug=api "test query"
# IDE 統合を有効化
claude --ide "help me with this file"
Agents の設定
--agents フラグはセッションに対するカスタムサブエージェントを定義する JSON オブジェクトを受け取る。
Agents の JSON フォーマット
{
"agent-name": {
"description": "Required: when to invoke this agent",
"prompt": "Required: system prompt for the agent",
"tools": ["Optional", "array", "of", "tools"],
"model": "optional: sonnet|opus|haiku"
}
}
必須フィールド:
description- エージェントを使う場面の自然言語による説明prompt- エージェントの役割と挙動を定義するシステムプロンプト
任意フィールド:
tools- 利用可能なツールの配列(省略時は全ツールを継承)- 形式:
["Read", "Grep", "Glob", "Bash"]
- 形式:
model- 使用するモデル:sonnet、opus、haiku
完全な Agents の例
{
"code-reviewer": {
"description": "Expert code reviewer. Use proactively after code changes.",
"prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",
"tools": ["Read", "Grep", "Glob", "Bash"],
"model": "sonnet"
},
"debugger": {
"description": "Debugging specialist for errors and test failures.",
"prompt": "You are an expert debugger. Analyze errors, identify root causes, and provide fixes.",
"tools": ["Read", "Edit", "Bash", "Grep"],
"model": "opus"
},
"documenter": {
"description": "Documentation specialist for generating guides.",
"prompt": "You are a technical writer. Create clear, comprehensive documentation.",
"tools": ["Read", "Write"],
"model": "haiku"
}
}
Agents コマンドの例
# カスタムエージェントをインラインで定義
claude --agents '{
"security-auditor": {
"description": "Security specialist for vulnerability analysis",
"prompt": "You are a security expert. Find vulnerabilities and suggest fixes.",
"tools": ["Read", "Grep", "Glob"],
"model": "opus"
}
}' "audit this codebase for security issues"
# ファイルからエージェントを読み込み
claude --agents "$(cat ~/.claude/agents.json)" "review the auth module"
# 他のフラグと組み合わせ
claude -p --agents "$(cat agents.json)" --model sonnet "analyze performance"
エージェントの優先順位
複数のエージェント定義が存在する場合、以下の優先順位で読み込まれる:
- CLI 定義(
--agentsフラグ) - セッション固有 - プロジェクトレベル(
.claude/agents/) - 現在のプロジェクト - ユーザーレベル(
~/.claude/agents/) - 全プロジェクト
CLI 定義のエージェントは、当該セッションにおいてプロジェクトおよびユーザーのエージェントを上書きする。プロジェクトレベルのエージェントは、名前が衝突した場合にユーザーレベルのエージェントを上書きする。プラグインレベルのエージェントを含む完全な優先順位表は Lesson 04 — サブエージェント を参照。
価値の高いユースケース
1. CI/CD への組み込み
Claude Code を CI/CD パイプラインに組み込み、コードレビュー、テスト、ドキュメント生成を自動化する。
GitHub Actions の例:
name: AI Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Run Code Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
claude -p --output-format json \
--max-turns 5 \
"Review the changes in this PR for:
- Security vulnerabilities
- Performance issues
- Code quality
Output as JSON with 'issues' array" > review.json
- name: Post Review Comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = JSON.parse(fs.readFileSync('review.json', 'utf8'));
// Process and post review comments
Jenkins パイプライン:
pipeline {
agent any
stages {
stage('AI Review') {
steps {
sh '''
claude -p --output-format json \
--max-turns 3 \
"Analyze test coverage and suggest missing tests" \
> coverage-analysis.json
'''
}
}
}
}
2. スクリプトのパイプ処理
ファイル、ログ、データを Claude に流し込んで分析する。
ログ解析:
# エラーログの分析
tail -1000 /var/log/app/error.log | claude -p "summarize these errors and suggest fixes"
# アクセスログ内のパターン抽出
cat access.log | claude -p "identify suspicious access patterns"
# git 履歴の要約
git log --oneline -50 | claude -p "summarize recent development activity"
コード処理:
# 特定ファイルのレビュー
cat src/auth.ts | claude -p "review this authentication code for security issues"
# ドキュメントの生成
cat src/api/*.ts | claude -p "generate API documentation in markdown"
# TODO の抽出と優先順位付け
grep -r "TODO" src/ | claude -p "prioritize these TODOs by importance"
3. マルチセッションのワークフロー
複数の会話スレッドで複雑なプロジェクトを管理する。
# フィーチャーブランチ用セッションを開始
claude -r "feature-auth" "let's implement user authentication"
# 後で同じセッションを継続
claude -r "feature-auth" "add password reset functionality"
# 別アプローチを試すためフォーク
claude --resume feature-auth --fork-session "try OAuth instead"
# 別の機能のセッションへ切り替え
claude -r "feature-payments" "continue with Stripe integration"
4. カスタムエージェントの設定
チームのワークフロー向けに専門エージェントを定義する。
# エージェント設定をファイルに保存
cat > ~/.claude/agents.json << 'EOF'
{
"reviewer": {
"description": "Code reviewer for PR reviews",
"prompt": "Review code for quality, security, and maintainability.",
"model": "opus"
},
"documenter": {
"description": "Documentation specialist",
"prompt": "Generate clear, comprehensive documentation.",
"model": "sonnet"
},
"refactorer": {
"description": "Code refactoring expert",
"prompt": "Suggest and implement clean code refactoring.",
"tools": ["Read", "Edit", "Glob"]
}
}
EOF
# セッションでエージェントを使用
claude --agents "$(cat ~/.claude/agents.json)" "review the auth module"
5. バッチ処理
一貫した設定で複数クエリを処理する。
# 複数ファイルの処理
for file in src/*.ts; do
echo "Processing $file..."
claude -p --model haiku "summarize this file: $(cat $file)" >> summaries.md
done
# バッチコードレビュー
find src -name "*.py" -exec sh -c '
echo "## $1" >> review.md
cat "$1" | claude -p "brief code review" >> review.md
' _ {} \;
# 全モジュールのテスト生成
for module in $(ls src/modules/); do
claude -p "generate unit tests for src/modules/$module" > "tests/$module.test.ts"
done
6. セキュリティを意識した開発
権限制御で安全に運用する。
# 読み取り専用のセキュリティ監査
claude --permission-mode plan \
--tools "Read,Grep,Glob" \
"audit this codebase for security vulnerabilities"
# 危険なコマンドをブロック
claude --disallowedTools "Bash(rm:*)" "Bash(curl:*)" "Bash(wget:*)" \
"help me clean up this project"
# 制限付き自動化
claude -p --max-turns 2 \
--allowedTools "Read" "Glob" \
"find all hardcoded credentials"
7. JSON API としての利用
jq のパースと組み合わせて、Claude をプログラム可能な API として活用する。
# 構造化された分析を取得
claude -p --output-format json \
--json-schema '{"type":"object","properties":{"functions":{"type":"array"},"complexity":{"type":"string"}}}' \
"analyze main.py and return function list with complexity rating"
# jq で処理に組み込む(スキーマ出力は .structured_output に入る)
claude -p --output-format json \
--json-schema '{"type":"object","properties":{"endpoints":{"type":"array"}}}' \
"list all API endpoints" | jq '.structured_output.endpoints[]'
# スクリプト内で利用
RESULT=$(claude -p --output-format json \
--json-schema '{"type":"object","properties":{"secure":{"type":"boolean"},"issues":{"type":"array"}},"required":["secure","issues"]}' \
"is this code secure?" < code.py)
if echo "$RESULT" | jq -e '.structured_output.secure == false' > /dev/null; then
echo "Security issues found!"
echo "$RESULT" | jq '.structured_output.issues[]'
fi
jq でのパース例
jq で Claude の JSON 出力をパース・処理する。応答テキストは .result に入り、--json-schema を指定した場合は検証済みオブジェクトが .structured_output に入る(以下の $SCHEMA は各フィルタが読むフィールドを定義したスキーマを表す):
# 応答テキストの抽出
claude -p --output-format json "analyze this code" | jq -r '.result'
# 配列要素のフィルタ
claude -p --output-format json --json-schema "$SCHEMA" "list issues" | jq -r '.structured_output.issues[] | select(.severity=="high")'
# 複数フィールドの抽出
claude -p --output-format json --json-schema "$SCHEMA" "describe the project" | jq -r '.structured_output | {name, version, description}'
# CSV への変換
claude -p --output-format json --json-schema "$SCHEMA" "list functions" | jq -r '.structured_output.functions[] | [.name, .lineCount] | @csv'
# 条件付き処理
claude -p --output-format json --json-schema "$SCHEMA" "check security" | jq 'if (.structured_output.vulnerabilities | length) > 0 then "UNSAFE" else "SAFE" end'
# ネストされた値の取得
claude -p --output-format json --json-schema "$SCHEMA" "analyze performance" | jq '.structured_output.metrics.cpu.usage'
# 配列全体の処理
claude -p --output-format json --json-schema "$SCHEMA" "find todos" | jq '.structured_output.todos | length'
# 出力の変換
claude -p --output-format json --json-schema "$SCHEMA" "list improvements" | jq '.structured_output.improvements | map({title: .title, priority: .priority})'
モデル
Claude Code は能力の異なる複数のモデルをサポートする:
| モデル | ID | コンテキストウィンドウ | 備考 |
|---|---|---|---|
| Opus 4.7 | claude-opus-4-7 |
1M トークン(1M コンテキスト対応は v2.1.117 で実装) | 最も能力が高く、適応的な労力レベルを備える。Claude Code では Opus 4.7 ローンチ(2026-04-16)以降 xhigh がデフォルトの労力レベル |
| Sonnet 4.6 | claude-sonnet-4-6 |
1M トークン | 速度と能力のバランスが良い。Pro/Max 加入者のデフォルト労力は v2.1.117 で medium から high に引き上げられた |
| Haiku 4.5 | claude-haiku-4-5 |
200K トークン | 最速で、軽いタスクに最適 |
モデルの選択
# 短縮名で指定
claude --model opus "complex architectural review"
claude --model sonnet "implement this feature"
claude --model haiku -p "format this JSON"
# opusplan エイリアス(Opus が計画、Sonnet が実装)
claude --model opusplan "design and implement the API"
# セッション中にファストモードを切り替え
/fast
労力レベル(Opus 4.7)
Opus 4.7 は適応的推論をサポートし、軽い順から low(○)、medium(◐)、high(●)、xhigh(Claude Code では Opus 4.7 ローンチ以降のデフォルト、2026-04-16)、max の労力レベルを持つ。Opus 4.6 / Sonnet 4.6 では、Pro/Max 加入者のデフォルト労力が v2.1.117 で medium から high に引き上げられた。
# CLI フラグで労力レベルを設定
claude --effort xhigh "complex review"
# スラッシュコマンドで労力レベルを設定
/effort xhigh
# 環境変数で労力レベルを設定
export CLAUDE_CODE_EFFORT_LEVEL=xhigh # low, medium, high, xhigh (default on Opus 4.7), or max
プロンプト内のキーワード「ultrathink」は深い推論を有効化する。v2.1.311 以降、対話型ターミナルで入力すると、Anthropic の API 経由の Opus 5.5、Sonnet 5.5、Haiku 5.5、Fable 5.2(v2.1.321 以降)、Fable 5.1 ではそのターンを xhigh で実行する(可能な場合は虹色で表示される。VS Code は v2.1.316 以降)。CLAUDE_CODE_DISABLE_ULTRATHINK=1(v2.1.316)でこのキーワードを無効化できる。
主要な環境変数
| 変数 | 説明 |
|---|---|
ANTHROPIC_API_KEY |
認証用の API キー |
ANTHROPIC_MODEL |
デフォルトモデルを上書き |
ANTHROPIC_CUSTOM_MODEL_OPTION |
API 用のカスタムモデルオプション |
ANTHROPIC_DEFAULT_OPUS_MODEL |
デフォルトの Opus モデル ID を上書き |
ANTHROPIC_DEFAULT_SONNET_MODEL |
デフォルトの Sonnet モデル ID を上書き |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
デフォルトの Haiku モデル ID を上書き |
MAX_THINKING_TOKENS |
拡張思考のトークン予算を設定 |
CLAUDE_CODE_EFFORT_LEVEL |
労力レベルを設定(low/medium/high/xhigh/max) — デフォルトは Fable 5.2、Opus 5.5、Sonnet 5.5、Haiku 5.5 では medium、Fable 5.1、Fable 5、Opus 5、Sonnet 5、Opus 4.8 では high(Opus 4.7 では xhigh)。xhigh には Fable モデル、Opus 5.5、Sonnet 5.5、Haiku 5.5、Opus 5、Sonnet 5、Opus 4.8/4.7 が必要。max は Fable モデル、Opus 5.5、Sonnet 5.5、Haiku 5.5、Opus 5、Sonnet 5、Opus 4.8/4.7/4.6、Sonnet 4.6 で使える |
CLAUDE_CODE_SIMPLE |
最小モード(--bare フラグで設定される) |
CLAUDE_CODE_DISABLE_AUTO_MEMORY |
1 を設定すると自動メモリを無効化する(自動メモリファイルを作成も読み込みもしない) |
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS |
バックグラウンドタスク実行を無効化 |
CLAUDE_CODE_DISABLE_CRON |
セッションスコープのスケジュールタスク(/loop、cron ツール)を無効化。クラウドスケジュールタスクには影響しない |
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS |
git 関連の指示を無効化 |
CLAUDE_CODE_DISABLE_TERMINAL_TITLE |
ターミナルタイトル更新を無効化 |
CLAUDE_CODE_DISABLE_1M_CONTEXT |
1M トークンコンテキストウィンドウを無効化 |
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK |
非ストリーミングフォールバックを無効化 |
CLAUDE_CODE_ENABLE_TASKS |
Task ツールがデフォルト。0 を設定すると従来の TodoWrite ツールに戻る |
CLAUDE_CODE_TASK_LIST_ID |
セッション間で共有する名前付きタスクディレクトリ |
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION |
プロンプトサジェストを切り替え(true/false) |
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS |
実験的なエージェントチームを有効化 |
CLAUDE_CODE_NEW_INIT |
新しい初期化フローを使用 |
CLAUDE_CODE_SUBAGENT_MODEL |
サブエージェント実行用モデル |
CLAUDE_CODE_PLUGIN_SEED_DIR |
プラグインシードファイル用ディレクトリ |
CLAUDE_CODE_SUBPROCESS_ENV_SCRUB |
サブプロセスから取り除く環境変数 |
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE |
自動コンパクションのパーセンテージを上書き |
CLAUDE_STREAM_IDLE_TIMEOUT_MS |
ストリームのアイドルタイムアウト(ミリ秒) |
SLASH_COMMAND_TOOL_CHAR_BUDGET |
スラッシュコマンドツールの文字数予算 |
ENABLE_TOOL_SEARCH |
ツール検索機能を有効化 |
MAX_MCP_OUTPUT_TOKENS |
MCP ツール出力の最大トークン数 |
CLAUDE_CODE_PERFORCE_MODE |
1 を設定すると Perforce モードを有効化 — ファイルをデフォルトで読み取り専用として扱う(Perforce/P4 バージョン管理ワークフロー向け)(v2.1.98 追加) |
DISABLE_UPDATES |
手動の claude update を含むすべての更新経路をブロックする。バックグラウンドの自動更新のみブロックする DISABLE_AUTOUPDATER より厳密(v2.1.118+) |
CLAUDE_CODE_HIDE_CWD |
1 に設定すると、起動時ロゴでカレント作業ディレクトリを隠す(プライバシー/画面共有用途)(v2.1.119+) |
CLAUDE_CODE_FORK_SUBAGENT |
0 を設定するとフォークサブエージェントを無効化する。v2.1.302 以降、ターミナル、claude -p、Agent SDK、デスクトップアプリ、VS Code でデフォルト有効。v2.1.302 より前は、claude -p と Agent SDK で有効にするには 1 を設定する。 |
OTEL_LOG_TOOL_DETAILS |
1 を設定すると OpenTelemetry イベント中のカスタムおよび MCP コマンド名のリダクションを解除する(v2.1.117+)。デフォルトはリダクション有効。 |
Agent Platform(Vertex AI)とゲートウェイでの
ENABLE_TOOL_SEARCH: v2.1.221 より前は、ENABLE_TOOL_SEARCH=trueを設定しない限り Google Cloud の Agent Platform ではツール検索がオフだった。現在は同プラットフォームで Claude Opus 4.5、Sonnet 4.5、Haiku 4.5 以降のモデルに対して有効である(それ以前のモデルはすべての MCP ツールを事前に読み込み、trueを設定しても変わらない)。ツール検索はデフォルトで有効で、v2.1.304 以降はカスタムのANTHROPIC_BASE_URLゲートウェイ経由でも有効になる(v2.1.305 以降、ツール検索を 400 または 422 で拒否するゲートウェイに対してはツール検索なしで再試行される)。すべてのツールを事前に読み込むにはENABLE_TOOL_SEARCH=falseを設定する。
クイックリファレンス
最もよく使うコマンド
# 対話セッション
claude
# サッと質問
claude -p "how do I..."
# 会話を継続
claude -c
# ファイルを処理
cat file.py | claude -p "review this"
# スクリプト用の JSON 出力
claude -p --output-format json "query"
フラグの組み合わせ
| ユースケース | コマンド |
|---|---|
| 簡易コードレビュー | cat file | claude -p "review" |
| 構造化出力 | claude -p --output-format json "query" |
| 安全な探索 | claude --permission-mode plan |
| 安全装置付き自律実行 | claude --enable-auto-mode --permission-mode auto |
| CI/CD 連携 | claude -p --max-turns 3 --output-format json |
| 作業の再開 | claude -r "session-name" |
| カスタムモデル | claude --model opus "complex task" |
| 最小モード | claude --bare "quick query" |
| 予算上限付き実行 | claude -p --max-budget-usd 2.00 "analyze code" |
トラブルシューティング
コマンドが見つからない
問題: claude: command not found
対処法:
- Claude Code をインストール:
curl -fsSL https://claude.ai/install.sh | bash(ネイティブ、推奨)またはnpm install -g @anthropic-ai/claude-code - PATH に
~/.local/bin(ネイティブインストール)または npm のグローバル bin ディレクトリが含まれていることを確認 claude doctorを実行
API キーの問題
問題: 認証に失敗する
対処法:
- API キーを設定:
export ANTHROPIC_API_KEY=your-key - キーが有効でクレジットが十分か確認
- 要求モデルに対するキー権限を確認
セッションが見つからない
問題: セッションを再開できない
対処法:
- 利用可能なセッションを一覧表示し、正しい名前/ID を確認
- セッションは一定期間使用しないと失効する場合がある
-cで直近のセッションを継続する
出力フォーマットの問題
問題: JSON 出力が壊れている
対処法:
--json-schemaで構造を強制する- プロンプト内に明示的な JSON 指示を含める
- プロンプトで JSON を要求するだけでなく
--output-format jsonを使用する
権限拒否
問題: ツール実行がブロックされる
対処法:
--permission-mode設定を確認--allowedToolsと--disallowedToolsフラグを見直す- 自動化用途では(注意のうえ)
--dangerously-skip-permissionsを使用
追加リソース
- 公式 CLI リファレンス - 完全なコマンドリファレンス
- ヘッドレスモードのドキュメント - 自動実行
- スラッシュコマンド - Claude 内のカスタムショートカット
- メモリガイド - CLAUDE.md による永続コンテキスト
- MCP プロトコル - 外部ツール連携
- 高度な機能 - プランニングモード、拡張思考
- サブエージェントガイド - 委譲によるタスク実行
Claude How To ガイドシリーズの一部
最終更新: 2026 年 11 月 12 日 Claude Code バージョン: 2.1.322 出典:
- https://code.claude.com/docs/en/agent-sdk/agent-loop#turns-and-messages
- https://code.claude.com/docs/en/model-config#use-ultrathink-for-one-off-deep-reasoning
- https://code.claude.com/docs/en/changelog#2-1-316
- https://code.claude.com/docs/en/troubleshoot-install#fix-an-npm-12-install
- https://code.claude.com/docs/en/cli-reference
- https://code.claude.com/docs/en/model-config
- https://code.claude.com/docs/en/settings
- https://code.claude.com/docs/en/changelog
- https://www.anthropic.com/news/claude-opus-4-7
- https://github.com/anthropics/claude-code/releases/tag/v2.1.113
- https://github.com/anthropics/claude-code/releases/tag/v2.1.116
- https://github.com/anthropics/claude-code/releases/tag/v2.1.117
- https://github.com/anthropics/claude-code/releases/tag/v2.1.118
- https://github.com/anthropics/claude-code/releases/tag/v2.1.119
- https://code.claude.com/docs/en/remote-control
- https://code.claude.com/docs/en/setup
- https://code.claude.com/docs/en/troubleshoot-install#command-not-found-claude-after-installation
- https://code.claude.com/docs/en/headless
- https://code.claude.com/docs/en/env-vars
- https://code.claude.com/docs/en/sub-agents
- https://code.claude.com/docs/en/changelog#2-1-302
- https://github.com/anthropics/claude-code
- https://platform.claude.com/docs/en/about-claude/models/overview
- https://code.claude.com/docs/en/cli-reference#cli-flags
- https://code.claude.com/docs/en/changelog#2-1-304
- https://code.claude.com/docs/en/mcp#configure-tool-search
- https://code.claude.com/docs/en/mcp#tool-search-through-a-gateway
- https://code.claude.com/docs/en/env-vars#variables
- https://code.claude.com/docs/en/scheduled-tasks
- https://code.claude.com/docs/en/model-config#adjust-effort-level 対応モデル: Claude Fable 5.2、Claude Fable 5.1、Claude Fable 5、Claude Opus 5.5、Claude Opus 5、Claude Sonnet 5.5、Claude Sonnet 5、Claude Sonnet 4.6、Claude Opus 4.8、Claude Haiku 5.5、Claude Haiku 4.5