# Plugin-System

Das Plugin-System von Claude Code ermöglicht es Ihnen, Claudes Fähigkeiten durch eigene Slash-Befehle, spezialisierte Agenten, wiederverwendbare Skills und Automatisierungs-Hooks zu erweitern. Mit Plugins können Sie die Best Practices und Workflows Ihres Teams formalisieren.

## Was sind Plugins?

### Grundkonzepte

Ein Claude Code Plugin ist ein Verzeichnis mit einer spezifischen Dateistruktur, das die folgenden Komponenten hinzufügen kann:

| Komponente | Beschreibung | Dateiformat |
|-----------|-------------|-------------|
| **Commands** | Eigene Slash-Befehle | `.md`-Dateien |
| **Agents** | Spezialisierte Aufgaben-Subagenten | `.md`-Dateien |
| **Skills** | Wiederverwendbares Wissen und Fähigkeiten | Verzeichnis + `SKILL.md` |
| **Hooks** | Ereignisgesteuerte Automatisierung | `hooks.json` |

### Warum Plugins?

- **Team-Standardisierung**: Bilden Sie Coding-Standards und Review-Kriterien als ausführbare Befehle ab

- **Workflow-Automatisierung**: Automatisieren Sie repetitive Aufgaben wie Commits, Deployments und Reviews

- **Wissensaustausch**: Teilen Sie Best Practices und Expertise unter den Teammitgliedern

- **Individuelle Erfahrung**: Passen Sie Claudes Verhalten an die Projektanforderungen an

## Verzeichnisstruktur eines Plugins

```
my-plugin/
├── .claude-plugin/
│   └── plugin.json          # Required: Plugin manifest
├── commands/                 # Slash commands (.md files)
│   ├── review.md
│   └── deploy.md
├── agents/                   # Subagent definitions (.md files)
│   └── code-reviewer.md
├── skills/                   # Agent skills (subdirectories)
│   └── coding-standards/
│       └── SKILL.md
├── hooks/
│   └── hooks.json           # Event handler configuration
├── .mcp.json                # MCP server definitions (optional)
└── scripts/                 # Helper scripts (optional)
```

## Schnellstart

### Plugins installieren

```bash
# Install from marketplace
/plugin install plugin-name@claude-code-marketplace

# Install from local directory
claude --plugin-dir /path/to/my-plugin
```

### Plugin-Assistenten verwenden

```bash
/plugin-dev:create-plugin
```

Dieser Befehl führt Sie durch 8 Phasen, um ein vollständiges Plugin zu erstellen.

## Eigene Befehle erstellen

### Grundlegendes Befehlsformat

Erstellen Sie `.md`-Dateien im Verzeichnis `commands/`:

```markdown
---
description: Perform code review
argument-hint: [file-path]
allowed-tools: Read, Bash(git:*)
---

Please review the code quality of: @$1

Focus on:
1. Code readability
2. Potential bugs
3. Performance issues
4. Security vulnerabilities
```

### YAML-Frontmatter-Konfiguration

| Feld | Beschreibung | Beispiel |
|-------|-------------|---------|
| `description` | Befehlsbeschreibung (wird in /help angezeigt) | `Perform code review` |
| `argument-hint` | Parameter-Hinweise | `[file-path] [options]` |
| `allowed-tools` | Erlaubte Tools | `Read, Bash(git:*)` |
| `model` | Modell angeben | `opus` oder `sonnet` |

### Dynamische Argumente verwenden

- `$1`, `$2`, `$3`... – Positionsargumente

- `$ARGUMENTS` – Alle Argumente

- `@path/to/file` – Dateireferenz

- `!`command`` – Bash-Befehl ausführen

### Befehlsbeispiele

**Code-Review-Befehl** (`commands/review.md`):

```markdown
---
description: Comprehensive code review
argument-hint: [file-or-directory]
allowed-tools: Read, Grep, Glob
model: opus
---

Perform a comprehensive code review of @$1.

Checklist:
- [ ] Code style follows project standards
- [ ] No potential security issues
- [ ] Error handling is complete
- [ ] Tests are needed

If it's a directory, first use Glob tool to find all relevant files.
```

**Intelligenter Commit-Befehl** (`commands/commit.md`):

```markdown
---
description: Smart commit with generated message
allowed-tools: Bash(git:*)
---

1. Run `git status` to see changes
2. Run `git diff --staged` to analyze staged changes
3. Generate a conventional commit message based on changes
4. Execute `git commit`

Commit message format:
- feat: New feature
- fix: Bug fix
- docs: Documentation update
- refactor: Refactoring
- test: Test related
```

## Eigene Agents erstellen

### Format der Agent-Definition

Erstellen Sie `.md`-Dateien im Verzeichnis `agents/`:

```markdown
---
description: Specialized code review agent
model: opus
tools: Read, Grep, Glob
---

You are a professional code review agent. Your task is to:

1. Carefully read the provided code
2. Identify potential issues
3. Provide specific improvement suggestions
4. Focus on security and performance

Always be constructive and specific.
```

