Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for developing custom slash commands for Claude Code plugins from the official Anthropic repository.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/plugin-commands.md
1# Plugin Command Examples23Practical examples of commands designed for Claude Code plugins, demonstrating plugin-specific patterns and features.45## Table of Contents671. [Simple Plugin Command](#1-simple-plugin-command)82. [Script-Based Analysis](#2-script-based-analysis)93. [Template-Based Generation](#3-template-based-generation)104. [Multi-Script Workflow](#4-multi-script-workflow)115. [Configuration-Driven Deployment](#5-configuration-driven-deployment)126. [Agent Integration](#6-agent-integration)137. [Skill Integration](#7-skill-integration)148. [Multi-Component Workflow](#8-multi-component-workflow)159. [Validated Input Command](#9-validated-input-command)1610. [Environment-Aware Command](#10-environment-aware-command)1718---1920## 1. Simple Plugin Command2122**Use case:** Basic command that uses plugin script2324**File:** `commands/analyze.md`2526```markdown27---28description: Analyze code quality using plugin tools29argument-hint: [file-path]30allowed-tools: Bash(node:*), Read31---3233Analyze @$1 using plugin's quality checker:3435!`node ${CLAUDE_PLUGIN_ROOT}/scripts/quality-check.js $1`3637Review the analysis output and provide:381. Summary of findings392. Priority issues to address403. Suggested improvements414. Code quality score interpretation42```4344**Key features:**45- Uses `${CLAUDE_PLUGIN_ROOT}` for portable path46- Combines file reference with script execution47- Simple single-purpose command4849---5051## 2. Script-Based Analysis5253**Use case:** Run comprehensive analysis using multiple plugin scripts5455**File:** `commands/full-audit.md`5657```markdown58---59description: Complete code audit using plugin suite60argument-hint: [directory]61allowed-tools: Bash(*)62model: sonnet63---6465Running complete audit on $1:6667**Security scan:**68!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/security-scan.sh $1`6970**Performance analysis:**71!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/perf-analyze.sh $1`7273**Best practices check:**74!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/best-practices.sh $1`7576Analyze all results and create comprehensive report including:77- Critical issues requiring immediate attention78- Performance optimization opportunities79- Security vulnerabilities and fixes80- Overall health score and recommendations81```8283**Key features:**84- Multiple script executions85- Organized output sections86- Comprehensive workflow87- Clear reporting structure8889---9091## 3. Template-Based Generation9293**Use case:** Generate documentation following plugin template9495**File:** `commands/gen-api-docs.md`9697```markdown98---99description: Generate API documentation from template100argument-hint: [api-file]101---102103Template structure: @${CLAUDE_PLUGIN_ROOT}/templates/api-documentation.md104105API implementation: @$1106107Generate complete API documentation following the template format above.108109Ensure documentation includes:110- Endpoint descriptions with HTTP methods111- Request/response schemas112- Authentication requirements113- Error codes and handling114- Usage examples with curl commands115- Rate limiting information116117Format output as markdown suitable for README or docs site.118```119120**Key features:**121- Uses plugin template122- Combines template with source file123- Standardized output format124- Clear documentation structure125126---127128## 4. Multi-Script Workflow129130**Use case:** Orchestrate build, test, and deploy workflow131132**File:** `commands/release.md`133134```markdown135---136description: Execute complete release workflow137argument-hint: [version]138allowed-tools: Bash(*), Read139---140141Executing release workflow for version $1:142143**Step 1 - Pre-release validation:**144!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/pre-release-check.sh $1`145146**Step 2 - Build artifacts:**147!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/build-release.sh $1`148149**Step 3 - Run test suite:**150!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/run-tests.sh`151152**Step 4 - Package release:**153!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/package.sh $1`154155Review all step outputs and report:1561. Any failures or warnings1572. Build artifacts location1583. Test results summary1594. Next steps for deployment1605. Rollback plan if needed161```162163**Key features:**164- Multi-step workflow165- Sequential script execution166- Clear step numbering167- Comprehensive reporting168169---170171## 5. Configuration-Driven Deployment172173**Use case:** Deploy using environment-specific plugin configuration174175**File:** `commands/deploy.md`176177```markdown178---179description: Deploy application to environment180argument-hint: [environment]181allowed-tools: Read, Bash(*)182---183184Deployment configuration for $1: @${CLAUDE_PLUGIN_ROOT}/config/$1-deploy.json185186Current git state: !`git rev-parse --short HEAD`187188Build info: !`cat package.json | grep -E '(name|version)'`189190Execute deployment to $1 environment using configuration above.191192Deployment checklist:1931. Validate configuration settings1942. Build application for $11953. Run pre-deployment tests1964. Deploy to target environment1975. Run smoke tests1986. Verify deployment success1997. Update deployment log200201Report deployment status and any issues encountered.202```203204**Key features:**205- Environment-specific configuration206- Dynamic config file loading207- Pre-deployment validation208- Structured checklist209210---211212## 6. Agent Integration213214**Use case:** Command that launches plugin agent for complex task215216**File:** `commands/deep-review.md`217218```markdown219---220description: Deep code review using plugin agent221argument-hint: [file-or-directory]222---223224Initiate comprehensive code review of @$1 using the code-reviewer agent.225226The agent will perform:2271. **Static analysis** - Check for code smells and anti-patterns2282. **Security audit** - Identify potential vulnerabilities2293. **Performance review** - Find optimization opportunities2304. **Best practices** - Ensure code follows standards2315. **Documentation check** - Verify adequate documentation232233The agent has access to:234- Plugin's linting rules: ${CLAUDE_PLUGIN_ROOT}/config/lint-rules.json235- Security checklist: ${CLAUDE_PLUGIN_ROOT}/checklists/security.md236- Performance guidelines: ${CLAUDE_PLUGIN_ROOT}/docs/performance.md237238Note: This uses the Task tool to launch the plugin's code-reviewer agent for thorough analysis.239```240241**Key features:**242- Delegates to plugin agent243- Documents agent capabilities244- References plugin resources245- Clear scope definition246247---248249## 7. Skill Integration250251**Use case:** Command that leverages plugin skill for specialized knowledge252253**File:** `commands/document-api.md`254255```markdown256---257description: Document API following plugin standards258argument-hint: [api-file]259---260261API source code: @$1262263Generate API documentation following the plugin's API documentation standards.264265Use the api-documentation-standards skill to ensure:266- **OpenAPI compliance** - Follow OpenAPI 3.0 specification267- **Consistent formatting** - Use plugin's documentation style268- **Complete coverage** - Document all endpoints and schemas269- **Example quality** - Provide realistic usage examples270- **Error documentation** - Cover all error scenarios271272The skill provides:273- Standard documentation templates274- API documentation best practices275- Common patterns for this codebase276- Quality validation criteria277278Generate production-ready API documentation.279```280281**Key features:**282- Invokes plugin skill by name283- Documents skill purpose284- Clear expectations285- Leverages skill knowledge286287---288289## 8. Multi-Component Workflow290291**Use case:** Complex workflow using agents, skills, and scripts292293**File:** `commands/complete-review.md`294295```markdown296---297description: Comprehensive review using all plugin components298argument-hint: [file-path]299allowed-tools: Bash(node:*), Read300---301302Target file: @$1303304Execute comprehensive review workflow:305306**Phase 1: Automated Analysis**307Run plugin analyzer: !`node ${CLAUDE_PLUGIN_ROOT}/scripts/analyze.js $1`308309**Phase 2: Deep Review (Agent)**310Launch the code-quality-reviewer agent for detailed analysis.311Agent will examine:312- Code structure and organization313- Error handling patterns314- Testing coverage315- Documentation quality316317**Phase 3: Standards Check (Skill)**318Use the coding-standards skill to validate:319- Naming conventions320- Code formatting321- Best practices adherence322- Framework-specific patterns323324**Phase 4: Report Generation**325Template: @${CLAUDE_PLUGIN_ROOT}/templates/review-report.md326327Compile all findings into comprehensive report following template.328329**Phase 5: Recommendations**330Generate prioritized action items:3311. Critical issues (must fix)3322. Important improvements (should fix)3333. Nice-to-have enhancements (could fix)334335Include specific file locations and suggested changes for each item.336```337338**Key features:**339- Multi-phase workflow340- Combines scripts, agents, skills341- Template-based reporting342- Prioritized outputs343344---345346## 9. Validated Input Command347348**Use case:** Command with input validation and error handling349350**File:** `commands/build-env.md`351352```markdown353---354description: Build for specific environment with validation355argument-hint: [environment]356allowed-tools: Bash(*)357---358359Validate environment argument: !`echo "$1" | grep -E "^(dev|staging|prod)$" && echo "VALID" || echo "INVALID"`360361Check build script exists: !`test -x ${CLAUDE_PLUGIN_ROOT}/scripts/build.sh && echo "EXISTS" || echo "MISSING"`362363Verify configuration available: !`test -f ${CLAUDE_PLUGIN_ROOT}/config/$1.json && echo "FOUND" || echo "NOT_FOUND"`364365If all validations pass:366367**Configuration:** @${CLAUDE_PLUGIN_ROOT}/config/$1.json368369**Execute build:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/build.sh $1 2>&1`370371**Validation results:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate-build.sh $1 2>&1`372373Report build status and any issues.374375If validations fail:376- Explain which validation failed377- Provide expected values/locations378- Suggest corrective actions379- Document troubleshooting steps380```381382**Key features:**383- Input validation384- Resource existence checks385- Error handling386- Helpful error messages387- Graceful failure handling388389---390391## 10. Environment-Aware Command392393**Use case:** Command that adapts behavior based on environment394395**File:** `commands/run-checks.md`396397```markdown398---399description: Run environment-appropriate checks400argument-hint: [environment]401allowed-tools: Bash(*), Read402---403404Environment: $1405406Load environment configuration: @${CLAUDE_PLUGIN_ROOT}/config/$1-checks.json407408Determine check level: !`echo "$1" | grep -E "^prod$" && echo "FULL" || echo "BASIC"`409410**For production environment:**411- Full test suite: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/test-full.sh`412- Security scan: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/security-scan.sh`413- Performance audit: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/perf-check.sh`414- Compliance check: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/compliance.sh`415416**For non-production environments:**417- Basic tests: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/test-basic.sh`418- Quick lint: !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/lint.sh`419420Analyze results based on environment requirements:421422**Production:** All checks must pass with zero critical issues423**Staging:** No critical issues, warnings acceptable424**Development:** Focus on blocking issues only425426Report status and recommend proceed/block decision.427```428429**Key features:**430- Environment-aware logic431- Conditional execution432- Different validation levels433- Appropriate reporting per environment434435---436437## Common Patterns Summary438439### Pattern: Plugin Script Execution440```markdown441!`node ${CLAUDE_PLUGIN_ROOT}/scripts/script-name.js $1`442```443Use for: Running plugin-provided Node.js scripts444445### Pattern: Plugin Configuration Loading446```markdown447@${CLAUDE_PLUGIN_ROOT}/config/config-name.json448```449Use for: Loading plugin configuration files450451### Pattern: Plugin Template Usage452```markdown453@${CLAUDE_PLUGIN_ROOT}/templates/template-name.md454```455Use for: Using plugin templates for generation456457### Pattern: Agent Invocation458```markdown459Launch the [agent-name] agent for [task description].460```461Use for: Delegating complex tasks to plugin agents462463### Pattern: Skill Reference464```markdown465Use the [skill-name] skill to ensure [requirements].466```467Use for: Leveraging plugin skills for specialized knowledge468469### Pattern: Input Validation470```markdown471Validate input: !`echo "$1" | grep -E "^pattern$" && echo "OK" || echo "ERROR"`472```473Use for: Validating command arguments474475### Pattern: Resource Validation476```markdown477Check exists: !`test -f ${CLAUDE_PLUGIN_ROOT}/path/file && echo "YES" || echo "NO"`478```479Use for: Verifying required plugin files exist480481---482483## Development Tips484485### Testing Plugin Commands4864871. **Test with plugin installed:**488```bash489cd /path/to/plugin490claude /command-name args491```4924932. **Verify ${CLAUDE_PLUGIN_ROOT} expansion:**494```bash495# Add debug output to command496!`echo "Plugin root: ${CLAUDE_PLUGIN_ROOT}"`497```4984993. **Test across different working directories:**500```bash501cd /tmp && claude /command-name502cd /other/project && claude /command-name503```5045054. **Validate resource availability:**506```bash507# Check all plugin resources exist508!`ls -la ${CLAUDE_PLUGIN_ROOT}/scripts/`509!`ls -la ${CLAUDE_PLUGIN_ROOT}/config/`510```511512### Common Mistakes to Avoid5135141. **Using relative paths instead of ${CLAUDE_PLUGIN_ROOT}:**515```markdown516# Wrong517!`node ./scripts/analyze.js`518519# Correct520!`node ${CLAUDE_PLUGIN_ROOT}/scripts/analyze.js`521```5225232. **Forgetting to allow required tools:**524```markdown525# Missing allowed-tools526!`bash script.sh` # Will fail without Bash permission527528# Correct529---530allowed-tools: Bash(*)531---532!`bash ${CLAUDE_PLUGIN_ROOT}/scripts/script.sh`533```5345353. **Not validating inputs:**536```markdown537# Risky - no validation538Deploy to $1 environment539540# Better - with validation541Validate: !`echo "$1" | grep -E "^(dev|staging|prod)$" || echo "INVALID"`542Deploy to $1 environment (if valid)543```5445454. **Hardcoding plugin paths:**546```markdown547# Wrong - breaks on different installations548@/home/user/.claude/plugins/my-plugin/config.json549550# Correct - works everywhere551@${CLAUDE_PLUGIN_ROOT}/config.json552```553554---555556For detailed plugin-specific features, see `references/plugin-features-reference.md`.557For general command development, see main `SKILL.md`.558