|
| 1 | +#!/bin/bash |
| 2 | +# Agent Skeleton Generator |
| 3 | +# Creates a new agent file with correct structure |
| 4 | + |
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +# Usage |
| 8 | +if [ $# -eq 0 ]; then |
| 9 | + echo "Usage: $0 <agent-name> [output-dir]" |
| 10 | + echo "" |
| 11 | + echo "Creates a skeleton agent file with:" |
| 12 | + echo " - Valid YAML frontmatter" |
| 13 | + echo " - Placeholder description with example block" |
| 14 | + echo " - Basic system prompt structure" |
| 15 | + echo "" |
| 16 | + echo "Arguments:" |
| 17 | + echo " agent-name Agent identifier (lowercase, numbers, hyphens)" |
| 18 | + echo " output-dir Directory to create file in (default: current directory)" |
| 19 | + echo "" |
| 20 | + echo "Examples:" |
| 21 | + echo " $0 code-reviewer agents/" |
| 22 | + echo " $0 test-generator" |
| 23 | + echo "" |
| 24 | + echo "After creation:" |
| 25 | + echo " 1. Edit the file to fill in placeholders" |
| 26 | + echo " 2. Add 2-4 triggering examples" |
| 27 | + echo " 3. Write detailed system prompt" |
| 28 | + echo " 4. Validate: ./scripts/validate-agent.sh <output-file>" |
| 29 | + echo " 5. Test triggers: ./scripts/test-agent-trigger.sh <output-file>" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +AGENT_NAME="$1" |
| 34 | +OUTPUT_DIR="${2:-.}" |
| 35 | +OUTPUT_FILE="$OUTPUT_DIR/$AGENT_NAME.md" |
| 36 | + |
| 37 | +echo "🔍 Creating agent skeleton: $AGENT_NAME" |
| 38 | +echo "" |
| 39 | + |
| 40 | +# Validate name format (lowercase alphanumeric + hyphens, 3-50 chars) |
| 41 | +if ! [[ "$AGENT_NAME" =~ ^[a-z0-9][a-z0-9-]*[a-z0-9]$ ]]; then |
| 42 | + echo "❌ Invalid name: $AGENT_NAME" |
| 43 | + echo "" |
| 44 | + echo "Agent names must:" |
| 45 | + echo " - Start with a lowercase letter or number" |
| 46 | + echo " - End with a lowercase letter or number" |
| 47 | + echo " - Contain only lowercase letters, numbers, and hyphens" |
| 48 | + echo " - Be at least 3 characters long" |
| 49 | + echo "" |
| 50 | + echo "Valid examples: code-reviewer, test-gen, my-agent-123" |
| 51 | + echo "Invalid examples: Code-Reviewer, -agent, agent-, a" |
| 52 | + exit 1 |
| 53 | +fi |
| 54 | +echo "✅ Name format valid" |
| 55 | + |
| 56 | +# Validate name length |
| 57 | +name_length=${#AGENT_NAME} |
| 58 | +if [ "$name_length" -lt 3 ]; then |
| 59 | + echo "❌ Name too short: $name_length characters (minimum 3)" |
| 60 | + exit 1 |
| 61 | +fi |
| 62 | +if [ "$name_length" -gt 50 ]; then |
| 63 | + echo "❌ Name too long: $name_length characters (maximum 50)" |
| 64 | + exit 1 |
| 65 | +fi |
| 66 | +echo "✅ Name length valid ($name_length characters)" |
| 67 | + |
| 68 | +# Check output directory exists |
| 69 | +if [ ! -d "$OUTPUT_DIR" ]; then |
| 70 | + echo "❌ Directory does not exist: $OUTPUT_DIR" |
| 71 | + echo "" |
| 72 | + echo "Create it first with: mkdir -p $OUTPUT_DIR" |
| 73 | + exit 1 |
| 74 | +fi |
| 75 | +echo "✅ Output directory exists" |
| 76 | + |
| 77 | +# Check file doesn't already exist |
| 78 | +if [ -f "$OUTPUT_FILE" ]; then |
| 79 | + echo "❌ File already exists: $OUTPUT_FILE" |
| 80 | + echo "" |
| 81 | + echo "Options:" |
| 82 | + echo " - Choose a different name" |
| 83 | + echo " - Delete the existing file: rm $OUTPUT_FILE" |
| 84 | + echo " - Edit the existing file directly" |
| 85 | + exit 1 |
| 86 | +fi |
| 87 | +echo "✅ Output path available" |
| 88 | + |
| 89 | +echo "" |
| 90 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 91 | +echo "📝 Creating agent file..." |
| 92 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 93 | +echo "" |
| 94 | + |
| 95 | +# Create the agent skeleton file |
| 96 | +cat > "$OUTPUT_FILE" << EOF |
| 97 | +--- |
| 98 | +name: $AGENT_NAME |
| 99 | +description: Use this agent when [describe triggering conditions]. Examples: |
| 100 | +
|
| 101 | +<example> |
| 102 | +Context: [Describe the situation] |
| 103 | +user: "[What the user says]" |
| 104 | +assistant: "[How Claude responds before triggering]" |
| 105 | +<commentary> |
| 106 | +[Why this agent should trigger] |
| 107 | +</commentary> |
| 108 | +assistant: "I'll use the $AGENT_NAME agent to [action]." |
| 109 | +</example> |
| 110 | +
|
| 111 | +<example> |
| 112 | +Context: [Second example situation] |
| 113 | +user: "[Another user request]" |
| 114 | +assistant: "[Claude's response]" |
| 115 | +<commentary> |
| 116 | +[Explanation of why this triggers the agent] |
| 117 | +</commentary> |
| 118 | +</example> |
| 119 | +
|
| 120 | +model: inherit |
| 121 | +color: blue |
| 122 | +--- |
| 123 | +
|
| 124 | +You are [describe the agent's role and expertise]. |
| 125 | +
|
| 126 | +**Your Core Responsibilities:** |
| 127 | +
|
| 128 | +1. [Primary responsibility] |
| 129 | +2. [Secondary responsibility] |
| 130 | +3. [Additional responsibility] |
| 131 | +
|
| 132 | +**Process:** |
| 133 | +
|
| 134 | +1. [First step] |
| 135 | +2. [Second step] |
| 136 | +3. [Third step] |
| 137 | +
|
| 138 | +**Quality Standards:** |
| 139 | +
|
| 140 | +- [Standard 1] |
| 141 | +- [Standard 2] |
| 142 | +- [Standard 3] |
| 143 | +
|
| 144 | +**Output Format:** |
| 145 | +
|
| 146 | +Provide results as: |
| 147 | +
|
| 148 | +- [What to include] |
| 149 | +- [How to structure] |
| 150 | +EOF |
| 151 | + |
| 152 | +echo "✅ Created agent skeleton: $OUTPUT_FILE" |
| 153 | +echo "" |
| 154 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 155 | +echo "📋 Next Steps" |
| 156 | +echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 157 | +echo "" |
| 158 | +echo "1. Edit the file to fill in placeholders:" |
| 159 | +echo " - Replace [bracketed text] with actual content" |
| 160 | +echo " - Update description to explain when agent triggers" |
| 161 | +echo " - Write 2-4 triggering examples" |
| 162 | +echo " - Develop detailed system prompt" |
| 163 | +echo "" |
| 164 | +echo "2. Choose appropriate settings:" |
| 165 | +echo " - model: inherit (default), sonnet, opus, or haiku" |
| 166 | +echo " - color: blue (default), cyan, green, yellow, magenta, or red" |
| 167 | +echo " - tools: Add array if restricting tools (optional)" |
| 168 | +echo "" |
| 169 | +echo "3. Validate the agent:" |
| 170 | +echo " ./scripts/validate-agent.sh $OUTPUT_FILE" |
| 171 | +echo "" |
| 172 | +echo "4. Test triggering:" |
| 173 | +echo " ./scripts/test-agent-trigger.sh $OUTPUT_FILE" |
| 174 | +echo "" |
| 175 | +echo "5. Load in Claude Code:" |
| 176 | +echo " cc --plugin-dir /path/to/plugin" |
0 commit comments