Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Claude Code agentic coding tool โ terminal-based assistant for coding, git workflows, and codebase understanding.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/validate-agent.sh
1#!/bin/bash2# Agent File Validator3# Validates agent markdown files for correct structure and content45set -euo pipefail67# Usage8if [ $# -eq 0 ]; then9echo "Usage: $0 <path/to/agent.md>"10echo ""11echo "Validates agent file for:"12echo " - YAML frontmatter structure"13echo " - Required fields (name, description, model, color)"14echo " - Field formats and constraints"15echo " - System prompt presence and length"16echo " - Example blocks in description"17exit 118fi1920AGENT_FILE="$1"2122echo "๐ Validating agent file: $AGENT_FILE"23echo ""2425# Check 1: File exists26if [ ! -f "$AGENT_FILE" ]; then27echo "โ File not found: $AGENT_FILE"28exit 129fi30echo "โ File exists"3132# Check 2: Starts with ---33FIRST_LINE=$(head -1 "$AGENT_FILE")34if [ "$FIRST_LINE" != "---" ]; then35echo "โ File must start with YAML frontmatter (---)"36exit 137fi38echo "โ Starts with frontmatter"3940# Check 3: Has closing ---41if ! tail -n +2 "$AGENT_FILE" | grep -q '^---$'; then42echo "โ Frontmatter not closed (missing second ---)"43exit 144fi45echo "โ Frontmatter properly closed"4647# Extract frontmatter and system prompt48FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$AGENT_FILE")49SYSTEM_PROMPT=$(awk '/^---$/{i++; next} i>=2' "$AGENT_FILE")5051# Check 4: Required fields52echo ""53echo "Checking required fields..."5455error_count=056warning_count=05758# Check name field59NAME=$(echo "$FRONTMATTER" | grep '^name:' | sed 's/name: *//' | sed 's/^"\(.*\)"$/\1/')6061if [ -z "$NAME" ]; then62echo "โ Missing required field: name"63((error_count++))64else65echo "โ name: $NAME"6667# Validate name format68if ! [[ "$NAME" =~ ^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$ ]]; then69echo "โ name must start/end with alphanumeric and contain only letters, numbers, hyphens"70((error_count++))71fi7273# Validate name length74name_length=${#NAME}75if [ $name_length -lt 3 ]; then76echo "โ name too short (minimum 3 characters)"77((error_count++))78elif [ $name_length -gt 50 ]; then79echo "โ name too long (maximum 50 characters)"80((error_count++))81fi8283# Check for generic names84if [[ "$NAME" =~ ^(helper|assistant|agent|tool)$ ]]; then85echo "โ ๏ธ name is too generic: $NAME"86((warning_count++))87fi88fi8990# Check description field91DESCRIPTION=$(echo "$FRONTMATTER" | grep '^description:' | sed 's/description: *//')9293if [ -z "$DESCRIPTION" ]; then94echo "โ Missing required field: description"95((error_count++))96else97desc_length=${#DESCRIPTION}98echo "โ description: ${desc_length} characters"99100if [ $desc_length -lt 10 ]; then101echo "โ ๏ธ description too short (minimum 10 characters recommended)"102((warning_count++))103elif [ $desc_length -gt 5000 ]; then104echo "โ ๏ธ description very long (over 5000 characters)"105((warning_count++))106fi107108# Check for example blocks109if ! echo "$DESCRIPTION" | grep -q '<example>'; then110echo "โ ๏ธ description should include <example> blocks for triggering"111((warning_count++))112fi113114# Check for "Use this agent when" pattern115if ! echo "$DESCRIPTION" | grep -qi 'use this agent when'; then116echo "โ ๏ธ description should start with 'Use this agent when...'"117((warning_count++))118fi119fi120121# Check model field122MODEL=$(echo "$FRONTMATTER" | grep '^model:' | sed 's/model: *//')123124if [ -z "$MODEL" ]; then125echo "โ Missing required field: model"126((error_count++))127else128echo "โ model: $MODEL"129130case "$MODEL" in131inherit|sonnet|opus|haiku)132# Valid model133;;134*)135echo "โ ๏ธ Unknown model: $MODEL (valid: inherit, sonnet, opus, haiku)"136((warning_count++))137;;138esac139fi140141# Check color field142COLOR=$(echo "$FRONTMATTER" | grep '^color:' | sed 's/color: *//')143144if [ -z "$COLOR" ]; then145echo "โ Missing required field: color"146((error_count++))147else148echo "โ color: $COLOR"149150case "$COLOR" in151blue|cyan|green|yellow|magenta|red)152# Valid color153;;154*)155echo "โ ๏ธ Unknown color: $COLOR (valid: blue, cyan, green, yellow, magenta, red)"156((warning_count++))157;;158esac159fi160161# Check tools field (optional)162TOOLS=$(echo "$FRONTMATTER" | grep '^tools:' | sed 's/tools: *//')163164if [ -n "$TOOLS" ]; then165echo "โ tools: $TOOLS"166else167echo "๐ก tools: not specified (agent has access to all tools)"168fi169170# Check 5: System prompt171echo ""172echo "Checking system prompt..."173174if [ -z "$SYSTEM_PROMPT" ]; then175echo "โ System prompt is empty"176((error_count++))177else178prompt_length=${#SYSTEM_PROMPT}179echo "โ System prompt: $prompt_length characters"180181if [ $prompt_length -lt 20 ]; then182echo "โ System prompt too short (minimum 20 characters)"183((error_count++))184elif [ $prompt_length -gt 10000 ]; then185echo "โ ๏ธ System prompt very long (over 10,000 characters)"186((warning_count++))187fi188189# Check for second person190if ! echo "$SYSTEM_PROMPT" | grep -q "You are\|You will\|Your"; then191echo "โ ๏ธ System prompt should use second person (You are..., You will...)"192((warning_count++))193fi194195# Check for structure196if ! echo "$SYSTEM_PROMPT" | grep -qi "responsibilities\|process\|steps"; then197echo "๐ก Consider adding clear responsibilities or process steps"198fi199200if ! echo "$SYSTEM_PROMPT" | grep -qi "output"; then201echo "๐ก Consider defining output format expectations"202fi203fi204205echo ""206echo "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ"207208if [ $error_count -eq 0 ] && [ $warning_count -eq 0 ]; then209echo "โ All checks passed!"210exit 0211elif [ $error_count -eq 0 ]; then212echo "โ ๏ธ Validation passed with $warning_count warning(s)"213exit 0214else215echo "โ Validation failed with $error_count error(s) and $warning_count warning(s)"216exit 1217fi218