Skip to main content

Creating Components

Extend Claude Code with custom components tailored to your workflow.

Component Types

Claude Code supports five component types:

Agent Components

Agents are AI specialists with focused expertise.

Agent File Structure

Agents use Markdown with YAML frontmatter:
  1. Measure Impact
    • Before/after benchmarks
    • Bundle size reduction
    • Lighthouse scores

Guidelines

When optimizing React applications:
  • Profile first, optimize second
  • Focus on measurable improvements
  • Balance performance with code readability
  • Document optimization decisions
Required fields:
  • name - Unique identifier (kebab-case)
  • description - Clear, concise expertise description
Optional fields:
  • tools - Comma-separated list of allowed tools
  • model - Preferred Claude model variant
Use model: opus for complex reasoning tasks, model: sonnet for balanced performance, or model: haiku for speed.

Agent Categories

Organize agents by domain:
Create new categories as needed:

Example: Security Auditor Agent

Security Tools

  • Static Analysis: ESLint security plugins, Semgrep
  • Dependency Scanning: npm audit, Snyk
  • Secret Detection: git-secrets, TruffleHog
  • Penetration Testing: Burp Suite, OWASP ZAP
Provide actionable security recommendations with code examples and remediation steps.

Implementation

  1. Bundle Analysis
  2. Lighthouse Audit
  3. Generate Report
    • Bundle size breakdown
    • Performance score
    • Optimization recommendations

Output Format

Recommendations

Based on audit results, suggest:
  • Code splitting opportunities
  • Lazy loading strategies
  • Image optimization
  • Caching improvements
components/commands/ ├── code-generation/ # Generate code, tests, docs ├── analysis/ # Code analysis, optimization ├── project-management/ # File operations, structure ├── testing/ # Test generation, validation └── deployment/ # Build, deploy, CI/CD

Required Fields

Never hardcode secrets in MCP files. Always use placeholder values like <YOUR_API_KEY> or <DATABASE_URL>.

Environment Variables

Use placeholders for sensitive data:
Users replace placeholders after installation:

Example: GitHub MCP

MCP Categories

Hook Components

Hooks automate actions based on events.

Hook File Structure

Hook Types

  • PreToolUse - Before tool execution
  • PostToolUse - After tool execution
  • PreConversation - Before conversation starts
  • PostConversation - After conversation ends

Example: Git Auto-Add Hook

Available Variables

  • $CLAUDE_TOOL_NAME - Name of tool executed
  • $CLAUDE_EDITED_FILE - Path to edited file
  • $CLAUDE_PROJECT_PATH - Current project directory
  • $CLAUDE_CONVERSATION_ID - Active conversation ID

Hook Categories

Settings Components

Settings configure Claude Code behavior.

Settings File Structure

Common Settings

Performance:
UI Customization:

Component Review Process

CRITICAL: Use the component-reviewer agent for ALL component changesBefore submitting any component, use:

Validation Checklist

The component-reviewer agent checks:
  • ✅ Valid YAML frontmatter (for agents/commands)
  • ✅ Valid JSON structure (for MCPs/hooks/settings)
  • ✅ Required fields present
  • ✅ Kebab-case naming conventions
  • ✅ No hardcoded secrets or API keys
  • ✅ Relative paths only (no absolute paths)
  • ✅ Clear, specific descriptions
  • ✅ Correct category placement

Example Review

Reviewer output:

Publishing Components

1

Create Component

Write component file in appropriate category directory
2

Review with Agent

3

Fix Issues

Address critical issues and warnings
4

Update Catalog

5

Test Installation

6

Submit PR

Open pull request with clear description and examples

Catalog Generation

After creating/modifying components:
This updates docs/components.json with:
  • Component metadata
  • File contents
  • Installation instructions
  • Search indexes

Best Practices

Naming Conventions

DO:
  • react-performance-expert (kebab-case)
  • security-auditor (descriptive)
  • github-integration (clear purpose)
DON’T:
  • ReactExpert (PascalCase)
  • expert_agent (snake_case)
  • myagent (vague)

Descriptions

Good descriptions:
Poor descriptions:

Security

Never include:
  • API keys or tokens
  • Passwords or credentials
  • Absolute file paths (/Users/you/...)
  • Personal information
  • Proprietary code or business logic
Use placeholders:

Next Steps

Contributing Guide

Full contribution guidelines and workflow

Component Examples

Browse 900+ existing components for inspiration