Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Directory structure and conventions for building Claude Code plugins (from the official Anthropic claude-code repo).
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
examples/standard-plugin.md
1# Standard Plugin Example23A well-structured plugin with commands, agents, and skills.45## Directory Structure67```8code-quality/9├── .claude-plugin/10│ └── plugin.json11├── commands/12│ ├── lint.md13│ ├── test.md14│ └── review.md15├── agents/16│ ├── code-reviewer.md17│ └── test-generator.md18├── skills/19│ ├── code-standards/20│ │ ├── SKILL.md21│ │ └── references/22│ │ └── style-guide.md23│ └── testing-patterns/24│ ├── SKILL.md25│ └── examples/26│ ├── unit-test.js27│ └── integration-test.js28├── hooks/29│ ├── hooks.json30│ └── scripts/31│ └── validate-commit.sh32└── scripts/33├── run-linter.sh34└── generate-report.py35```3637## File Contents3839### .claude-plugin/plugin.json4041```json42{43"name": "code-quality",44"version": "1.0.0",45"description": "Comprehensive code quality tools including linting, testing, and review automation",46"author": {47"name": "Quality Team",48"email": "[email protected]"49},50"homepage": "https://docs.example.com/plugins/code-quality",51"repository": "https://github.com/example/code-quality-plugin",52"license": "MIT",53"keywords": ["code-quality", "linting", "testing", "code-review", "automation"]54}55```5657### commands/lint.md5859```markdown60---61name: lint62description: Run linting checks on the codebase63---6465# Lint Command6667Run comprehensive linting checks on the project codebase.6869## Process70711. Detect project type and installed linters722. Run appropriate linters (ESLint, Pylint, RuboCop, etc.)733. Collect and format results744. Report issues with file locations and severity7576## Implementation7778Execute the linting script:7980\`\`\`bash81bash ${CLAUDE_PLUGIN_ROOT}/scripts/run-linter.sh82\`\`\`8384Parse the output and present issues organized by:85- Critical issues (must fix)86- Warnings (should fix)87- Style suggestions (optional)8889For each issue, show:90- File path and line number91- Issue description92- Suggested fix (if available)93```9495### commands/test.md9697```markdown98---99name: test100description: Run test suite with coverage reporting101---102103# Test Command104105Execute the project test suite and generate coverage reports.106107## Process1081091. Identify test framework (Jest, pytest, RSpec, etc.)1102. Run all tests1113. Generate coverage report1124. Identify untested code113114## Output115116Present results in structured format:117- Test summary (passed/failed/skipped)118- Coverage percentage by file119- Critical untested areas120- Failed test details121122## Integration123124After test completion, offer to:125- Fix failing tests126- Generate tests for untested code (using test-generator agent)127- Update documentation based on test changes128```129130### agents/code-reviewer.md131132```markdown133---134description: Expert code reviewer specializing in identifying bugs, security issues, and improvement opportunities135capabilities:136- Analyze code for potential bugs and logic errors137- Identify security vulnerabilities138- Suggest performance improvements139- Ensure code follows project standards140- Review test coverage adequacy141---142143# Code Reviewer Agent144145Specialized agent for comprehensive code review.146147## Expertise148149- **Bug detection**: Logic errors, edge cases, error handling150- **Security analysis**: Injection vulnerabilities, authentication issues, data exposure151- **Performance**: Algorithm efficiency, resource usage, optimization opportunities152- **Standards compliance**: Style guide adherence, naming conventions, documentation153- **Test coverage**: Adequacy of test cases, missing scenarios154155## Review Process1561571. **Initial scan**: Quick pass for obvious issues1582. **Deep analysis**: Line-by-line review of changed code1593. **Context evaluation**: Check impact on related code1604. **Best practices**: Compare against project and language standards1615. **Recommendations**: Prioritized list of improvements162163## Integration with Skills164165Automatically loads `code-standards` skill for project-specific guidelines.166167## Output Format168169For each file reviewed:170- Overall assessment171- Critical issues (must fix before merge)172- Important issues (should fix)173- Suggestions (nice to have)174- Positive feedback (what was done well)175```176177### agents/test-generator.md178179```markdown180---181description: Generates comprehensive test suites from code analysis182capabilities:183- Analyze code structure and logic flow184- Generate unit tests for functions and methods185- Create integration tests for modules186- Design edge case and error condition tests187- Suggest test fixtures and mocks188---189190# Test Generator Agent191192Specialized agent for generating comprehensive test suites.193194## Expertise195196- **Unit testing**: Individual function/method tests197- **Integration testing**: Module interaction tests198- **Edge cases**: Boundary conditions, error paths199- **Test organization**: Proper test structure and naming200- **Mocking**: Appropriate use of mocks and stubs201202## Generation Process2032041. **Code analysis**: Understand function purpose and logic2052. **Path identification**: Map all execution paths2063. **Input design**: Create test inputs covering all paths2074. **Assertion design**: Define expected outputs2085. **Test generation**: Write tests in project's framework209210## Integration with Skills211212Automatically loads `testing-patterns` skill for project-specific test conventions.213214## Test Quality215216Generated tests include:217- Happy path scenarios218- Edge cases and boundary conditions219- Error handling verification220- Mock data for external dependencies221- Clear test descriptions222```223224### skills/code-standards/SKILL.md225226```markdown227---228name: Code Standards229description: This skill should be used when reviewing code, enforcing style guidelines, checking naming conventions, or ensuring code quality standards. Provides project-specific coding standards and best practices.230version: 1.0.0231---232233# Code Standards234235Comprehensive coding standards and best practices for maintaining code quality.236237## Overview238239Enforce consistent code quality through standardized conventions for:240- Code style and formatting241- Naming conventions242- Documentation requirements243- Error handling patterns244- Security practices245246## Style Guidelines247248### Formatting249250- **Indentation**: 2 spaces (JavaScript/TypeScript), 4 spaces (Python)251- **Line length**: Maximum 100 characters252- **Braces**: Same line for opening brace (K&R style)253- **Whitespace**: Space after commas, around operators254255### Naming Conventions256257- **Variables**: camelCase for JavaScript, snake_case for Python258- **Functions**: camelCase, descriptive verb-noun pairs259- **Classes**: PascalCase260- **Constants**: UPPER_SNAKE_CASE261- **Files**: kebab-case for modules262263## Documentation Requirements264265### Function Documentation266267Every function must include:268- Purpose description269- Parameter descriptions with types270- Return value description with type271- Example usage (for public functions)272273### Module Documentation274275Every module must include:276- Module purpose277- Public API overview278- Usage examples279- Dependencies280281## Error Handling282283### Required Practices284285- Never swallow errors silently286- Always log errors with context287- Use specific error types288- Provide actionable error messages289- Clean up resources in finally blocks290291### Example Pattern292293\`\`\`javascript294async function processData(data) {295try {296const result = await transform(data)297return result298} catch (error) {299logger.error('Data processing failed', {300data: sanitize(data),301error: error.message,302stack: error.stack303})304throw new DataProcessingError('Failed to process data', { cause: error })305}306}307\`\`\`308309## Security Practices310311- Validate all external input312- Sanitize data before output313- Use parameterized queries314- Never log sensitive information315- Keep dependencies updated316317## Detailed Guidelines318319For comprehensive style guides by language, see:320- `references/style-guide.md`321```322323### skills/code-standards/references/style-guide.md324325```markdown326# Comprehensive Style Guide327328Detailed style guidelines for all supported languages.329330## JavaScript/TypeScript331332### Variable Declarations333334Use `const` by default, `let` when reassignment needed, never `var`:335336\`\`\`javascript337// Good338const MAX_RETRIES = 3339let currentTry = 0340341// Bad342var MAX_RETRIES = 3343\`\`\`344345### Function Declarations346347Use function expressions for consistency:348349\`\`\`javascript350// Good351const calculateTotal = (items) => {352return items.reduce((sum, item) => sum + item.price, 0)353}354355// Bad (inconsistent style)356function calculateTotal(items) {357return items.reduce((sum, item) => sum + item.price, 0)358}359\`\`\`360361### Async/Await362363Prefer async/await over promise chains:364365\`\`\`javascript366// Good367async function fetchUserData(userId) {368const user = await db.getUser(userId)369const orders = await db.getOrders(user.id)370return { user, orders }371}372373// Bad374function fetchUserData(userId) {375return db.getUser(userId)376.then(user => db.getOrders(user.id)377.then(orders => ({ user, orders })))378}379\`\`\`380381## Python382383### Import Organization384385Order imports: standard library, third-party, local:386387\`\`\`python388# Good389import os390import sys391392import numpy as np393import pandas as pd394395from app.models import User396from app.utils import helper397398# Bad - mixed order399from app.models import User400import numpy as np401import os402\`\`\`403404### Type Hints405406Use type hints for all function signatures:407408\`\`\`python409# Good410def calculate_average(numbers: list[float]) -> float:411return sum(numbers) / len(numbers)412413# Bad414def calculate_average(numbers):415return sum(numbers) / len(numbers)416\`\`\`417418## Additional Languages419420See language-specific guides for:421- Go: `references/go-style.md`422- Rust: `references/rust-style.md`423- Ruby: `references/ruby-style.md`424```425426### hooks/hooks.json427428```json429{430"PreToolUse": [431{432"matcher": "Write|Edit",433"hooks": [434{435"type": "prompt",436"prompt": "Before modifying code, verify it meets our coding standards from the code-standards skill. Check formatting, naming conventions, and documentation. If standards aren't met, suggest improvements.",437"timeout": 30438}439]440}441],442"Stop": [443{444"matcher": ".*",445"hooks": [446{447"type": "command",448"command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/validate-commit.sh",449"timeout": 45450}451]452}453]454}455```456457### hooks/scripts/validate-commit.sh458459```bash460#!/bin/bash461# Validate code quality before task completion462463set -e464465# Check if there are any uncommitted changes466if [[ -z $(git status -s) ]]; then467echo '{"systemMessage": "No changes to validate. Task complete."}'468exit 0469fi470471# Run linter on changed files472CHANGED_FILES=$(git diff --name-only --cached | grep -E '\.(js|ts|py)$' || true)473474if [[ -z "$CHANGED_FILES" ]]; then475echo '{"systemMessage": "No code files changed. Validation passed."}'476exit 0477fi478479# Run appropriate linters480ISSUES=0481482for file in $CHANGED_FILES; do483case "$file" in484*.js|*.ts)485if ! npx eslint "$file" --quiet; then486ISSUES=$((ISSUES + 1))487fi488;;489*.py)490if ! python -m pylint "$file" --errors-only; then491ISSUES=$((ISSUES + 1))492fi493;;494esac495done496497if [[ $ISSUES -gt 0 ]]; then498echo "{\"systemMessage\": \"Found $ISSUES code quality issues. Please fix before completing.\"}"499exit 1500fi501502echo '{"systemMessage": "Code quality checks passed. Ready to commit."}'503exit 0504```505506## Usage Examples507508### Running Commands509510```511$ claude512> /lint513Running linter checks...514515Critical Issues (2):516src/api/users.js:45 - SQL injection vulnerability517src/utils/helpers.js:12 - Unhandled promise rejection518519Warnings (5):520src/components/Button.tsx:23 - Missing PropTypes521...522523Style Suggestions (8):524src/index.js:1 - Use const instead of let525...526527> /test528Running test suite...529530Test Results:531✓ 245 passed532✗ 3 failed533○ 2 skipped534535Coverage: 87.3%536537Untested Files:538src/utils/cache.js - 0% coverage539src/api/webhooks.js - 23% coverage540541Failed Tests:5421. User API › GET /users › should handle pagination543Expected 200, received 500544...545```546547### Using Agents548549```550> Review the changes in src/api/users.js551552[code-reviewer agent selected automatically]553554Code Review: src/api/users.js555556Critical Issues:5571. Line 45: SQL injection vulnerability558- Using string concatenation for SQL query559- Replace with parameterized query560- Priority: CRITICAL5615622. Line 67: Missing error handling563- Database query without try/catch564- Could crash server on DB error565- Priority: HIGH566567Suggestions:5681. Line 23: Consider caching user data569- Frequent DB queries for same users570- Add Redis caching layer571- Priority: MEDIUM572```573574## Key Points5755761. **Complete manifest**: All recommended metadata fields5772. **Multiple components**: Commands, agents, skills, hooks5783. **Rich skills**: References and examples for detailed information5794. **Automation**: Hooks enforce standards automatically5805. **Integration**: Components work together cohesively581582## When to Use This Pattern583584- Production plugins for distribution585- Team collaboration tools586- Plugins requiring consistency enforcement587- Complex workflows with multiple entry points588