### Workflow Example: Start developing Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/README.md Commands to set the API key and run the agent after project setup. ```bash # Set your API key echo "ANTHROPIC_API_KEY=your_key_here" > .env # Run your agent npm start ``` -------------------------------- ### Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md Example of how to invoke the '/hello' command after installing the plugin and its expected output. ```bash $ claude > /hello Hello! This is a simple command from the hello-world plugin. Use this as a starting point for building more complex plugins. Executed at: 2025-01-15 14:30:22 UTC ``` -------------------------------- ### Test Plugin Commands with Plugin Installed Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Example of how to test a plugin command after installing the plugin. ```bash cd /path/to/plugin claude /command-name args ``` -------------------------------- ### Example: /new-sdk-app customer-support-agent Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/README.md Demonstrates creating a new Agent SDK project for a customer support agent, including setup and verification steps. ```bash /new-sdk-app customer-support-agent # # Creates a new Agent SDK project for a customer support agent # # Sets up TypeScript or Python environment # # Installs latest SDK version # # Verifies the setup automatically ``` -------------------------------- ### Using yq for YAML Parsing Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-settings/references/parsing-techniques.md Example demonstrating how to use `yq` for more robust YAML parsing, including installation instructions. ```bash # Install: brew install yq # Parse YAML properly FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$FILE") # Extract fields with yq ENABLED=$(echo "$FRONTMATTER" | yq '.enabled') MODE=$(echo "$FRONTMATTER" | yq '.mode') LIST=$(echo "$FRONTMATTER" | yq -o json '.list_field') ``` -------------------------------- ### Environment variable example Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/commands/new-sdk-app.md Example content for a .env.example file to set the Anthropic API key. ```env ANTHROPIC_API_KEY=your_api_key_here ``` -------------------------------- ### Installation Instructions Source: https://github.com/anthropics/claude-code/blob/main/plugins/pr-review-toolkit/README.md Commands to install the plugin from a personal marketplace. ```bash /plugins # Find "pr-review-toolkit" # Install ``` -------------------------------- ### Deployment Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /deploy command. ```bash > /deploy staging v1.2.3 ``` -------------------------------- ### Example Block Format Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/references/triggering-examples.md The standard format for triggering examples. ```markdown Context: [Describe the situation - what led to this interaction] user: "[Exact user message or request]" assistant: "[How Claude should respond before triggering]" [Explanation of why this agent should be triggered in this scenario] assistant: "[How Claude triggers the agent - usually 'I'll use the [agent-name] agent...']" ``` -------------------------------- ### Debugging Commands Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md Kubectl commands for getting pod details, logs, executing commands, and checking resource usage. ```bash kubectl describe pod kubectl logs kubectl logs --previous # logs from crashed container ``` ```bash kubectl exec -it -- /bin/sh kubectl exec -- env ``` ```bash kubectl top nodes kubectl top pods ``` -------------------------------- ### Quick Start Command Source: https://github.com/anthropics/claude-code/blob/main/plugins/ralph-wiggum/README.md Example command to start a Ralph loop for building a REST API for todos with a completion promise and iteration limit. ```bash /ralph-loop "Build a REST API for todos. Requirements: CRUD operations, input validation, tests. Output COMPLETE when done." --completion-promise "COMPLETE" --max-iterations 50 ``` -------------------------------- ### Hardcoding plugin paths Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Shows the problem with hardcoding absolute plugin paths, which can break on different installations, and the correct approach using `${CLAUDE_PLUGIN_ROOT}` for portability. ```markdown # Wrong - breaks on different installations @/home/user/.claude/plugins/my-plugin/config.json # Correct - works everywhere @${CLAUDE_PLUGIN_ROOT}/config.json ``` -------------------------------- ### Documentation Generator Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /document command. ```bash > /document src/api/users.ts ``` -------------------------------- ### Comparison Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /compare-files command. ```bash > /compare-files src/old-api.ts src/new-api.ts ``` -------------------------------- ### Pod Security Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md Example configuration for applying pod security best practices like running as non-root, read-only filesystem, and dropping capabilities. ```yaml securityContext: runAsNonRoot: true runAsUser: 1000 readOnlyRootFilesystem: true capabilities: drop: - ALL ``` -------------------------------- ### Install from claude-code-marketplace Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/README.md Command to install the plugin-dev plugin from the marketplace. ```bash /plugin install plugin-dev@claude-code-marketplace ``` -------------------------------- ### Install Plugin Source: https://github.com/anthropics/claude-code/blob/main/plugins/security-guidance/README.md Command to install the security-guidance plugin using the Claude Code CLI. ```bash /plugin install security-guidance@claude-plugins-official ``` -------------------------------- ### Good Example: Referencing Additional Resources Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/skill-development/SKILL.md Example of a SKILL.md file that clearly references additional resources like reference files and examples. ```markdown # SKILL.md [Core content] ## Additional Resources ### Reference Files - **`references/patterns.md`** - Detailed patterns - **`references/advanced.md`** - Advanced techniques ### Examples - **`examples/script.sh`** - Working example ``` -------------------------------- ### Regex Examples Source: https://github.com/anthropics/claude-code/blob/main/plugins/hookify/skills/writing-rules/SKILL.md Examples demonstrating common regex metacharacters and their matching behavior. ```regex rm\s+-rf Matches: rm -rf, rm -rf console\.log\( Matches: console.log( (eval|exec)\( Matches: eval( or exec( chmod\s+777 Matches: chmod 777, chmod 777 API_KEY\s*= Matches: API_KEY=, API_KEY = ``` -------------------------------- ### Code Review Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /review command. ```bash > /review ``` -------------------------------- ### Test Command with File Argument Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /test-file command. ```bash > /test-file src/utils/helpers.test.ts ``` -------------------------------- ### Multi-Script Workflow Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Orchestrate build, test, and deploy workflow ```markdown --- description: Execute complete release workflow argument-hint: [version] allowed-tools: Bash(*), Read --- Executing release workflow for version $1: **Step 1 - Pre-release validation:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/pre-release-check.sh $1` **Step 2 - Build artifacts:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/build-release.sh $1` **Step 3 - Run test suite:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/run-tests.sh` **Step 4 - Package release:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/package.sh $1` Review all step outputs and report: 1. Any failures or warnings 2. Build artifacts location 3. Test results summary 4. Next steps for deployment 5. Rollback plan if needed ``` -------------------------------- ### Self-Correction (Good Example) Source: https://github.com/anthropics/claude-code/blob/main/plugins/ralph-wiggum/README.md Example of a prompt guiding the AI through a Test-Driven Development (TDD) process for self-correction. ```markdown Implement feature X following TDD: 1. Write failing tests 2. Implement feature 3. Run tests 4. If any fail, debug and fix 5. Refactor if needed 6. Repeat until all green 7. Output: COMPLETE ``` -------------------------------- ### Script-Based Analysis Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Run comprehensive analysis using multiple plugin scripts ```markdown --- description: Complete code audit using plugin suite argument-hint: [directory] allowed-tools: Bash(*) model: sonnet --- Running complete audit on $1: **Security scan:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/security-scan.sh $1` **Performance analysis:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/perf-analyze.sh $1` **Best practices check:** !`bash ${CLAUDE_PLUGIN_ROOT}/scripts/best-practices.sh $1` Analyze all results and create comprehensive report including: - Critical issues requiring immediate attention - Performance optimization opportunities - Security vulnerabilities and fixes - Overall health score and recommendations ``` -------------------------------- ### Get Pod Logs Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md JavaScript code to get logs for a specific pod and container using the `k8s_get_logs` tool. ```javascript const logs = await tools.k8s_get_logs({ pod: 'api-xyz', container: 'app' }) ``` -------------------------------- ### Cover Different Phrasings Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/references/triggering-examples.md Examples demonstrating how to cover various user phrasings for the same request. ```markdown user: "Review my code" [...] user: "Can you check my implementation?" [...] user: "Look over these changes" [...] ``` -------------------------------- ### Git Status Summary Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md Example usage of the /git-status command. ```bash > /git-status ``` -------------------------------- ### Verify SDK Installation (Python) Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/commands/new-sdk-app.md Command to verify the installed version of the Claude Agent SDK in a Python project. ```bash pip show claude-agent-sdk ``` -------------------------------- ### Verify SDK Installation (TypeScript) Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/commands/new-sdk-app.md Command to verify the installed version of the Claude Agent SDK in a TypeScript project. ```bash npm list @anthropic-ai/claude-agent-sdk ``` -------------------------------- ### Command with Smart Defaults Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/marketplace-considerations.md Example demonstrating how to use shell parameter expansion for sensible defaults and how users can override them via arguments or a configuration file. ```markdown --- description: Command with smart defaults --- # Smart Defaults Configuration: - Format: ${FORMAT:-json} # Defaults to json - Output: ${OUTPUT:-stdout} # Defaults to stdout - Verbose: ${VERBOSE:-false} # Defaults to false These defaults work for 80% of use cases. Override with arguments: /command --format yaml --output file.txt --verbose Or set in .claude/plugin-name.local.md: ```yaml --- format: yaml output: custom.txt verbose: true --- ``` ``` -------------------------------- ### Install Claude Agent SDK (Python) Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/commands/new-sdk-app.md Command to install the latest version of the Claude Agent SDK for Python projects. ```bash pip install claude-agent-sdk ``` -------------------------------- ### Template-Based Generation Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Generate documentation following plugin template ```markdown --- description: Generate API documentation from template argument-hint: [api-file] --- Template structure: @${CLAUDE_PLUGIN_ROOT}/templates/api-documentation.md API implementation: @$1 Generate complete API documentation following the template format above. Ensure documentation includes: - Endpoint descriptions with HTTP methods - Request/response schemas - Authentication requirements - Error codes and handling - Usage examples with curl commands - Rate limiting information Format output as markdown suitable for README or docs site. ``` -------------------------------- ### Install Claude Agent SDK (TypeScript) Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/commands/new-sdk-app.md Command to install the latest version of the Claude Agent SDK for TypeScript projects. ```bash npm install @anthropic-ai/claude-agent-sdk@latest ``` -------------------------------- ### Python Type Hints Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Demonstrates the use of type hints for function signatures in Python. ```python # Good def calculate_average(numbers: list[float]) -> float: return sum(numbers) / len(numbers) # Bad def calculate_average(numbers): return sum(numbers) / len(numbers) ``` -------------------------------- ### Interactive Bug Fix Source: https://github.com/anthropics/claude-code/blob/main/plugins/ralph-wiggum/commands/help.md An example command to start a Ralph loop for an interactive bug fix. ```bash /ralph-loop "Fix the token refresh logic in auth.ts. Output FIXED when all tests pass." --completion-promise "FIXED" --max-iterations 10 ``` -------------------------------- ### Version and Changelog Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/documentation-patterns.md An example of how to structure versioning, changelog, migration notes, deprecation warnings, and known issues within a documentation block. ```markdown ``` -------------------------------- ### Guided Workflow Command Usage Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/README.md Examples of how to use the /plugin-dev:create-plugin command, with and without an optional description. ```bash /plugin-dev:create-plugin [optional description] # Examples: /plugin-dev:create-plugin /plugin-dev:create-plugin A plugin for managing database migrations ``` -------------------------------- ### Documenting Token Requirements Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/mcp-integration/references/authentication.md Example of documenting token setup, obtaining tokens, and permissions in a README file. ```markdown ## Setup ### Required Environment Variables Set these environment variables before using the plugin: ```bash export API_TOKEN="your-token-here" export API_SECRET="your-secret-here" ``` ### Obtaining Tokens 1. Visit https://api.example.com/tokens 2. Create a new API token 3. Copy the token and secret 4. Set environment variables as shown above ### Token Permissions The API token needs the following permissions: - Read access to resources - Write access for creating items - Delete access (optional, for cleanup operations) ``` -------------------------------- ### Using Agents Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Example of using a code-reviewer agent to review changes in a specific file, detailing critical issues and suggestions. ```shell > Review the changes in src/api/users.js [code-reviewer agent selected automatically] Code Review: src/api/users.js Critical Issues: 1. Line 45: SQL injection vulnerability - Using string concatenation for SQL query - Replace with parameterized query - Priority: CRITICAL 2. Line 67: Missing error handling - Database query without try/catch - Could crash server on DB error - Priority: HIGH Suggestions: 1. Line 23: Consider caching user data - Frequent DB queries for same users - Add Redis caching layer - Priority: MEDIUM ``` -------------------------------- ### Example command Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/mcp-integration/references/tool-usage.md A full command example demonstrating how to define allowed tools and provide instructions for searching and creating Asana tasks. ```markdown --- description: Search and create Asana tasks allowed-tools: [ "mcp__plugin_asana_asana__asana_search_tasks", "mcp__plugin_asana_asana__asana_create_task" ] --- # Asana Task Management ## Searching Tasks To search for tasks: 1. Use mcp__plugin_asana_asana__asana_search_tasks 2. Provide search filters (assignee, project, etc.) 3. Display results to user ## Creating Tasks To create a task: 1. Gather task details: - Title (required) - Description - Project - Assignee - Due date 2. Use mcp__plugin_asana_asana__asana_create_task 3. Show confirmation with task link ``` -------------------------------- ### Example quick-check.sh script Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/hook-development/references/advanced.md A bash script for immediate approval of safe commands in a multi-stage validation setup. ```bash #!/bin/bash input=$(cat) command=$(echo "$input" | jq -r '.tool_input.command') # Immediate approval for safe commands if [[ "$command" =~ ^(ls|pwd|echo|date|whoami)$ ]]; then exit 0 fi # Let prompt hook handle complex cases exit 0 ``` -------------------------------- ### Unsupported Beta Header Comment Source: https://github.com/anthropics/claude-code/blob/main/plugins/claude-opus-4-5-migration/skills/claude-opus-4-5-migration/SKILL.md Example of how to add a comment when the context-1m-2025-08-07 beta header is not supported with Opus 4.5. ```python # Note: 1M context beta (context-1m-2025-08-07) not yet supported with Opus 4.5 ``` -------------------------------- ### Complete Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-settings/references/parsing-techniques.md This comprehensive bash script demonstrates robust settings handling by parsing frontmatter from a settings file, applying defaults, performing validation, and recovering from errors. ```bash #!/bin/bash set -euo pipefail # Configuration SETTINGS_FILE=".claude/my-plugin.local.md" # Quick exit if not configured if [[ ! -f "$SETTINGS_FILE" ]]; then # Use defaults ENABLED=true MODE=standard MAX_SIZE=1000000 else # Parse frontmatter FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' "$SETTINGS_FILE") # Extract fields with defaults ENABLED=$(echo "$FRONTMATTER" | grep '^enabled:' | sed 's/enabled: *//') ENABLED=${ENABLED:-true} MODE=$(echo "$FRONTMATTER" | grep '^mode:' | sed 's/mode: *//' | sed 's/^"\(.*\)"$/\1/') MODE=${MODE:-standard} MAX_SIZE=$(echo "$FRONTMATTER" | grep '^max_size:' | sed 's/max_size: *//') MAX_SIZE=${MAX_SIZE:-1000000} # Validate values if [[ "$ENABLED" != "true" ]] && [[ "$ENABLED" != "false" ]]; then echo "⚠️ Invalid enabled value, using default" >&2 ENABLED=true fi if ! [[ "$MAX_SIZE" =~ ^[0-9]+$ ]]; then echo "⚠️ Invalid max_size, using default" >&2 MAX_SIZE=1000000 fi fi # Quick exit if disabled if [[ "$ENABLED" != "true" ]]; then exit 0 fi # Use configuration echo "Configuration loaded: mode=$MODE, max_size=$MAX_SIZE" >&2 # Apply logic based on settings case "$MODE" in strict) # Strict validation ;; standard) # Standard validation ;; lenient) # Lenient validation ;; esac ``` -------------------------------- ### Running Commands Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Example of running linter and test commands via the Claude interface, showing output for issues, warnings, and test results. ```shell $ claude > /lint Running linter checks... Critical Issues (2): src/api/users.js:45 - SQL injection vulnerability src/utils/helpers.js:12 - Unhandled promise rejection Warnings (5): src/components/Button.tsx:23 - Missing PropTypes ... Style Suggestions (8): src/index.js:1 - Use const instead of let ... > /test Running test suite... Test Results: ✓ 245 passed ✗ 3 failed ○ 2 skipped Coverage: 87.3% Untested Files: src/utils/cache.js - 0% coverage src/api/webhooks.js - 23% coverage Failed Tests: 1. User API › GET /users › should handle pagination Expected 200, received 500 ... ``` -------------------------------- ### commands/hello.md Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md The content of the 'hello' command markdown file, including front matter and implementation details. ```markdown --- name: hello description: Prints a friendly greeting message --- # Hello Command Print a friendly greeting to the user. ## Implementation Output the following message to the user: > Hello! This is a simple command from the hello-world plugin. > > Use this as a starting point for building more complex plugins. Include the current timestamp in the greeting to show the command executed successfully. ``` -------------------------------- ### Message for no configured Hookify rules Source: https://github.com/anthropics/claude-code/blob/main/plugins/hookify/commands/list.md The message displayed when no Hookify rules are found, providing instructions on how to get started with creating rules. ```markdown ## No Hookify Rules Configured You haven't created any hookify rules yet. To get started: 1. Use `/hookify` to analyze conversation and create rules 2. Or manually create `.claude/hookify.my-rule.local.md` files 3. See `/hookify:help` for documentation Example: ``` /hookify Warn me when I use console.log ``` Check `${CLAUDE_PLUGIN_ROOT}/examples/` for example rule files. ``` -------------------------------- ### Deployment Command Definition Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/simple-commands.md File: .claude/commands/deploy.md ```markdown --- description: Deploy to specified environment argument-hint: [environment] [version] allowed-tools: Bash(kubectl:*), Read --- Deploy to $1 environment using version $2 **Pre-deployment Checks:** 1. Verify $1 configuration exists 2. Check version $2 is valid 3. Verify cluster accessibility: !`kubectl cluster-info` **Deployment Steps:** 1. Update deployment manifest with version $2 2. Apply configuration to $1 3. Monitor rollout status 4. Verify pod health 5. Run smoke tests **Rollback Plan:** Document current version for rollback if issues occur. Proceed with deployment? (yes/no) ``` -------------------------------- ### Progressive Disclosure Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/interactive-commands.md Example demonstrating how to use AskUserQuestion to implement progressive disclosure, offering different setup paths based on user choice. ```markdown # Start Simple, Get Detailed as Needed ## Question 1: Setup Type Use AskUserQuestion: Question: "How would you like to set up?" Header: "Setup type" Options: - Quick (Use recommended defaults) - Custom (Configure all options) - Guided (Step-by-step with explanations) If "Quick": Apply defaults, minimal questions If "Custom": Ask all available configuration questions If "Guided": Ask questions with extra explanation Provide recommendations along the way ``` -------------------------------- ### Actionable Instructions Examples Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/references/system-prompt-design.md Examples demonstrating concrete steps vs. vague instructions in system prompts. ```text ✅ Read the file using the Read tool, then search for patterns using Grep ❌ Analyze the code ✅ Generate test file at test/path/to/file.test.ts ❌ Create tests ``` -------------------------------- ### README Documentation Template Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/documentation-patterns.md A comprehensive template for structuring a command's companion README file, covering installation, usage, arguments, examples, configuration, requirements, troubleshooting, contributing, license, and support. ```markdown # Command Name Brief description of what the command does. ## Installation This command is part of the [plugin-name] plugin. Install with: ``` /plugin install plugin-name ``` ## Usage Basic usage: ``` /command-name [arg1] [arg2] ``` ## Arguments - `arg1`: Description (required) - `arg2`: Description (optional, defaults to X) ## Examples ### Example 1: Basic Usage ``` /command-name value1 value2 ``` Description of what happens. ### Example 2: Advanced Usage ``` /command-name value1 --option ``` Description of advanced feature. ## Configuration Optional configuration file: `.claude/command-name.local.md` ```markdown --- default_arg: value enable_feature: true --- ``` ## Requirements - Git 2.x or later - jq (for JSON processing) - Node.js 14+ (optional, for advanced features) ## Troubleshooting ### Issue: Command not found **Solution:** Ensure plugin is installed and enabled. ### Issue: Permission denied **Solution:** Check file permissions and allowed-tools setting. ## Contributing Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md). ## License MIT License - See [LICENSE](LICENSE). ## Support - Issues: https://github.com/user/plugin/issues - Docs: https://docs.example.com - Email: support@example.com ``` -------------------------------- ### Example workflow Source: https://github.com/anthropics/claude-code/blob/main/plugins/code-review/README.md Demonstrates how to run /code-review locally and post as a PR comment. ```bash # On a PR branch, run locally (outputs to terminal): /code-review # Post review as PR comment: /code-review --comment # Claude will: # - Launch 4 review agents in parallel # - Score each issue for confidence # - Output issues ≥80 confidence (to terminal or PR depending on flag) # - Skip if no high-confidence issues found ``` -------------------------------- ### Directory Structure Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/minimal-plugin.md The directory structure for the minimal 'hello-world' plugin. ```text hello-world/ ├── .claude-plugin/ │ └── plugin.json └── commands/ └── hello.md ``` -------------------------------- ### hooks/hooks.json Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md This JSON configuration defines various hooks that trigger commands or prompts at different stages of plugin execution, such as before tool use, after tool use, on session stop, and on session start. Each hook includes a matcher to determine when it applies and a command or prompt to execute, along with a timeout. ```json { "PreToolUse": [ { "matcher": "Write|Edit", "hooks": [ { "type": "command", "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/scan-secrets.sh", "timeout": 30 } ] }, { "matcher": "Bash", "hooks": [ { "type": "prompt", "prompt": "Evaluate if this bash command is safe for production environment. Check for destructive operations, missing safeguards, and potential security issues. Commands should be idempotent and reversible.", "timeout": 20 } ] } ], "PostToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/update-status.sh", "timeout": 15 } ] } ], "Stop": [ { "matcher": ".*", "hooks": [ { "type": "command", "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/quality/check-config.sh", "timeout": 45 }, { "type": "command", "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/workflow/notify-team.sh", "timeout": 30 } ] } ], "SessionStart": [ { "matcher": ".*", "hooks": [ { "type": "command", "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/security/validate-permissions.sh", "timeout": 20 } ] } ] } ``` -------------------------------- ### Example-Driven Documentation Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/documentation-patterns.md Illustrates a documentation style where examples are presented first, showing input, command, and output for different transformations. ```shell ---description: Example-heavy command---# Transformation Command## What This DoesTransforms data from one format to another.## Examples First### Example 1: JSON to YAML**Input:** `data.json````json{"name": "test", "value": 42}```**Command:** `/transform data.json yaml`**Output:** `data.yaml````yamlname: testvalue: 42```### Example 2: CSV to JSON**Input:** `data.csv````csvname,valuetest,42```**Command:** `/transform data.csv json`**Output:** `data.json````json[{"name": "test", "value": "42"}]```### Example 3: With Options**Command:** `/transform data.json yaml --pretty --sort-keys`**Result:** Formatted YAML with sorted keys---## Your TransformationFile: $1Format: $2[Perform transformation...] ``` ```json {"name": "test", "value": 42} ``` ```yaml name: test value: 42 ``` ```csv name,value test,42 ``` ```json [{"name": "test", "value": "42"}] ``` -------------------------------- ### Workflow Example: Create a new project Source: https://github.com/anthropics/claude-code/blob/main/plugins/agent-sdk-dev/README.md Command to initiate the creation of a new code-reviewer-agent project. ```bash /new-sdk-app code-reviewer-agent ``` -------------------------------- ### Network Policy Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/advanced-plugin.md Example configuration for restricting pod communication using Kubernetes Network Policies. ```yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: api-allow spec: podSelector: matchLabels: app: api ingress: - from: - podSelector: matchLabels: app: frontend ``` -------------------------------- ### Clarity and Specificity Examples Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/references/system-prompt-design.md Examples demonstrating specific vs. vague instructions in system prompts. ```text ✅ Check for SQL injection by examining all database queries for parameterization ❌ Look for security issues ✅ Provide file:line references for each finding ❌ Show where issues are ✅ Categorize as critical (security), major (bugs), or minor (style) ❌ Rate the severity of issues ``` -------------------------------- ### Selecting a Model Source: https://github.com/anthropics/claude-code/blob/main/plugins/security-guidance/README.md Examples of how to configure the SECURITY_REVIEW_MODEL environment variable for different providers (1P/gateway, Bedrock, Vertex). ```bash # 1P / gateway: a canonical model id SECURITY_REVIEW_MODEL=claude-opus-4-7 # default ``` ```bash # Bedrock: use the inference-profile id SECURITY_REVIEW_MODEL=us.anthropic.claude-opus-4-7 ``` ```bash # Vertex: use the Vertex date-tag form SECURITY_REVIEW_MODEL=claude-opus-4-7@20260218 ``` -------------------------------- ### Error Handling Example Pattern Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Example of a robust error handling pattern in JavaScript, including logging and re-throwing specific errors. ```javascript async function processData(data) { try { const result = await transform(data) return result } catch (error) { logger.error('Data processing failed', { data: sanitize(data), error: error.message, stack: error.stack }) throw new DataProcessingError('Failed to process data', { cause: error }) } } ``` -------------------------------- ### Lint Command Implementation Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Bash script execution for running linting checks. ```bash bash ${CLAUDE_PLUGIN_ROOT}/scripts/run-linter.sh ``` -------------------------------- ### Security Analyzer Agent Definition Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/examples/complete-agent-examples.md Configuration and usage examples for the security-analyzer agent, including its name, description, example conversational triggers, model, color, and tools. ```markdown --- name: security-analyzer description: Use this agent when the user implements security-critical code (auth, payments, data handling), explicitly requests security analysis, or before deploying sensitive changes. Examples: Context: User implemented authentication logic user: "I've added JWT token validation" assistant: "Let me check the security." Authentication code is security-critical. Proactively trigger security-analyzer. assistant: "I'll use the security-analyzer agent to review for security vulnerabilities." Context: User requests security check user: "Check my code for security issues" assistant: "I'll use the security-analyzer agent to perform a thorough security review." Explicit security review request triggers the agent. model: inherit color: red tools: ["Read", "Grep", "Glob"] --- ``` -------------------------------- ### Documentation Generator Agent Definition Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/examples/complete-agent-examples.md Configuration and usage examples for the docs-generator agent, including its name, description, example conversational triggers, model, color, and tools. ```markdown --- name: docs-generator description: Use this agent when the user has written code needing documentation, API endpoints requiring docs, or explicitly requests documentation generation. Examples: Context: User implemented new public API user: "I've added the user management API endpoints" assistant: "Let me document these endpoints." New public API needs documentation. Proactively trigger docs-generator. assistant: "I'll use the docs-generator agent to create API documentation." Context: User requests documentation user: "Generate docs for this module" assistant: "I'll use the docs-generator agent to create comprehensive documentation." Explicit documentation request triggers the agent. model: inherit color: cyan tools: ["Read", "Write", "Grep", "Glob"] --- ``` -------------------------------- ### Minimal Command example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/frontmatter-reference.md Example of a command with no frontmatter. ```markdown Review this code for common issues and suggest improvements. ``` -------------------------------- ### Python Import Organization Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Shows the recommended order for organizing Python imports: standard library, third-party, then local. ```python # Good import os import sys import numpy as np import pandas as pd from app.models import User from app.utils import helper # Bad - mixed order from app.models import User import numpy as np import os ``` -------------------------------- ### validate-hook-schema.sh Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/hook-development/scripts/README.md Example of using validate-hook-schema.sh. ```bash cd my-plugin ./validate-hook-schema.sh hooks/hooks.json ``` -------------------------------- ### Allowed Tools Security and Clarity Examples Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/frontmatter-reference.md Examples demonstrating how to use `allowed-tools` for security restrictions, clarity, and enabling specific Bash commands. ```yaml allowed-tools: Read, Grep # Read-only command ``` ```yaml allowed-tools: Bash(git:*), Read ``` ```yaml allowed-tools: Bash(git status:*), Bash(git diff:*) ``` -------------------------------- ### JavaScript Async/Await vs. Promise Chains Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/examples/standard-plugin.md Compares `async/await` with traditional promise chains, advocating for the former. ```javascript // Good async function fetchUserData(userId) { const user = await db.getUser(userId) const orders = await db.getOrders(user.id) return { user, orders } } // Bad function fetchUserData(userId) { return db.getUser(userId) .then(user => db.getOrders(user.id) .then(orders => ({ user, orders }))) } ``` -------------------------------- ### Usage in Hooks Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-settings/examples/example-settings.md Bash script demonstrating how to check for and read plugin settings from a local markdown file within a hook. ```bash # Check if plugin is configured if [[ ! -f ".claude/my-plugin.local.md" ]]; then exit 0 # Not configured, skip hook fi # Read settings FRONTMATTER=$(sed -n '/^---$/,/^---$/{ /^---$/d; p; }' ".claude/my-plugin.local.md") ENABLED=$(echo "$FRONTMATTER" | grep '^enabled:' | sed 's/enabled: *//') # Apply settings if [[ "$ENABLED" == "true" ]]; then # Hook is active # ... fi ``` -------------------------------- ### Helper Commands: Get help Source: https://github.com/anthropics/claude-code/blob/main/plugins/hookify/README.md Command to get help for hookify. ```bash /hookify:help ``` -------------------------------- ### Test Plugin Commands Across Different Working Directories Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/examples/plugin-commands.md Examples of testing plugin commands from various working directories to ensure robustness. ```bash cd /tmp && claude /command-name cd /other/project && claude /command-name ``` -------------------------------- ### Batching Requests: Good Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/mcp-integration/references/tool-usage.md An example of an efficient batching request using a single query with filters. ```markdown Steps: 1. Call mcp__plugin_api_server__search with filters: - project_id: "123" - status: "active" - limit: 100 2. Process all results ``` -------------------------------- ### First-run experience Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/command-development/references/marketplace-considerations.md A command that provides a welcome message, explains its purpose, and offers quick start instructions on its first execution. ```markdown ---description: Command with onboardingallowed-tools: Read, Write---# First Run Checkif [ ! -f ".claude/command-initialized" ]; then **Welcome to Command Name!** This appears to be your first time using this command. WHAT THIS COMMAND DOES: [Brief explanation of purpose and benefits] QUICK START: 1. Basic usage: /command [arg] 2. For help: /command help 3. Examples: /command examples SETUP: No additional setup required. You're ready to go! ✓ Initialization complete [Create initialization marker] Ready to proceed with your request...fi[Normal command execution...] ``` -------------------------------- ### Keywords Field Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/references/manifest-reference.md Example of the `keywords` field as an array of strings. ```json ["testing", "automation", "ci-cd", "quality-assurance"] ``` -------------------------------- ### Cover Proactive and Reactive Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/agent-development/references/triggering-examples.md Examples showing both explicit user requests (reactive) and proactive agent triggering based on context. ```markdown Context: User explicitly requests review user: "Review my code for issues" [...] Context: After user writes code user: "I've implemented the feature" assistant: "Great! Now let me review it." Code written, proactively review. [...] ``` -------------------------------- ### Categorized Structure Example Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-structure/references/component-patterns.md Example of a categorized directory structure for commands. ```plaintext commands/ # Core commands ├── build.md └── test.md admin-commands/ # Administrative ├── configure.md └── manage.md workflow-commands/ # Workflow automation ├── review.md └── deploy.md ``` -------------------------------- ### Ralph Loop Initialization Script Source: https://github.com/anthropics/claude-code/blob/main/plugins/plugin-dev/skills/plugin-settings/references/real-world-examples.md A bash script to set up the Ralph loop by creating a local markdown state file with initial configuration. ```bash #!/bin/bash PROMPT="$1" MAX_ITERATIONS="${2:-0}" COMPLETION_PROMISE="${3:-}" # Create state file cat > ".claude/ralph-loop.local.md" < /security-review ``` -------------------------------- ### Usage Examples Source: https://github.com/anthropics/claude-code/blob/main/plugins/frontend-design/README.md Examples of prompts to use with the Frontend Design Plugin. ```plaintext "Create a dashboard for a music streaming app" "Build a landing page for an AI security startup" "Design a settings panel with dark mode" ```