Optimize and validate Claude skill files
Analyzes and optimizes Claude skill files for performance and compliance with official best practices.
/plugin marketplace add lenneTech/claude-code/plugin install lt-dev@lenne-techAnalyze and optimize skill files for better Claude Code performance and compliance with official best practices.
** MANDATORY: Execute this step FIRST at every invocation!**
Use WebFetch to download current official requirements:
https://code.claude.com/docs/en/skills
Extract and analyze:
Run automated validation checks on all skills in plugins/lt-dev/skills/:
Check required YAML frontmatter fields:
echo "=== Frontmatter Validation ==="
for skill in plugins/lt-dev/skills/*/SKILL.md; do
name=$(basename $(dirname "$skill"))
echo "--- $name ---"
# Check name field
skill_name=$(grep "^name:" "$skill" | cut -d: -f2 | tr -d ' ')
if [ -n "$skill_name" ]; then
# Validate format: lowercase, numbers, hyphens only, max 64 chars
if echo "$skill_name" | grep -qE '^[a-z0-9-]+$'; then
len=${#skill_name}
if [ "$len" -le 64 ]; then
echo " name: $skill_name ($len chars)"
else
echo " name: $skill_name (TOO LONG: $len chars, max 64)"
fi
else
echo " name: $skill_name (INVALID: use lowercase, numbers, hyphens only)"
fi
# Check for reserved words
if echo "$skill_name" | grep -qE '(anthropic|claude)'; then
echo " WARNING: name contains reserved word"
fi
else
echo " name: MISSING"
fi
# Check description field
desc=$(grep "^description:" "$skill" | cut -d: -f2-)
if [ -n "$desc" ]; then
desc_len=${#desc}
if [ "$desc_len" -le 1024 ]; then
echo " description: $desc_len chars"
# Check for first/second person (should be third person)
if echo "$desc" | grep -qiE '\b(I|you|your|my)\b'; then
echo " WARNING: description uses first/second person (should be third person)"
fi
# Check for vagueness
if echo "$desc" | grep -qiE '\b(helps|processes|manages|handles)\s+(with|data|files)?\s*$'; then
echo " WARNING: description may be too vague (add specifics and trigger terms)"
fi
else
echo " description: TOO LONG ($desc_len chars, max 1024)"
fi
else
echo " description: MISSING"
fi
echo ""
done
Validation criteria:
name exists, lowercase/numbers/hyphens only, max 64 charsname doesn't contain reserved words ("anthropic", "claude")description exists, max 1024 charsdescription in third person (not "I" or "you")description includes specific actions and trigger termsOfficial guideline: SKILL.md body < 500 lines
echo "=== File Size Validation ==="
for skill in plugins/lt-dev/skills/*/SKILL.md; do
name=$(basename $(dirname "$skill"))
# Count body lines (excluding frontmatter)
frontmatter_end=$(grep -n "^---$" "$skill" | tail -1 | cut -d: -f1)
body_lines=$(tail -n +$((frontmatter_end + 1)) "$skill" | wc -l)
printf "%-30s %5d lines " "$name:" "$body_lines"
if [ "$body_lines" -lt 500 ]; then
echo " OPTIMAL"
elif [ "$body_lines" -lt 800 ]; then
echo " ACCEPTABLE (consider optimization)"
else
echo " TOO LARGE (needs optimization)"
fi
done
Size targets:
Official requirement: One-level-deep references only
echo "=== Progressive Disclosure Check ==="
for skill_dir in plugins/lt-dev/skills/*/; do
skill_name=$(basename "$skill_dir")
echo "=== $skill_name ==="
# Count reference files (one level deep)
ref_files=$(find "$skill_dir" -maxdepth 1 -name "*.md" ! -name "SKILL.md")
ref_count=$(echo "$ref_files" | grep -c ".")
if [ "$ref_count" -gt 0 ]; then
echo " Reference files: $ref_count"
echo "$ref_files" | while read -r file; do
filename=$(basename "$file")
lines=$(wc -l < "$file")
# Check if file > 100 lines should have TOC
if [ "$lines" -gt 100 ]; then
if grep -q "^## Table of Contents" "$file" || grep -q "^# Table of Contents" "$file"; then
echo " $filename ($lines lines, has TOC)"
else
echo " $filename ($lines lines, needs TOC)"
fi
else
echo " $filename ($lines lines)"
fi
done
else
echo " Reference files: 0"
fi
# Check for nested files (anti-pattern)
nested=$(find "$skill_dir" -mindepth 2 -name "*.md" 2>/dev/null)
if [ -n "$nested" ]; then
echo " WARNING: Nested files found (avoid deep nesting):"
echo "$nested" | sed 's/^/ /'
fi
# Check for Windows-style paths in SKILL.md
if grep -q '\\' "$skill_dir/SKILL.md"; then
echo " WARNING: Windows-style backslashes found (use forward slashes)"
fi
echo ""
done
Rules:
doc1.md, utils.md)Recommended: Gerund form (processing-pdfs, analyzing-data)
echo "=== Naming Convention Check ==="
for skill in plugins/lt-dev/skills/*/SKILL.md; do
skill_name=$(grep "^name:" "$skill" | cut -d: -f2 | tr -d ' ')
# Check if gerund form (-ing)
if echo "$skill_name" | grep -qE -- '-(ing|izing|ising)(-|$)'; then
echo " $skill_name (gerund form - recommended)"
# Check if action-oriented
elif echo "$skill_name" | grep -qE '^(process|analyze|manage|generate|create|build|test)-'; then
echo " $skill_name (action-oriented - acceptable)"
# Check if noun phrase
elif echo "$skill_name" | grep -qE -- '-ing$'; then
echo " $skill_name (noun phrase with -ing - acceptable)"
else
# Check for anti-patterns
if echo "$skill_name" | grep -qE '^(helper|utils|tools|common)'; then
echo " $skill_name (VAGUE: avoid helper/utils/tools)"
else
echo " $skill_name (consider gerund form: ${skill_name}ing or processing-${skill_name})"
fi
fi
done
echo "=== Content Quality Scan ==="
for skill in plugins/lt-dev/skills/*/SKILL.md; do
name=$(basename $(dirname "$skill"))
echo "--- $name ---"
# Check for common anti-patterns
if grep -qi "magic number" "$skill"; then
echo " Uses term 'magic number' - ensure values are justified"
fi
if grep -qE '\b(TODO|FIXME|XXX)\b' "$skill"; then
echo " Contains TODO/FIXME markers"
fi
if grep -q "as of [0-9][0-9][0-9][0-9]" "$skill"; then
echo " Contains time-sensitive information (use 'old patterns' section)"
fi
# Check for inconsistent terminology
if grep -qi "repository" "$skill" && grep -qi "repo" "$skill"; then
echo " Inconsistent terminology: 'repository' and 'repo' both used"
fi
echo ""
done
Cross-reference validation results with the best practices document from Step 1:
If official guidelines have changed, update validation criteria accordingly.
For skills > 500 lines, perform extraction:
# Analyze section sizes in oversized SKILL.md
awk '/^## / {
if (prev) print prev " " NR-start " lines"
prev=$0
start=NR
}
END {
if (prev) print prev " " NR-start " lines"
}' SKILL.md | sort -t' ' -k3 -rn
Candidates for extraction (> 100 lines):
1. Create reference file:
---
name: skill-name-topic
description: Detailed [topic] for skill-name skill
---
# [Topic Title]
## Table of Contents
(If file > 100 lines, REQUIRED)
[Content extracted from SKILL.md]
2. Replace in SKILL.md:
## [Topic]
** Complete [topic] details: `topic-name.md`**
**Quick overview:**
- Essential point 1
- Essential point 2
- Essential point 3
**Critical checklist:**
- [ ] Must-know item 1
- [ ] Must-know item 2
Keep in SKILL.md:
Extract to separate files:
echo "=================================="
echo " Skill Validation Report"
echo "=================================="
echo ""
echo " Summary:"
total=$(find src/templates/claude-skills -name "SKILL.md" | wc -l)
echo "Total skills validated: $total"
echo ""
echo " Size Distribution:"
optimal=0
acceptable=0
too_large=0
for skill in plugins/lt-dev/skills/*/SKILL.md; do
frontmatter_end=$(grep -n "^---$" "$skill" | tail -1 | cut -d: -f1)
body_lines=$(tail -n +$((frontmatter_end + 1)) "$skill" | wc -l)
if [ "$body_lines" -lt 500 ]; then
optimal=$((optimal + 1))
elif [ "$body_lines" -lt 800 ]; then
acceptable=$((acceptable + 1))
else
too_large=$((too_large + 1))
fi
done
echo " Optimal (< 500 lines): $optimal"
echo " Acceptable (500-800): $acceptable"
echo " Too large (> 800): $too_large"
echo ""
echo " Frontmatter Compliance:"
complete=0
incomplete=0
for skill in plugins/lt-dev/skills/*/SKILL.md; do
if grep -q "^name:" "$skill" && grep -q "^description:" "$skill"; then
complete=$((complete + 1))
else
incomplete=$((incomplete + 1))
fi
done
echo " Complete: $complete"
echo " Incomplete: $incomplete"
echo ""
echo " Issues Requiring Attention:"
for skill in plugins/lt-dev/skills/*/SKILL.md; do
name=$(basename $(dirname "$skill"))
issues=""
# Check size
frontmatter_end=$(grep -n "^---$" "$skill" | tail -1 | cut -d: -f1)
body_lines=$(tail -n +$((frontmatter_end + 1)) "$skill" | wc -l)
if [ "$body_lines" -gt 800 ]; then
issues="${issues}- Size: $body_lines lines (optimize)\n"
fi
# Check frontmatter
if ! grep -q "^name:" "$skill"; then
issues="${issues}- Missing 'name' field\n"
fi
if ! grep -q "^description:" "$skill"; then
issues="${issues}- Missing 'description' field\n"
fi
# Check naming
skill_name=$(grep "^name:" "$skill" | cut -d: -f2 | tr -d ' ')
if echo "$skill_name" | grep -qE '^(helper|utils|tools)'; then
issues="${issues}- Vague name: $skill_name\n"
fi
if [ -n "$issues" ]; then
echo ""
echo "$name:"
echo -e "$issues"
fi
done
echo ""
echo "=================================="
echo " Validation Complete"
echo "=================================="
Based on validation, create specific action items for each skill needing work:
Priority 1 (Critical):
800 lines → Extract content
Priority 2 (Important):
Priority 3 (Nice to have):
Before completing, verify:
Official documentation:
For autonomous execution:
For interactive use:
Success indicators: