講座 › 分野2 アプリケーションと統合
2.5 Claudeアプリケーションの設計
どの入口から使うかで、Claudeが受け取る指示の形が違う。指示とデータの境界、スキーマ、セッションの整理、プラグインを設計で押さえる。
入口ごとに指示の届き方が違う 読了

APIでは、システムプロンプトを自分で書きます。役割を1文与えるだけでも、ふるまいと口調が絞られます。Claude Codeでは、CLAUDE.mdが会話の最初に読み込まれますが、強制される設定ではなく文脈として扱われます。Agent SDKでは、システムプロンプトを指定しないと、ツール呼び出しだけを扱う最小限のプロンプトになり、Claude Code用の安全の指示も含まれません。Claude Codeと同じふるまいにしたいときは claude_code プリセットを指定し、自分の指示は append で後ろに足します。
出典:Prompting best practices
Setting a role in the system prompt focuses Claude’s behavior and tone for your use case.https://platform.claude.com/docs/en/build-with-claude/prompt-engineeri…(取得 2026-11-17)
出典:Memory (CLAUDE.md)
Claude treats them as context, not enforced configuration.https://code.claude.com/docs/en/memory.md(取得 2026-11-17)
出典:Modifying system prompts
the SDK uses a minimal prompt that covers tool calling but omits the rest of the `claude_code` preset's content, including its security and safety instructionshttps://code.claude.com/docs/en/agent-sdk/modifying-system-prompts.md(取得 2026-11-17)
コンテンツの境界 読了

指示、背景、例、入力データが混ざるプロンプトでは、それぞれをXMLのタグで囲みます。境界がはっきりして、取り違えが減ります。外から来た文書やWebページを、信頼できる指示と同じ扱いにしないことは、安全の面でも重要です。
出典:Prompting best practices
XML tags help Claude parse complex prompts unambiguously, especially when your prompt mixes instructions, context, examples, and variable inputs.https://platform.claude.com/docs/en/build-with-claude/prompt-engineeri…(取得 2026-11-17)
出典:Claude Certified Developer – Foundations 試験ガイド v1.0(日本語)
取得したページのコンテンツを信頼できない入力として扱い、信頼できる指示とは分離しておきhttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-17)
スキーマの設計 読了

ツールは、名前、何をするか・いつ使うかを書いた詳しい説明、そしてJSON Schemaの入力の定義で作ります。応答を決まったJSONで受け取りたいときは、構造化出力を使います。構造化出力は、制約付きの生成でスキーマどおりの応答を保証します。
出典:Define tools
A detailed plain text description of what the tool does, when it should be used, and how it behaves.https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-t…(取得 2026-11-17)
出典:Structured outputs
Structured outputs guarantee schema-compliant responses through constrained decodinghttps://platform.claude.com/docs/en/build-with-claude/structured-outpu…(取得 2026-11-17)
セッションの整理(セッションハイジーン) 読了

関係のない作業に移るときは /clear で会話を切り替えます。古い会話が次に必要なファイルの場所を奪い、毎回のメッセージでトークンを消費するからです。同じ指摘を2回しても直らないときも、3回目の指摘を重ねるより、/clear して良いプロンプトを書き直すほうが効果的です。
出典:Context window
Old conversation crowds out the files you need next and costs tokens on every message.https://code.claude.com/docs/en/context-window.md(取得 2026-11-17)
出典:Claude Code best practices
after two failed corrections run `/clear` and write a better prompt instead of a thirdhttps://code.claude.com/docs/en/best-practices.md(取得 2026-11-17)
プラグインの管理 読了

Claude Codeのプラグインは、スキル、エージェント、フック、MCPサーバーなどを1つにまとめて、まとめて入れたり読み込んだりできるものです。多くはマーケットプレイス(プラグインの一覧と取得先をまとめた目録)から入れます。
出典:Plugins
A Claude Code plugin is a directory of skills, agents, hooks, MCP servers, or other components that Claude Code installs and loads as one unit.https://code.claude.com/docs/en/plugins/overview.md(取得 2026-11-17)
出典:Plugins
Most plugins come from a marketplace, which is a catalog that lists plugins and where to fetch each one.https://code.claude.com/docs/en/plugins/overview.md(取得 2026-11-17)
- CLAUDE.mdもシステムプロンプトも「文脈」。必ず守らせたいことはフックや権限で強制する。
出典:Memory (CLAUDE.md)
To block an action regardless of what Claude decides, use a PreToolUse hook
https://code.claude.com/docs/en/memory.md(取得 2026-11-17) - Agent SDKで指定なしは最小のプロンプト。Claude Code相当にするなら claude_code プリセット+append。
出典:Modifying system prompts
Everything above, with your instructions added after the preset. Nothing is removed, so this is the lowest-risk
https://code.claude.com/docs/en/agent-sdk/modifying-system-prompts.md(取得 2026-11-17)