設定
パーミッションモード
Claude Codeの権限設定。5つのモード、ルール構文、MCP権限、設定方法を解説。
permissionssecuritysettingsmcp
パーミッションモード
Claude Codeは5つの権限モードを提供します。
| モード | 説明 | 想定用途 |
|---|---|---|
default | ツールごとに確認 | 通常の開発 |
acceptEdits | 編集操作を自動許可 | 高速な開発サイクル |
dontAsk | ほぼ全操作を自動許可 | 信頼できる環境 |
bypassPermissions | 全権限チェックをスキップ | CI/CD等の自動化 |
plan | 読み取りのみ | 調査・計画フェーズ |
# モードの指定
claude --permission-mode plan
// settings.jsonでのデフォルト指定
{
"permissions": {
"defaultMode": "acceptEdits"
}
}
ルール構文
allow、ask、deny でツールごとの権限を細かく制御します。
基本形式
ToolName(subcommand:arguments)
ルール例
{
"permissions": {
"allow": [
"Bash(git diff:*)",
"Bash(git log:*)",
"Bash(npm test:*)",
"Read"
],
"ask": [
"Bash(git push:*)",
"Bash(npm install:*)"
],
"deny": [
"WebFetch",
"Read(./.env)",
"Bash(rm -rf:*)"
]
}
}
ツール別権限一覧
| ツール | 権限 | 例 |
|---|---|---|
Bash | 要確認 | Bash(git diff:*) |
Edit | 要確認 | Edit |
Write | 要確認 | Write |
WebFetch | 要確認 | WebFetch |
WebSearch | 要確認 | WebSearch |
Read | 不要 | Read |
Grep | 不要 | Grep |
Glob | 不要 | Glob |
MCP権限
MCPツールはサーバー単位またはツール単位で権限を設定します。ワイルドカードはサポートされていません。
{
"permissions": {
"allow": [
"mcp__github",
"mcp__github__get_issue"
]
}
}
| 指定方法 | 説明 | 例 |
|---|---|---|
| サーバー全体 | サーバー内の全ツールを許可 | mcp__github |
| 個別ツール | 特定ツールのみ許可 | mcp__github__get_issue |
mcp__github__* のようなワイルドカードは無効です。
追加ディレクトリ
デフォルトの作業ディレクトリ以外も許可できます。
{
"permissions": {
"additionalDirectories": [
"../docs/",
"../shared-libs/"
]
}
}
設定の確認・変更
# 現在の権限を確認
/permissions
# CLIで設定
claude config add permissions.allow "Bash(npm run build:*)"