講座 › 分野3 Claude Code
3.1 Claude Codeの操作
常に効かせたい事実はCLAUDE.md、手順はスキル、部分的な決まりはルール、任せる作業はサブエージェント。自動化は -p と出力形式で。
コアコンポーネント:ルール・スキル・コマンド・エージェント・メモリ 読了

CLAUDE.mdには、毎回守ってほしい事実(ビルドのコマンド、決まり、構成)を書きます。特定のファイルの種類やフォルダだけに効かせたい決まりは、.claude/rules/ にルールとして分けます。何度も貼り付ける手順は、SKILL.mdを書いてスキルにします。スキルの本文は、使うときだけ読み込まれます。以前のカスタムコマンドは、スキルに統合されました。サブエージェントは、自分のコンテキストウィンドウと、専用のシステムプロンプトとツールの権限で動きます。オートメモリは、ユーザーの指摘や好みから、Claudeが自分で書くメモです。
出典:Memory (CLAUDE.md)
Rules let you scope instructions to specific file types or subdirectories.https://code.claude.com/docs/en/memory.md(取得 2026-11-17)
出典:Skills
Create a skill when you keep pasting the same instructions, checklist, or multi-step procedure into chathttps://code.claude.com/docs/en/skills.md(取得 2026-11-17)
出典:Skills
Custom commands have been merged into skills.https://code.claude.com/docs/en/skills.md(取得 2026-11-17)
出典:Subagents
Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions.https://code.claude.com/docs/en/sub-agents.md(取得 2026-11-17)
出典:Memory (CLAUDE.md)
notes Claude writes itself based on your corrections and preferenceshttps://code.claude.com/docs/en/memory.md(取得 2026-11-17)
CLAUDE.mdの階層と初期化 読了

作業フォルダより上の階層にあるCLAUDE.mdは起動時に読み込まれ、下の階層のものは必要になったときに読み込まれます。リポジトリで初めて使うときは /init を実行すると、Claudeがコードを調べて、ビルドやテストの方法を書いたCLAUDE.mdのたたき台を作ります。
出典:Memory (CLAUDE.md)
CLAUDE.md and CLAUDE.local.md files in the directory hierarchy above the working directory are loaded at launch. Files in subdirectories load on demand.https://code.claude.com/docs/en/memory.md(取得 2026-11-17)
出典:Memory (CLAUDE.md)
Claude analyzes your codebase and creates a file with build commands, test instructions, and project conventions it discovers.https://code.claude.com/docs/en/memory.md(取得 2026-11-17)
セッションの管理とスラッシュコマンド 読了

/clear は、プロジェクトのメモリを残したまま新しい作業を始めます。/resume は以前の会話に戻ります。claude --continue は、そのフォルダの直近のセッションを開きます。/plan は大きな変更の前に計画モードに切り替え、/context はコンテキストを何が埋めているかを表示します。
出典:Commands
`/clear` starts fresh on a new task while keeping project memory.https://code.claude.com/docs/en/commands.md(取得 2026-11-17)
出典:Sessions
Reopens the most recent session in the current directoryhttps://code.claude.com/docs/en/sessions.md(取得 2026-11-17)
出典:Commands
`/plan` switches into plan mode before a large change.https://code.claude.com/docs/en/commands.md(取得 2026-11-17)
ヘッドレスモードとストリーミングの出力 読了

claude に -p を付けると、対話なしで実行できます。CIやスクリプトに組み込むときに使います。出力の形式は、text(既定)、json(結果とセッションIDなど)、stream-json(1行ずつのJSONで、その場で流れてくる)から選べます。
出典:Headless mode
Add the `-p` (or `--print`) flag to any `claude` command to run it non-interactively.https://code.claude.com/docs/en/headless.md(取得 2026-11-17)
出典:Headless mode
`stream-json`: newline-delimited JSON for real-time streaminghttps://code.claude.com/docs/en/headless.md(取得 2026-11-17)
権限モードと自動モード、settings.json 読了

権限モードは、確認なしに何をしてよいかを決めます。default(手動)は読み取りだけ、acceptEdits はファイルの編集も、plan は調べるだけ、auto は背景の安全の検査を付けてすべてを許します。bypassPermissions は、隔離したコンテナやVMだけで使います。権限やフックなどは settings.json で設定します。
出典:Permission modes (auto mode)
A permission mode sets which actions Claude can take in a session without asking you first.https://code.claude.com/docs/en/permission-modes.md(取得 2026-11-17)
出典:Permission modes (auto mode)
Everything, with background safety checks | Long tasks, reducing prompt fatiguehttps://code.claude.com/docs/en/permission-modes.md(取得 2026-11-17)
出典:Permission modes (auto mode)
Everything | Isolated containers and VMs onlyhttps://code.claude.com/docs/en/permission-modes.md(取得 2026-11-17)
- 事実はCLAUDE.md、手順はスキル、部分的な決まりはルール。CLAUDE.mdが手順で膨らんだらスキルへ移す。
出典:Skills
or when a section of CLAUDE.md has grown into a procedure rather than a fact
https://code.claude.com/docs/en/skills.md(取得 2026-11-17) - CIでは -p。結果を機械で読むなら json、流れてくる途中を扱うなら stream-json。
出典:Headless mode
`json`: structured JSON with result, session ID, and metadata
https://code.claude.com/docs/en/headless.md(取得 2026-11-17)