create-skill.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/bin/bash
  2. #
  3. # create-skill.sh - Production-grade Skill directory generator
  4. #
  5. # Usage: ./create-skill.sh <skill-name> [--minimal]
  6. #
  7. # Examples:
  8. # ./create-skill.sh postgresql
  9. # ./create-skill.sh my-api --minimal
  10. #
  11. set -e
  12. SKILL_NAME=$1
  13. MINIMAL=$2
  14. if [ -z "$SKILL_NAME" ]; then
  15. echo "Usage: ./create-skill.sh <skill-name> [--minimal]"
  16. echo ""
  17. echo "Examples:"
  18. echo " ./create-skill.sh postgresql"
  19. echo " ./create-skill.sh my-api --minimal"
  20. exit 1
  21. fi
  22. # Validate skill name (lowercase, hyphens only)
  23. if [[ ! "$SKILL_NAME" =~ ^[a-z][a-z0-9-]*$ ]]; then
  24. echo "Error: Skill name must be lowercase, start with letter, use hyphens"
  25. echo "Example: my-skill-name"
  26. exit 1
  27. fi
  28. echo "Creating skill: $SKILL_NAME"
  29. # Create directory structure
  30. mkdir -p "$SKILL_NAME"/{assets,scripts,references}
  31. # Create references/index.md
  32. cat > "$SKILL_NAME/references/index.md" << 'EOF'
  33. # Documentation Index
  34. ## Categories
  35. ### Getting Started
  36. - **getting_started.md** - Installation and setup
  37. ### API Reference
  38. - **api.md** - Complete API documentation
  39. ### Examples
  40. - **examples.md** - Code examples by use case
  41. ## Quick Links
  42. - Installation → `getting_started.md`
  43. - API Reference → `api.md`
  44. - Examples → `examples.md`
  45. EOF
  46. if [ "$MINIMAL" == "--minimal" ]; then
  47. # Minimal template
  48. cat > "$SKILL_NAME/SKILL.md" << EOF
  49. ---
  50. name: $SKILL_NAME
  51. description: [Domain] assistance including [key capability]. Use when [trigger condition].
  52. ---
  53. # ${SKILL_NAME^} Skill
  54. [One-sentence overview]
  55. ## When to Use This Skill
  56. This skill should be triggered when:
  57. - [Trigger 1]
  58. - [Trigger 2]
  59. - [Trigger 3]
  60. ## Quick Reference
  61. ### Common Patterns
  62. **Pattern 1:**
  63. \`\`\`
  64. [code]
  65. \`\`\`
  66. ## Resources
  67. ### references/
  68. Documentation files
  69. ### scripts/
  70. Helper scripts
  71. EOF
  72. else
  73. # Full production template
  74. cat > "$SKILL_NAME/SKILL.md" << EOF
  75. ---
  76. name: $SKILL_NAME
  77. description: [Domain] development including [capability 1], [capability 2]. Use when working with [domain], implementing solutions, or troubleshooting issues.
  78. ---
  79. # ${SKILL_NAME^} Skill
  80. Comprehensive assistance with [domain] development.
  81. ## When to Use This Skill
  82. This skill should be triggered when:
  83. - Working with [domain/technology]
  84. - Asking about [domain] features or APIs
  85. - Implementing [domain] solutions
  86. - Debugging [domain] code
  87. - Learning [domain] best practices
  88. ## Quick Reference
  89. ### Common Patterns
  90. **Pattern 1:** [Name]
  91. \`\`\`
  92. [code example]
  93. \`\`\`
  94. **Pattern 2:** [Name]
  95. \`\`\`
  96. [code example]
  97. \`\`\`
  98. ### Example Code Patterns
  99. **Example 1:**
  100. \`\`\`
  101. [complete working code]
  102. \`\`\`
  103. ## Reference Files
  104. This skill includes documentation in \`references/\`:
  105. - **index.md** - Documentation navigation
  106. - **getting_started.md** - Setup and basics
  107. - **api.md** - API reference
  108. - **examples.md** - Code examples
  109. ## Working with This Skill
  110. ### For Beginners
  111. Start with getting_started reference file.
  112. ### For Specific Features
  113. Use api reference for detailed information.
  114. ### For Code Examples
  115. See examples reference file.
  116. ## Resources
  117. ### references/
  118. Organized documentation from official sources.
  119. ### scripts/
  120. Helper scripts for automation.
  121. ### assets/
  122. Templates and configurations.
  123. ## Notes
  124. - Generated from official documentation
  125. - Code examples are complete and working
  126. EOF
  127. fi
  128. echo ""
  129. echo "✅ Created skill: $SKILL_NAME/"
  130. echo ""
  131. echo " $SKILL_NAME/"
  132. echo " ├── SKILL.md"
  133. echo " ├── assets/"
  134. echo " ├── scripts/"
  135. echo " └── references/"
  136. echo " └── index.md"
  137. echo ""
  138. echo "Next steps:"
  139. echo " 1. Edit $SKILL_NAME/SKILL.md"
  140. echo " 2. Add documentation to references/"
  141. echo " 3. Add helper scripts to scripts/"
  142. echo " 4. Add templates to assets/"