From claude-commands
Provides best practices for Claude Code settings.json and hooks configuration to prevent validation errors. Useful for troubleshooting configs, agent files, and consulting official docs.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-2 --plugin jleechanorg-claude-commandsThis skill uses the workspace's default tool permissions.
**Purpose**: Best practices for maintaining Claude Code settings.json and agent files to avoid validation errors and ensure proper configuration.
Validates Claude Code settings.json against official JSON schema using IDE support (VS Code, IntelliJ), Python jsonschema, and Node.js ajv scripts. Ensures configuration correctness.
Reference every Claude Code setting option from permissions, hooks, and sandbox to models, status line, and MCP servers. Use for config customization and troubleshooting.
Manages hooks and automation for coding agents like Claude Code, Codex CLI, OpenCode. Handles add, list, remove, update, validate requests with validation script and restart reminders.
Share bugs, ideas, or general feedback.
Purpose: Best practices for maintaining Claude Code settings.json and agent files to avoid validation errors and ensure proper configuration.
MANDATORY PROTOCOL: When uncertain about configuration format, ALWAYS web search official Claude Code documentation first.
Use WebFetch tool to retrieve latest official docs
Primary documentation URLs:
https://code.claude.com/docs/en/ - Main documentation hubhttps://code.claude.com/docs/en/hooks - Hooks documentationhttps://code.claude.com/docs/en/agents - Agents documentationhttps://code.claude.com/docs/en/settings - Settings referenceSearch pattern:
WebFetch(url="https://code.claude.com/docs/en/hooks",
prompt="What is the correct format for hook matchers?")
{
"hooks": {
"PreToolUse": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "echo 'Running pre-tool hook'",
"description": "Example hook"
}
]
},
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "echo 'Before write operation'",
"description": "Pre-write hook"
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo 'After bash command'",
"description": "Post-bash hook"
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "echo 'User submitted prompt'",
"description": "Prompt submission hook"
}
]
}
],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "echo 'Session stopping'",
"description": "Stop hook"
}
]
}
]
}
}
{
"hooks": {
"PreToolUse": [
{
"matcher": {"tools": ["*"]}, // โ WRONG - Object format
"hooks": [...]
},
{
"matcher": {"tools": ["Write"]}, // โ WRONG - Object format
"hooks": [...]
}
]
}
}
| Matcher Pattern | Description | Example |
|---|---|---|
"*" | Match all tools | "matcher": "*" |
"Write" | Match specific tool | "matcher": "Write" |
| `"Edit | Write"` | Match multiple tools (regex) |
"Bash(git:*)" | Match specific bash commands | "matcher": "Bash(git:*)" |
"" | Empty matcher (for non-tool hooks) | "matcher": "" |
Note: Matcher patterns accept raw regular expressions. Use the pipe (
|) for alternation without escaping (e.g.,"Edit|Write").
"")"")"")---
name: my-agent
description: A specialized agent for specific tasks with detailed expertise
---
# Agent Content
Your agent instructions here...
---
name: "my-agent" # โ WRONG - Quoted
description: "A specialized agent..." # โ WRONG - Quoted
---
| Field | Required | Format | Example |
|---|---|---|---|
name | โ Yes | Unquoted string | name: code-review |
description | โ Yes | Unquoted string | description: Expert code reviewer |
code-review, test-runner, security-auditpython-test-runner over testerALWAYS run /doctor after configuration changes:
/doctor
Expected clean output:
โ
Diagnostics
โ Currently running: npm-global (2.0.43)
โ Settings: Valid
โ Agents: All parsed successfully
โ Hooks: All registered correctly
| Error | Cause | Fix |
|---|---|---|
matcher: Expected string, but received object | Using {"tools": [...]} format | Change to string: "*" or "Write" |
Missing required "description" field | Agent frontmatter missing description | Add description: ... to frontmatter |
Missing required "name" field | Agent frontmatter missing name | Add name: ... to frontmatter |
Invalid frontmatter | Quoted values in YAML | Remove quotes from name/description |
Before committing settings changes:
/doctor to validate configurationname and description fields present---jq or JSON validator to check syntax~/.claude/settings.json<project>/.claude/settings.json| Topic | URL |
|---|---|
| Hooks | https://code.claude.com/docs/en/hooks |
| Agents | https://code.claude.com/docs/en/agents |
| Settings | https://code.claude.com/docs/en/settings |
| MCP Servers | https://code.claude.com/docs/en/mcp |
| Permissions | https://code.claude.com/docs/en/permissions |
| Pitfall | Impact | Prevention |
|---|---|---|
| Using old object matcher format | Hooks fail validation | Always use string matchers |
| Quoting agent frontmatter values | Agent parse errors | Use unquoted YAML values |
| Missing description field | Agent not loaded | Always include name + description |
| Invalid JSON syntax | Settings not loaded | Validate JSON before commit |
| Not running /doctor | Deploy with broken config | Run /doctor before every commit |
Search for object matchers:
grep -n '"matcher": {' .claude/settings.json
Old:
"matcher": {"tools": ["*"]}
"matcher": {"tools": ["Write"]}
"matcher": {"tools": ["Bash(git:*)"]}
New:
"matcher": "*"
"matcher": "Write"
"matcher": "Bash(git:*)"
For UserPromptSubmit, Stop, SessionStart:
{
"UserPromptSubmit": [
{
"matcher": "", // Empty string for non-tool hooks
"hooks": [...]
}
]
}
/doctor
{
"env": {
"BASH_MAX_OUTPUT_LENGTH": "5000"
},
"permissions": {
"allow": ["Bash(git:*)"]
},
"hooks": {
"PreToolUse": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "echo 'Pre-tool execution'",
"description": "Log before tool use"
}
]
}
],
"PostToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "echo 'File written'",
"description": "Log file writes"
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "echo 'Prompt submitted'",
"description": "Log prompt submission"
}
]
}
]
}
}
ALWAYS search official docs when:
Search Example:
WebFetch({
url: "https://code.claude.com/docs/en/hooks",
prompt: "What is the correct format for hook matchers? Show examples."
})
Configuration is correct when:
/doctor shows no errorsLast Updated: 2025-11-17 Applies To: Claude Code 2.0+ Official Docs: https://code.claude.com/docs/en/