claude-code-settings-maintenance
Maintain Claude Code settings, hooks, and agent config formats; use when editing or validating settings.json or hooks.
What this skill does
# Claude Code Settings & Configuration Maintenance
**Purpose**: Best practices for maintaining Claude Code settings.json and agent files to avoid validation errors and ensure proper configuration.
## ๐จ Critical: Always Consult Official Documentation
**MANDATORY PROTOCOL**: When uncertain about configuration format, ALWAYS web search official Claude Code documentation first.
### Documentation Search Strategy
1. **Use WebFetch tool** to retrieve latest official docs
2. **Primary documentation URLs**:
- `https://code.claude.com/docs/en/` - Main documentation hub
- `https://code.claude.com/docs/en/hooks` - Hooks documentation
- `https://code.claude.com/docs/en/agents` - Agents documentation
- `https://code.claude.com/docs/en/settings` - Settings reference
3. **Search pattern**:
```
WebFetch(url="https://code.claude.com/docs/en/hooks",
prompt="What is the correct format for hook matchers?")
```
## ๐ Hooks Configuration Format
### โ
Correct Format (String Matchers)
```json
{
"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"
}
]
}
]
}
}
```
### โ Incorrect Format (Object Matchers - OLD FORMAT)
```json
{
"hooks": {
"PreToolUse": [
{
"matcher": {"tools": ["*"]}, // โ WRONG - Object format
"hooks": [...]
},
{
"matcher": {"tools": ["Write"]}, // โ WRONG - Object format
"hooks": [...]
}
]
}
}
```
### Matcher Types
| Matcher Pattern | Description | Example |
|----------------|-------------|---------|
| `"*"` | Match all tools | `"matcher": "*"` |
| `"Write"` | Match specific tool | `"matcher": "Write"` |
| `"Edit|Write"` | Match multiple tools (regex) | `"matcher": "Edit|Write"` |
| `"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"`).
### Hook Event Types
- **PreToolUse**: Runs before tool execution (requires matcher)
- **PostToolUse**: Runs after tool execution (requires matcher)
- **UserPromptSubmit**: Runs when user submits prompt (use empty matcher `""`)
- **SessionStart**: Runs at session start (use empty matcher `""`)
- **Stop**: Runs when session stops (use empty matcher `""`)
## ๐ค Agent File Frontmatter Format
### โ
Correct Format (Unquoted Values)
```yaml
---
name: my-agent
description: A specialized agent for specific tasks with detailed expertise
---
# Agent Content
Your agent instructions here...
```
### โ Incorrect Format (Quoted Values)
```yaml
---
name: "my-agent" # โ WRONG - Quoted
description: "A specialized agent..." # โ WRONG - Quoted
---
```
### Required Frontmatter Fields
| Field | Required | Format | Example |
|-------|----------|--------|---------|
| `name` | โ
Yes | Unquoted string | `name: code-review` |
| `description` | โ
Yes | Unquoted string | `description: Expert code reviewer` |
### Agent Naming Best Practices
- **Use kebab-case**: `code-review`, `test-runner`, `security-audit`
- **Be descriptive**: Name should indicate agent's purpose
- **Avoid generic names**: Prefer `python-test-runner` over `tester`
- **No quotes**: YAML values should be unquoted
## ๐ Validation Protocol
### 1. Use /doctor Command
**ALWAYS run `/doctor` after configuration changes**:
```bash
/doctor
```
Expected clean output:
```
โ
Diagnostics
โ Currently running: npm-global (2.0.43)
โ Settings: Valid
โ Agents: All parsed successfully
โ Hooks: All registered correctly
```
### 2. Common Validation Errors
| 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 |
### 3. Pre-Commit Checklist
Before committing settings changes:
- [ ] Run `/doctor` to validate configuration
- [ ] Check hooks section uses string matchers
- [ ] Verify all agent files have required frontmatter
- [ ] Ensure agent frontmatter uses unquoted values
- [ ] Test hooks execute correctly (if applicable)
## ๐ ๏ธ Troubleshooting Workflow
### Issue: Hooks Not Working
1. **Check matcher format**: Ensure using string matchers, not objects
2. **Verify hook syntax**: Confirm JSON structure is valid
3. **Test command**: Run hook command manually to ensure it works
4. **Check permissions**: Ensure hook script files are executable
### Issue: Agent Parse Errors
1. **Check frontmatter**: Verify both `name` and `description` fields present
2. **Remove quotes**: Ensure values are unquoted (YAML format)
3. **Validate YAML**: Ensure frontmatter block starts/ends with `---`
4. **Check indentation**: YAML is indent-sensitive (use spaces, not tabs)
### Issue: Settings Not Loading
1. **Validate JSON**: Use `jq` or JSON validator to check syntax
2. **Check file location**: Ensure settings.json is in correct directory
- Global: `~/.claude/settings.json`
- Project: `<project>/.claude/settings.json`
3. **Restart Claude Code**: Configuration changes may require restart
## ๐ Documentation Reference Quick Links
| 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` |
## ๐ฏ Best Practices Summary
1. **Always consult official docs** when uncertain about format
2. **Use string matchers** for hooks (not object format)
3. **Use unquoted values** in agent frontmatter
4. **Run /doctor** after every configuration change
5. **Test hooks manually** before committing
6. **Keep settings.json valid** - use JSON validator
7. **Document custom configurations** in project README
8. **Version control** all .claude/ directory files
9. **Use descriptive names** for agents and hooks
10. **Follow principle of least privilege** for permissions
## โ ๏ธ Common Pitfalls to Avoid
| 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 Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts โ single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score โฅ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.