| name | component-auditor |
| description | Audit Claude Code agents, skills, commands, and hooks for quality, completeness, and adherence to templates and best practices. Use this skill when reviewing workspace components, ensuring quality standards, preparing for deployment, or investigating component issues. Trigger for phrases like "audit components", "check agents", "review skills", "validate commands", or proactively before major releases or when onboarding new components. |
| allowed-tools | ["Read","Grep","Glob","Bash"] |
Component Auditor
You are an expert at auditing Claude Code components (agents, skills, commands, hooks) for quality, completeness, and adherence to best practices.
When to Use This Skill
Use this skill whenever:
- Adding new agents, skills, or commands to the workspace
- Before deploying workspace changes to production
- Investigating why a component isn't working as expected
- Ensuring consistency across all components
- The user mentions "audit", "review", "check quality", or "validate"
- Quarterly quality reviews or workspace cleanup
Component Types
Agents (~/.claude/agents/**/*.md)
- Specialized subagents with specific capabilities
- Frontmatter: name, description, tools, model, etc.
Skills (~/.claude/skills/*/SKILL.md)
- Reusable workflows and procedures
- Frontmatter: name, description
- Optional: references/, scripts/, resources/
Commands (~/.claude/commands/**/*.md)
- User-invocable slash commands
- Frontmatter: description, allowed-tools, argument-hint
Hooks (~/.claude/settings.json)
- Automated workflows triggered by events
- JSON configuration with event matchers
Core Workflow
Step 1: Inventory Components
Scan the workspace:
echo "=== Component Inventory ==="
AGENTS=$(find ~/.claude/agents -name "*.md" -type f 2>/dev/null | wc -l | tr -d ' ')
echo "Agents: $AGENTS"
SKILLS=$(find ~/.claude/skills -name "SKILL.md" -type f 2>/dev/null | wc -l | tr -d ' ')
echo "Skills: $SKILLS"
COMMANDS=$(find ~/.claude/commands -name "*.md" -type f 2>/dev/null | wc -l | tr -d ' ')
echo "Commands: $COMMANDS"
if [ -f ~/.claude/settings.json ]; then
echo "Hooks: configured"
else
echo "Hooks: not configured"
fi
echo ""
echo "Total components: $((AGENTS + SKILLS + COMMANDS))"
Step 2: Audit Agents
For each agent file:
find ~/.claude/agents -name "*.md" -type f | while read agent; do
echo "=== Auditing: $agent ==="
if ! head -1 "$agent" | grep -q "^---$"; then
echo "ERROR: Missing frontmatter"
continue
fi
FRONTMATTER=$(awk '/^---$/,/^---$/' "$agent" | sed '1d;$d')
echo "$FRONTMATTER" | grep -q "^name:" || echo "WARN: Missing 'name' field"
echo "$FRONTMATTER" | grep -q "^description:" || echo "ERROR: Missing 'description' field"
echo "$FRONTMATTER" | grep -q "^tools:" || echo "ERROR: Missing 'tools' field"
DESC=$(echo "$FRONTMATTER" | grep "^description:" | cut -d: -f2- | sed 's/^ *//')
DESC_LEN=${#DESC}
if [ $DESC_LEN -lt 50 ]; then
echo "WARN: Description too short ($DESC_LEN chars, recommend 50-300)"
elif [ $DESC_LEN -gt 300 ]; then
echo "WARN: Description too long ($DESC_LEN chars, recommend 50-300)"
fi
if echo "$DESC" | grep -qi "proactively\|use this"; then
echo "PASS: Description includes usage guidance"
else
echo "WARN: Description should start with 'Use PROACTIVELY' or 'Use this'"
fi
BODY=$(sed '1,/^---$/d' "$agent" | tail -n +2)
echo "$BODY" | grep -q "^## " || echo "WARN: No sections (should have ##)"
echo "$BODY" | grep -qi "instructions\|workflow\|process" || echo "WARN: Missing Instructions section"
echo "$BODY" | grep -q "{{" && echo "ERROR: Contains placeholder text {{}}"
echo ""
done
Agent Checklist:
Step 3: Audit Skills
For each skill directory:
find ~/.claude/skills -type d -mindepth 1 -maxdepth 1 | while read skill_dir; do
echo "=== Auditing: $(basename "$skill_dir") ==="
if [ ! -f "$skill_dir/SKILL.md" ]; then
echo "ERROR: Missing SKILL.md file"
continue
fi
SKILL_FILE="$skill_dir/SKILL.md"
if ! head -1 "$SKILL_FILE" | grep -q "^---$"; then
echo "ERROR: Missing frontmatter"
continue
fi
FRONTMATTER=$(awk '/^---$/,/^---$/' "$SKILL_FILE" | sed '1d;$d')
echo "$FRONTMATTER" | grep -q "^name:" || echo "ERROR: Missing 'name' field"
echo "$FRONTMATTER" | grep -q "^description:" || echo "ERROR: Missing 'description' field"
SKILL_NAME=$(echo "$FRONTMATTER" | grep "^name:" | cut -d: -f2- | sed 's/^ *//')
DIR_NAME=$(basename "$skill_dir")
if [ "$SKILL_NAME" != "$DIR_NAME" ]; then
echo "WARN: Name mismatch (frontmatter: $SKILL_NAME, dir: $DIR_NAME)"
fi
DESC=$(echo "$FRONTMATTER" | grep "^description:" | cut -d: -f2-)
if echo "$DESC" | grep -qi "^You are\|^I am"; then
echo "WARN: Description should be third-person, not 'You are' or 'I am'"
fi
WORD_COUNT=$(wc -w < "$SKILL_FILE" | tr -d ' ')
if [ "$WORD_COUNT" -gt 5000 ]; then
echo "WARN: SKILL.md is large ($WORD_COUNT words, recommend <5000)"
echo " Consider moving content to references/"
fi
grep -q "## When to Use" "$SKILL_FILE" || echo "WARN: Missing 'When to Use' section"
grep -qi "## .*workflow\|## .*process\|## .*steps" "$SKILL_FILE" || \
echo "WARN: Missing workflow/process section"
grep -qi "## .*example" "$SKILL_FILE" || echo "WARN: Missing examples section"
grep -q "{{" "$SKILL_FILE" && echo "ERROR: Contains placeholder text {{}}"
if [ -d "$skill_dir/references" ]; then
echo "INFO: Has references/ directory"
fi
if [ -d "$skill_dir/scripts" ]; then
echo "INFO: Has scripts/ directory"
find "$skill_dir/scripts" -type f -name "*.sh" -o -name "*.bash" | while read script; do
if [ ! -x "$script" ]; then
echo "WARN: Script not executable: $(basename "$script")"
fi
done
fi
echo ""
done
Skill Checklist:
Step 4: Audit Commands
For each command file:
find ~/.claude/commands -name "*.md" -type f | while read cmd; do
echo "=== Auditing: $cmd ==="
if ! head -1 "$cmd" | grep -q "^---$"; then
echo "ERROR: Missing frontmatter"
continue
fi
FRONTMATTER=$(awk '/^---$/,/^---$/' "$cmd" | sed '1d;$d')
echo "$FRONTMATTER" | grep -q "^description:" || echo "ERROR: Missing 'description' field"
DESC=$(echo "$FRONTMATTER" | grep "^description:" | cut -d: -f2- | sed 's/^ *//')
DESC_LEN=${#DESC}
if [ $DESC_LEN -gt 100 ]; then
echo "WARN: Description too long ($DESC_LEN chars, recommend <100)"
fi
BODY=$(sed '1,/^---$/d' "$cmd" | tail -n +2)
echo "$BODY" | grep -q "^# " || echo "WARN: Missing title (# heading)"
if echo "$FRONTMATTER" | grep -q "^argument-hint:"; then
if ! echo "$BODY" | grep -q '\$ARGUMENTS'; then
echo "WARN: Has argument-hint but doesn't use \$ARGUMENTS"
fi
fi
if echo "$BODY" | grep -q '!\`'; then
echo "INFO: Uses dynamic context (! syntax)"
fi
echo "$BODY" | grep -q "{{" && echo "ERROR: Contains placeholder text {{}}"
echo ""
done
Command Checklist:
Step 5: Audit Hooks
Check hooks configuration:
if [ ! -f ~/.claude/settings.json ]; then
echo "WARN: No settings.json found"
exit 0
fi
echo "=== Auditing Hooks ==="
if ! jq empty ~/.claude/settings.json 2>/dev/null; then
echo "ERROR: Invalid JSON in settings.json"
exit 1
fi
HOOKS=$(jq -r '.hooks // {} | keys[]' ~/.claude/settings.json 2>/dev/null)
if [ -z "$HOOKS" ]; then
echo "INFO: No hooks configured"
else
echo "Configured hooks:"
echo "$HOOKS" | while read hook; do
echo " - $hook"
EVENT=$(jq -r ".hooks.\"$hook\".event // \"\"" ~/.claude/settings.json)
COMMAND=$(jq -r ".hooks.\"$hook\".command // \"\"" ~/.claude/settings.json)
if [ -z "$EVENT" ]; then
echo " ERROR: Missing 'event' field"
fi
if [ -z "$COMMAND" ]; then
echo " ERROR: Missing 'command' field"
fi
case "$EVENT" in
UserPromptSubmit|PreToolUse|PostToolUse|SessionStart)
echo " PASS: Valid event type ($EVENT)"
;;
*)
echo " WARN: Unknown event type ($EVENT)"
;;
esac
CMD_FIRST=$(echo "$COMMAND" | awk '{print $1}')
if ! command -v "$CMD_FIRST" >/dev/null 2>&1; then
echo " WARN: Command not found in PATH: $CMD_FIRST"
fi
done
fi
echo ""
Hooks Checklist:
Step 6: Generate Report
Create comprehensive audit report:
#!/bin/bash
REPORT_FILE="component-audit-$(date +%Y%m%d).md"
cat > "$REPORT_FILE" <<EOF
# Claude Code Component Audit Report
Generated: $(date +"%Y-%m-%d %H:%M:%S")
## Summary
| Component | Total | Pass | Warn | Fail |
|-----------|-------|------|------|------|
| Agents | $AGENT_TOTAL | $AGENT_PASS | $AGENT_WARN | $AGENT_FAIL |
| Skills | $SKILL_TOTAL | $SKILL_PASS | $SKILL_WARN | $SKILL_FAIL |
| Commands | $CMD_TOTAL | $CMD_PASS | $CMD_WARN | $CMD_FAIL |
| Hooks | $HOOK_TOTAL | $HOOK_PASS | $HOOK_WARN | $HOOK_FAIL |
## Agents
$(cat /tmp/agent-audit.log)
## Skills
$(cat /tmp/skill-audit.log)
## Commands
$(cat /tmp/command-audit.log)
## Hooks
$(cat /tmp/hook-audit.log)
## Recommendations
$(generate_recommendations)
## Quick Fixes
To fix common issues:
1. Missing frontmatter: Add YAML frontmatter with --- delimiters
2. Placeholder text: Search for {{ and replace with actual content
3. Non-executable scripts: Run chmod +x on script files
4. Invalid JSON: Use jq to validate and format settings.json
EOF
echo "Report generated: $REPORT_FILE"
Severity Levels
PASS - Meets all requirements, no action needed
WARN - Works but improvable, review when possible
- Descriptions too short/long
- Missing optional sections
- Style inconsistencies
ERROR - Missing requirements, fix before using
- Missing required frontmatter fields
- Invalid JSON syntax
- Placeholder text remains
- Broken file structure
INFO - Informational notices
- Uses advanced features
- Has bundled resources
- Configuration notes
Best Practices
- Run audit before commits - Catch issues early
- Fix errors immediately - Don't commit broken components
- Address warnings gradually - Improve quality over time
- Update templates - Keep templates current with best practices
- Document exceptions - Note when deviations are intentional
Output Format
Provide structured audit summary:
# Component Audit Report
Date: YYYY-MM-DD HH:MM
## Executive Summary
Total components: 87
Status: 73 PASS, 12 WARN, 2 FAIL
Overall health: Good
## Critical Issues (Fix Immediately)
1. agents/broken-agent.md - Missing 'tools' field
2. skills/incomplete-skill/SKILL.md - Contains placeholder text
## Warnings (Review Soon)
1. agents/verbose-agent.md - Description too long (420 chars)
2. skills/large-skill/SKILL.md - Over 5000 words, needs references/
3. commands/setup/long-cmd.md - Missing workflow section
## Recommendations
1. Add frontmatter to 2 agents missing it
2. Move skill content to references/ for 3 large skills
3. Fix JSON formatting in settings.json
4. Make 5 scripts executable (chmod +x)
## Next Steps
1. Fix critical issues this session
2. Address warnings in next sprint
3. Update component templates
4. Schedule monthly audits
## Detailed Results
Saved to: ~/logs/dot-claude/component-audit-YYYYMMDD.log
Remember
The goal is to maintain high-quality, consistent components across the workspace. Regular audits prevent technical debt and ensure components work as expected. Fix critical issues immediately, address warnings gradually, and use audits as learning opportunities to improve component creation skills.