### Agent-Typen

| Typ | Zweck | Beispiel |
|------|---------|---------|
| Review Agent | Code-Review, PR-Review | `code-reviewer` |
| Test Agent | Tests generieren und ausführen | `test-generator` |
| Doc Agent | Dokumentation generieren | `doc-writer` |
| Refactor Agent | Code-Refactoring | `refactorer` |

## Skills erstellen

### Verzeichnisstruktur der Skills

```
skills/
└── coding-standards/
    ├── SKILL.md              # Required: Skill definition
    ├── references/           # Reference materials
    │   └── style-guide.md
    └── examples/             # Example code
        └── good-practices.md
```

### Format von SKILL.md

```markdown
# Coding Standards Skill

## Overview
This skill contains team coding standards and best practices.

## Knowledge Content

### Naming Conventions
- Variables: camelCase
- Constants: UPPER_SNAKE_CASE
- Classes: PascalCase
- Files: kebab-case

### Code Style
- Use 2-space indentation
- Max line width 100 characters
- Use semicolons

### Error Handling
- Always use try-catch
- Log errors
- Provide meaningful error messages
```

## Hooks erstellen

### Format von hooks.json

```json
{
  "hooks": [
    {
      "event": "on_commit",
      "command": "npm run lint",
      "description": "Run lint check before commit"
    },
    {
      "event": "on_file_change",
      "pattern": "*.ts",
      "command": "npm run typecheck",
      "description": "Type check when TypeScript files change"
    }
  ]
}
```

### Unterstützte Events

| Event | Ausgelöst bei |
|-------|----------------|
| `on_commit` | Code-Commit |
| `on_file_change` | Dateiänderungen |
| `on_session_start` | Session-Beginn |
| `on_command` | Befehlsausführung |

## Plugin-Manifest

### Format von plugin.json

```json
{
  "name": "my-plugin",
  "version": "1.0.0",
  "description": "My custom plugin",
  "author": "Your Name",
  "components": {
    "commands": ["commands/*.md"],
    "agents": ["agents/*.md"],
    "skills": ["skills/*/SKILL.md"],
    "hooks": "hooks/hooks.json"
  },
  "mcpServers": ".mcp.json"
}
```

## Praxisbeispiele

### Beispiel 1: Team-Code-Review-Plugin

```
team-review-plugin/
├── .claude-plugin/
│   └── plugin.json
├── commands/
│   ├── review-pr.md          # PR review command
│   ├── security-check.md     # Security check command
│   └── perf-audit.md         # Performance audit command
├── agents/
│   ├── security-reviewer.md  # Security review agent
│   └── perf-analyzer.md      # Performance analysis agent
└── skills/
    └── team-standards/
        └── SKILL.md          # Team standards skill
```

### Beispiel 2: Deployment-Automatisierungs-Plugin

```
deploy-plugin/
├── .claude-plugin/
│   └── plugin.json
├── commands/
│   ├── deploy-staging.md     # Deploy to staging
│   ├── deploy-prod.md        # Deploy to production
│   └── rollback.md           # Rollback command
├── hooks/
│   └── hooks.json            # Pre-deploy check hooks
└── .mcp.json                 # Kubernetes MCP config
```

## Best Practices

### Befehlsdesign

1. **Einzelverantwortung**: Jeder Befehl erledigt eine Sache

2. **Klare Beschreibungen**: Halten Sie die Beschreibung kurz

3. **Parameter dokumentieren**: Verwenden Sie argument-hint, um Parameter zu erklären

4. **Minimale Berechtigungen**: Nur notwendige Tools in allowed-tools aufnehmen

5. **Fehlerbehandlung**: Fehler-Szenarien einkalkulieren

### Plugin-Organisation

1. **Modular**: Zusammengehörige Funktionalität bündeln

2. **Wiederverwendbar**: Skills sollten von mehreren Befehlen nutzbar sein

3. **Dokumentiert**: README und Gebrauchsanleitung hinzufügen

4. **Versioniert**: Semantische Versionierung verwenden

### Sicherheitshinweise

1. **Keine hartcodierten Secrets**: Umgebungsvariablen verwenden

2. **Dateizugriff einschränken**: Nur auf notwendige Pfade zugreifen

3. **Eingaben validieren**: Parameter überprüfen

4. **Audit-Logs**: Sensible Operationen protokollieren

## Plugins debuggen

```bash
# View plugin load status
/plugin list

# View command details
/help my-command

# Test command
/my-command test-argument
```

## Nächste Schritte

- Erfahren Sie mehr über [MCP Servers](/docs/advanced/mcp), um externe Integrationen zu erweitern

- Prüfen Sie [CLI Tips](/docs/usage/cli-tips), um Ihre Effizienz zu steigern

- Entdecken Sie [Workflow Tips](/docs/usage/workflow-tips), um Ihren Entwicklungsablauf zu optimieren