# 标准插件示例
一个结构良好的插件,包含命令、智能体和技能。
## 目录结构
code-quality/
├── .claude-plugin/
│ └── plugin.json
├── commands/
│ ├── lint.md
│ ├── test.md
│ └── review.md
├── agents/
│ ├── code-reviewer.md
│ └── test-generator.md
├── skills/
│ ├── code-standards/
│ │ ├── SKILL.md
│ │ └── references/
│ │ └── style-guide.md
│ └── testing-patterns/
│ ├── SKILL.md
│ └── examples/
│ ├── unit-test.js
│ └── integration-test.js
├── hooks/
│ ├── hooks.json
│ └── scripts/
│ └── validate-commit.sh
└── scripts/
├── run-linter.sh
└── generate-report.py
## 文件内容
### .claude-plugin/plugin.json
{
"name": "code-quality",
"version": "1.0.0",
"description": "全面的代码质量工具,包括 linting、测试和审查自动化",
"author": {
"name": "Quality Team",
"email": "
[email protected]"
},
"homepage": "https://docs.example.com/plugins/code-quality",
"repository": "https://github.com/example/code-quality-plugin",
"license": "MIT",
"keywords": ["code-quality", "linting", "testing", "code-review", "automation"]
}
### commands/lint.md
markdown
---
name: lint
description: 在代码库上运行 linting 检查
---
# Lint 命令
在项目代码库上运行全面的 linting 检查。
## 流程
1. 检测项目类型和已安装的 linter
2. 运行适当的 linter (ESLint, Pylint, RuboCop 等)
3. 收集并格式化结果
4. 报告带有文件位置和严重性的问题
## 实现
执行 linting 脚本:
```bash
bash ${CLAUDE_PLUGIN_ROOT}/scripts/run-linter.sh
```
解析输出并按以下方式组织问题:
- 关键问题(必须修复)
- 警告(应该修复)
- 样式建议(可选)
对于每个问题,显示:
- 文件路径和行号
- 问题描述
- 建议修复(如果可用)
### commands/test.md
markdown
---
name: test
description: 运行测试套件并生成覆盖率报告
---
# Test 命令
执行项目测试套件并生成覆盖率报告。
## 流程
1. 识别测试框架 (Jest, pytest, RSpec 等)
2. 运行所有测试
3. 生成覆盖率报告
4. 识别未测试的代码
## 输出
以结构化格式呈现结果:
- 测试摘要(通过/失败/跳过)
- 按文件划分的覆盖率百分比
- 关键未测试区域
- 失败测试详情
## 集成
测试完成后,提供以下选项:
- 修复失败