alirezarezvani/claude-code-skill-factory / generated-skills/slash-command-factory
slash-command-factory
VerifiedGenerate custom Claude Code slash commands through intelligent 5-7 question flow. Creates powerful commands for business research, content analysis, healthcare compliance, API integration, documentation automation, and workflow optimization. Outputs organized commands to generated-commands/ with validation and installation guidance.
| File | Kind | Size |
|---|---|---|
| HOW_TO_USE.md | markdown | 4.3 KB |
| SKILL.md | skill md | 23.9 KB |
| command_generator.py | script | 12.3 KB |
| expected_output.json | config | 1.1 KB |
| presets.json | config | 24.5 KB |
| sample_input.json | config | 276 B |
| validator.py | script | 10.9 KB |
validator.py
View on GitHub"""
Slash Command Validator
Validates generated slash command files for proper format.
Enforces official Anthropic patterns and best practices.
"""
import re
import os
from typing import Dict, List, Any
class CommandValidator:
"""Validate slash command .md files."""
def validate(self, command_content: str) -> Dict[str, any]:
"""
Validate complete command file content.
Args:
command_content: Full .md file content
Returns:
Dict with validation results
"""
issues = []
# Check YAML frontmatter
yaml_valid, yaml_issues = self._check_yaml_frontmatter(command_content)
if not yaml_valid:
issues.extend(yaml_issues)
# Check argument syntax
args_valid, args_issues = self._check_arguments(command_content)
if not args_valid:
issues.extend(args_issues)
# Check allowed-tools format
tools_valid, tools_issues = self._check_allowed_tools(command_content)
if not tools_valid:
issues.extend(tools_issues)
return {
'valid': len(issues) == 0,
'issues': issues
}
def _check_yaml_frontmatter(self, content: str) -> tuple:
"""Check YAML frontmatter is present and valid."""
issues = []
# Check starts with ---
if not content.strip().startswith('---'):
issues.append("Missing YAML frontmatter opening (---)")
return False, issues
# Extract frontmatter
parts = content.split('---')
if len(parts) < 3:
issues.append("YAML frontmatter not properly closed")
return False, issues
frontmatter = parts[1]
# Check required fields
if 'description:' not in frontmatter:
issues.append("Missing required 'description' field in YAML")
return len(issues) == 0, issues
def _check_arguments(self, content: str) -> tuple:
"""
Check argument usage is correct.
Commands should use $ARGUMENTS (not $1, $2, $3).
"""
issues = []
# Check for positional arguments (not allowed)
if re.search(r'\$[0-9]', content):
issues.append("Found positional arguments ($1, $2, etc.). Use $ARGUMENTS instead.")
# If uses $ARGUMENTS, should have argument-hint
if '$ARGUMENTS' in content:
if 'argument-hint:' not in content:
issues.append("Command uses $ARGUMENTS but missing 'argument-hint' in YAML")
return len(issues) == 0, issues
def _check_allowed_tools(self, content: str) -> tuple:
"""Check allowed-tools format is correct."""
issues = []
# Extract frontmatter
if '---' not in content:
return True, [] # Already caught in YAML check
parts = content.split('---')
if len(parts) < 2:
return True, []
frontmatter = parts[1]
# If has allowed-tools, validate format
if 'allowed-tools:' in frontmatter:
# Extract the tools line
for line in frontmatter.split('\n'):
if 'allowed-tools:' in line:
tools_part = line.split('allowed-tools:')[1].strip()
# Valid tools
valid_tools = ['Read', 'Write', 'Edit', 'Bash', 'Grep', 'Glob', 'Task', 'TodoWrite', 'Skill', 'SlashCommand']
# Check comma-separated
if ',' in tools_part or any(tool in tools_part for tool in valid_tools):
# Format looks okay
pass
else:
issues.append("allowed-tools should be comma-separated list")
return len(issues) == 0, issues
def validate_folder_structure(self, folder_path: str) -> Dict[str, Any]:
"""
Validate command folder organization.
Args:
folder_path: Path to generated command folder
Returns:
Validation results
"""
issues = []
if not os.path.exists(folder_path):
issues.append(f"Folder not found: {folder_path}")
return {'valid': False, 'issues': issues}
# Check .md files are in root (not in subfolders)
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)
# Should be in root of folder
if root != folder_path:
issues.append(f".md file in subfolder (should be in root): {file}")
# Check folders are properly separated
subfolders = [d for d in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, d))]
# Valid folder names
valid_folders = ['standards', 'examples', 'scripts']
for folder in subfolders:
if folder not in valid_folders:
issues.append(f"Unexpected folder: {folder} (valid: {valid_folders})")
return {
'valid': len(issues) == 0,
'issues': issues
}
def validate_bash_permissions(self, allowed_tools: str) -> Dict[str, Any]:
"""
Validate bash permissions are specific (not wildcards).
Official rule from Anthropic: NEVER use 'Bash' alone - always specify commands.
Args:
allowed_tools: The allowed-tools string from YAML
Returns:
Dict with validation results including errors and warnings
"""
if not allowed_tools:
return {'valid': True, 'errors': [], 'warnings': []}
errors = []
warnings = []
# Check for wildcard Bash (CRITICAL ERROR - not allowed)
# Must check if 'Bash' appears without parentheses
if re.search(r'\bBash\b(?!\()', allowed_tools):
errors.append("❌ CRITICAL: Wildcard 'Bash' not allowed per official patterns. Must specify exact commands: Bash(git status:*)")
# Extract bash commands
bash_commands = re.findall(r'Bash\(([^)]+)\)', allowed_tools)
# Validate each command against whitelist
valid_commands = [
'git', 'find', 'tree', 'ls', 'grep', 'wc', 'du',
'head', 'tail', 'cat', 'awk', 'sed', 'sort', 'uniq', 'touch'
]
for cmd in bash_commands:
base_cmd = cmd.split(':')[0].strip()
if base_cmd not in valid_commands:
warnings.append(f"⚠️ Command '{base_cmd}' not in official patterns. Verify necessity.")
return {
'valid': len(errors) == 0,
'errors': errors,
'warnings': warnings
}
def validate_command_name(self, name: str) -> Dict[str, Any]:
"""
Validate command name follows kebab-case convention.
Official rules from Anthropic docs:
- Must be kebab-case (lowercase with hyphens)
- Length: 2-4 words
- Characters: [a-z0-9-] only
- Must start and end with letter/number
Args:
name: Command name to validate
Returns:
Dict with validation results
"""
errors = []
# Check format (kebab-case with 2-4 words)
if not re.match(r'^[a-z0-9]+(-[a-z0-9]+){1,3}$', name):
errors.append(f"❌ Command name '{name}' must be kebab-case with 2-4 words (e.g., 'code-review')")
# Check length
word_count = len(name.split('-'))
if word_count < 2:
errors.append(f"❌ Command name too short: needs at least 2 words (e.g., 'api-build')")
elif word_count > 4:
errors.append(f"❌ Command name too long: maximum 4 words, found {word_count}")
# Check invalid characters
if re.search(r'[^a-z0-9-]', name):
errors.append(f"❌ Command name contains invalid characters. Use only [a-z0-9-]")
# Check for underscores (common mistake)
if '_' in name:
suggested = name.replace('_', '-')
errors.append(f"❌ Use hyphens not underscores. Try: '{suggested}'")
# Check for camelCase or PascalCase
if re.search(r'[A-Z]', name):
errors.append(f"❌ Command name must be lowercase only. No CamelCase or PascalCase.")
return {
'valid': len(errors) == 0,
'errors': errors
}
def validate_arguments_usage(self, command_content: str) -> Dict[str, Any]:
"""
Validate uses $ARGUMENTS (not $1, $2, $3).
Official pattern from Anthropic: All examples use $ARGUMENTS.
Args:
command_content: Full command file content
Returns:
Dict with validation results
"""
warnings = []
errors = []
# Check for positional arguments (CRITICAL - wrong pattern)
positional_matches = re.findall(r'\$[0-9]+', command_content)
if positional_matches:
errors.append(f"❌ Found positional arguments: {positional_matches}. Official pattern uses $ARGUMENTS")
# Check for $ARGUMENTS without argument-hint
if '$ARGUMENTS' in command_content and 'argument-hint:' not in command_content:
warnings.append("⚠️ Uses $ARGUMENTS but missing 'argument-hint' in YAML frontmatter")
return {
'valid': len(errors) == 0,
'errors': errors,
'warnings': warnings
}
def validate_comprehensive(self, command_name: str, command_content: str, allowed_tools: str) -> Dict[str, Any]:
"""
Run all validations comprehensively.
Args:
command_name: Name of the command
command_content: Full command file content
allowed_tools: The allowed-tools string
Returns:
Comprehensive validation results
"""
all_errors = []
all_warnings = []
# Validate command name
name_result = self.validate_command_name(command_name)
if not name_result['valid']:
all_errors.extend(name_result['errors'])
# Validate bash permissions
bash_result = self.validate_bash_permissions(allowed_tools)
if not bash_result['valid']:
all_errors.extend(bash_result['errors'])
all_warnings.extend(bash_result['warnings'])
# Validate arguments usage
args_result = self.validate_arguments_usage(command_content)
if not args_result['valid']:
all_errors.extend(args_result['errors'])
all_warnings.extend(args_result['warnings'])
# Run standard validation
standard_result = self.validate(command_content)
if not standard_result['valid']:
all_errors.extend(standard_result['issues'])
return {
'valid': len(all_errors) == 0,
'errors': all_errors,
'warnings': all_warnings,
'summary': f"{'✅ VALID' if len(all_errors) == 0 else '❌ INVALID'} - {len(all_errors)} errors, {len(all_warnings)} warnings"
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 470k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 197k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |