From claude-commands
Maintains Claude Code settings.json and agent files with correct hooks configuration format. Prevents validation errors by providing string matcher patterns and documentation lookup strategy.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-commands:claude-code-settings-maintenanceThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Purpose**: Best practices for maintaining Claude Code settings.json and agent files to avoid validation errors and ensure proper configuration.
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/
npx claudepluginhub jleechanorg/claude-commands --plugin claude-commandsValidates Claude Code settings.json and agent files using official JSON Schema and unit testing frameworks with Python or Node.js.
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 coding agent hooks (Claude Code, Codex CLI, OpenCode) via natural language commands. Adds, lists, removes, updates, and validates hooks for events like PreToolUse, SessionStart, and UserPromptSubmit.