Claude Code: 出力スタイル
最終更新:2026-08-31
出力スタイルは Claude Code の「話し方」を制御します — 簡潔から詳細まで、プレーンテキストから JSON まで、適切なスタイルの選択で情報の伝わりやすさが変わります。
💡 ヒント: 出力スタイルは Claude Code の能力には影響せず、結果の表示方法にのみ影響します。日常開発ではデフォルトを、自動化スクリプトでは JSON を使用してください。
📋 前提条件: 第16章 - Agent Skills と skill-creator
1. 学ぶ内容
- 内蔵出力スタイル
- カスタム出力形式
- シナリオ別のスタイル選択
- スクリプト統合向け JSON 出力
- 出力スタイルの設定
2. 内蔵出力スタイル
(1) スタイル一覧
| スタイル | 説明 | ユースケース |
|---|---|---|
| default | バランスの取れた情報 | 日常開発 |
| concise | 最もコンパクトな出力 | 素早いクエリ |
| verbose | 詳細な説明 | 学習/デバッグ |
| code | コード中心 | 純粋なコード生成 |
| plan | 実行前に計画 | 複雑なタスク |
(2) スタイルの切り替え
BASH
# コマンドライン
claude --style concise
claude --style verbose
# セッション内
> /style concise
> /style verbose
# CLAUDE.md 内
## Output Preferences
- Use concise style
- Show diff for code modifications
▶ 例1:スタイルによる出力の比較
TEXT
📖 参照専用
# Default:変更と結果のバランスの取れた情報
# Concise:✅ Added resetPassword() to user.service.ts, 4 tests, 2 files changed のみ
# Verbose:ステップバイステップの分析、実装の詳細、テストの説明
3. カスタム出力形式
(1) CLAUDE.md で定義
MARKDOWN
## Output Preferences
- コード変更には完全ファイルではなく diff のみ表示
- コードは英語、説明は日本語で記述
- ファイル修正後に自動でテストを実行
- テスト失敗時は失敗理由と修正計画を表示
- 各ステップの説明は不要(求められた場合を除く)
(2) タスクレベルの形式制御
TEXT
📖 参照専用
> List all TODO comments, output in JSON format
> Compare Express vs Fastify performance, show as table
> Generate API documentation, Markdown format
> Refactor this function, only output modified code
▶ 例2:フォーマット出力
TEXT
📖 参照専用
> List test coverage for all services under src/services/, show as table
Claude Code:
| Service | Coverage | Missing |
|:--------|:---------|:--------|
| user.service.ts | 92% | delete method |
| auth.service.ts | 85% | refresh token |
| payment.service.ts | 0% | **no tests** |
Average: 64% | Below 80%: 3 services
4. スクリプト向け JSON 出力
(1) コマンドライン JSON 出力
BASH
claude -p "List all TypeScript errors" --output json
# 出力構造
{
"task": "list TypeScript errors",
"result": { "errors": [...], "total": 1 },
"usage": { "tokens": 15420, "cost_usd": 0.31 }
}
▶ 例3:自動コードレビュースクリプト
BASH
#!/bin/bash
# auto-review.sh - git の変更を自動レビュー
CHANGED_FILES=$(git diff --name-only HEAD~1)
for file in $CHANGED_FILES; do
RESULT=$(claude -p "Review $file code quality, focus on security" --output json)
ISSUES=$(echo "$RESULT" | jq '.result.issues | length')
if [ "$ISSUES" -gt 0 ]; then
echo "⚠️ Found $ISSUES issues in $file"
else
echo "✅ $file looks good"
fi
done
5. 出力スタイルの設定
(1) グローバルデフォルトスタイル
JSON
// ~/.claude/settings.json
{
"output": {
"defaultStyle": "concise",
"showDiff": true,
"language": "en",
"autoTest": true
}
}
(2) 動的切り替え
TEXT
📖 参照専用
> From now on use verbose style
> /style concise # 戻す
> This task use JSON output # 単一タスク指定
6. 総合例:マルチシナリオスタイル戦略
TEXT
📖 参照専用
# 日常開発(default)
claude
> Refactor UserService
# 素早い修正(concise)
claude --style concise
> Fix this typo
# 新しいプロジェクトの学習(verbose)
claude --style verbose
> Explain this project's architecture
# 自動化スクリプト(JSON)
claude -p "Code review" --output json | jq '.result'
❓ よくある質問
Q 異なるスタイルで Token 消費は変わりますか?
A はい。verbose が最も多く消費し、concise が最も少ない。差は2-3倍になる場合があります。日常使用:default または concise。
Q JSON 出力形式は安定していますか?
A ほぼ安定していますが、バージョンで変更される可能性があります。スクリプトにはエラーハンドリングを追加してください。
Q Markdown テンプレートをカスタマイズできますか?
A CLAUDE.md に出力形式の要件を記述でき、Claude Code はそれに従おうとします。厳密なテンプレートシステムはありません。
Q 出力をより簡潔にするには?
A concise スタイル + 正確な指示 + CLAUDE.md に「ステップの説明は不要」と書いてください。
📖 まとめ
- 5つの内蔵スタイル:default、concise、verbose、code、plan
- 日常:default。素早い:concise。学習:verbose
- JSON 出力はスクリプト統合と自動化に適している
- CLAUDE.md でプロジェクトレベルの出力好みを定義可能
- スタイルは表示にのみ影響し、コード品質には影響しない
📝 練習問題
- 基本 (⭐): 3つの異なるスタイルで同じタスクを完了し、出力の違いを比較してください。
- 応用 (⭐⭐): JSON 出力形式を使用したシンプルなコードレビュースクリプトを書いてください。
- 高度 (⭐⭐⭐): CLAUDE.md にチーム出力スタイル基準を設計し、一貫した体験を実現してください。