drogon-claude-plugin 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. drogon_claude_plugin-0.3.0/LICENSE +21 -0
  2. drogon_claude_plugin-0.3.0/MANIFEST.in +2 -0
  3. drogon_claude_plugin-0.3.0/PKG-INFO +235 -0
  4. drogon_claude_plugin-0.3.0/README.md +186 -0
  5. drogon_claude_plugin-0.3.0/pyproject.toml +41 -0
  6. drogon_claude_plugin-0.3.0/setup.cfg +4 -0
  7. drogon_claude_plugin-0.3.0/src/drogon_claude_plugin.egg-info/PKG-INFO +235 -0
  8. drogon_claude_plugin-0.3.0/src/drogon_claude_plugin.egg-info/SOURCES.txt +50 -0
  9. drogon_claude_plugin-0.3.0/src/drogon_claude_plugin.egg-info/dependency_links.txt +1 -0
  10. drogon_claude_plugin-0.3.0/src/drogon_claude_plugin.egg-info/entry_points.txt +2 -0
  11. drogon_claude_plugin-0.3.0/src/drogon_claude_plugin.egg-info/top_level.txt +1 -0
  12. drogon_claude_plugin-0.3.0/src/drogon_plugin/__init__.py +14 -0
  13. drogon_claude_plugin-0.3.0/src/drogon_plugin/cli.py +307 -0
  14. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/.claude-plugin/marketplace.json +18 -0
  15. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/.claude-plugin/plugin.json +21 -0
  16. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/CLAUDE.md +60 -0
  17. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/hooks/hooks.json +28 -0
  18. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/hooks/posttooluse.py +244 -0
  19. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-create-controller/SKILL.md +38 -0
  20. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-create-controller/references/code-guide.md +107 -0
  21. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-advice/SKILL.md +42 -0
  22. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-advice/references/code-guide.md +95 -0
  23. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-cmake/SKILL.md +39 -0
  24. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-cmake/references/code-guide.md +64 -0
  25. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-coroutine-handler/SKILL.md +35 -0
  26. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-coroutine-handler/references/code-guide.md +126 -0
  27. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-csp-view/SKILL.md +37 -0
  28. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-csp-view/references/code-guide.md +158 -0
  29. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-db-config/SKILL.md +39 -0
  30. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-db-config/references/code-guide.md +84 -0
  31. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-file-upload/SKILL.md +36 -0
  32. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-file-upload/references/code-guide.md +79 -0
  33. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-filter/SKILL.md +36 -0
  34. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-filter/references/code-guide.md +102 -0
  35. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-http-client/SKILL.md +36 -0
  36. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-http-client/references/code-guide.md +85 -0
  37. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-lambda-handler/SKILL.md +36 -0
  38. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-lambda-handler/references/code-guide.md +78 -0
  39. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-middleware/SKILL.md +36 -0
  40. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-middleware/references/code-guide.md +106 -0
  41. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-orm-crud/SKILL.md +39 -0
  42. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-orm-crud/references/code-guide.md +109 -0
  43. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-plugin/SKILL.md +40 -0
  44. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-plugin/references/code-guide.md +127 -0
  45. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-redis-config/SKILL.md +39 -0
  46. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-redis-config/references/code-guide.md +55 -0
  47. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-session-auth/SKILL.md +35 -0
  48. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-session-auth/references/code-guide.md +108 -0
  49. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-test/SKILL.md +37 -0
  50. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-gen-test/references/code-guide.md +125 -0
  51. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-setup-config/SKILL.md +37 -0
  52. drogon_claude_plugin-0.3.0/src/drogon_plugin/drogon_plugin_assets/skills/drogon-setup-config/references/code-guide.md +92 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vilas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # wheel 资产打包清单(assets 由 scripts/sync-assets.py 生成)
2
+ recursive-include src/drogon_plugin/drogon_plugin_assets *
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: drogon-claude-plugin
3
+ Version: 0.3.0
4
+ Summary: Drogon C++ backend Claude Code plugin - rules & code generation skills, plus a CLI installer (install/verify/uninstall)
5
+ Author: voidvec
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 vilas
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/voidvec/drogon-claude-plugin
29
+ Project-URL: Repository, https://github.com/voidvec/drogon-claude-plugin
30
+ Project-URL: Documentation, https://github.com/voidvec/drogon-claude-plugin#readme
31
+ Project-URL: Changelog, https://github.com/voidvec/drogon-claude-plugin/blob/main/CHANGELOG.md
32
+ Keywords: drogon,claude-code,claude,plugin,cpp,c++,async,web-framework,backend
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Environment :: Console
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Topic :: Software Development :: Code Generators
45
+ Requires-Python: >=3.9
46
+ Description-Content-Type: text/markdown; charset=UTF-8
47
+ License-File: LICENSE
48
+ Dynamic: license-file
49
+
50
+ # drogon-claude-plugin
51
+
52
+ > **Drogon C++ 后端开发的 Claude Code 插件** — 提供 AI 辅助开发规则与代码生成技能,让 AI 写出正确的异步代码,避开回调/事件循环等高频陷阱。
53
+
54
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
55
+ [![PyPI version](https://img.shields.io/pypi/v/drogon-claude-plugin.svg)](https://pypi.org/project/drogon-claude-plugin/)
56
+ [![npm version](https://img.shields.io/npm/v/drogon-claude-plugin.svg)](https://www.npmjs.com/package/drogon-claude-plugin)
57
+ [![Claude Code](https://img.shields.io/badge/Claude%20Code-plugin-8A2BE2)](https://docs.anthropic.com/en/docs/claude-code/plugins)
58
+
59
+ 基于 [Drogon](https://github.com/drogonframework/drogon) C++ HTTP 框架的应用项目提供 **AI 辅助开发规则与代码生成技能**,让 AI 写出正确的异步代码,避开回调/事件循环等高频陷阱。
60
+
61
+ ## 安装
62
+
63
+ ### 方式 A:通过 marketplace(推荐)
64
+
65
+ ```bash
66
+ # 添加 marketplace 源(首次)
67
+ claude plugin marketplace add https://github.com/voidvec/drogon-claude-plugin
68
+
69
+ # 安装插件
70
+ claude plugin install drogon
71
+
72
+ # 更新到最新版
73
+ claude plugin update drogon
74
+ ```
75
+
76
+ ### 方式 B:通过 npm / PyPI(CLI 安装器)
77
+
78
+ ```bash
79
+ # npm
80
+ npx drogon-claude-plugin install
81
+
82
+ # 或 PyPI
83
+ pipx install drogon-claude-plugin
84
+ drogon-plugin install
85
+ ```
86
+
87
+ > 两种包共用同一份插件资产,CLI 提供 `install` / `verify` / `uninstall` 子命令,详见 [CLI 安装器](#--cli-安装器)。
88
+
89
+ ### 方式 C:本地安装
90
+
91
+ ```bash
92
+ git clone https://github.com/voidvec/drogon-claude-plugin
93
+ cd <你的 drogon 项目>
94
+ claude plugin install ../drogon-claude-plugin --scope project
95
+ ```
96
+
97
+ ### 验证安装
98
+
99
+ ```bash
100
+ claude plugin details drogon
101
+ ```
102
+
103
+ 应显示 17 个技能和 2 个钩子(SessionStart + PostToolUse)。
104
+
105
+ ## CLI 安装器
106
+
107
+ `drogon-claude-plugin` 同时发布到 [npm](https://www.npmjs.com/package/drogon-claude-plugin) 与 [PyPI](https://pypi.org/project/drogon-claude-plugin/),两种包内置同一份插件资产(skills / hooks / CLAUDE.md / .claude-plugin),并提供一致的命令行界面(bin 名均为 `drogon-plugin`):
108
+
109
+ | 命令 | 作用 |
110
+ |------|------|
111
+ | `drogon-plugin install [--scope project\|user\|local]` | 将插件资产拷贝到当前项目(或指定 scope),并提示执行 `claude plugin install` 启用 |
112
+ | `drogon-plugin verify` | 校验插件的技能数 / 钩子 / manifest,输出结构报告 |
113
+ | `drogon-plugin uninstall` | 从当前项目(或由 `--target` 指定目录)移除已安装的插件资产 |
114
+ | `drogon-plugin version` | 显示 CLI 与内置插件版本 |
115
+
116
+ 安装器只负责**分发与落盘**,不替换 Claude Code 官方插件机制——启用插件仍走 `claude plugin install`。
117
+
118
+ ## 功能组件
119
+
120
+ ### 规则层(CLAUDE.md,自动注入会话上下文)
121
+
122
+ CLAUDE.md 采用**精简路由**设计:只保留跨所有任务的顶层纪律(异步回调模型、事件循环模型)+ Skill 路由表,**详细知识(模板、API 速查、配置格式、禁止模式)全部下沉到各 Skill 的 `references/code-guide.md` 按需加载**,避免常驻占用上下文。
123
+
124
+ 顶层纪律覆盖:
125
+
126
+ - **A 异步回调模型**:回调恰好一次、按值捕获、禁阻塞、优先协程、异常安全
127
+ - **B 事件循环模型(Trantor IO)**:不阻塞循环、重活走线程池、跨循环共享状态加锁
128
+ - **通用纪律**:所有 I/O 异步、异步操作双回调、异常不逃逸 handler、配置加载 try/catch、键名严格
129
+
130
+ ### 代码生成技能(17 个)
131
+
132
+ 每个技能提供准确的 drogon API 用法、代码模板与常犯错误警告。遇到对应任务时 AI 主动调用,按需加载详细知识:
133
+
134
+ | 技能 | 用途 |
135
+ |------|------|
136
+ | `drogon-create-controller` | 生成控制器(Simple/Http/WebSocket),含路径前缀差异、`:param`、自动注册 |
137
+ | `drogon-gen-cmake` | 生成 CMakeLists.txt,含 Conan、插件过滤器编译 |
138
+ | `drogon-gen-csp-view` | 生成 CSP 视图模板,含 `drogon_ctl create view` 管线、布局 |
139
+ | `drogon-gen-db-config` | 生成数据库配置,含键名黑名单、SQL 注入防护、运行期异常 |
140
+ | `drogon-gen-filter` | 生成 Filter 请求拦截器 |
141
+ | `drogon-gen-middleware` | 生成 Middleware 处理链 |
142
+ | `drogon-gen-plugin` | 生成 Plugin 系统级扩展(连接池/SDK 初始化),含三者职责边界 |
143
+ | `drogon-gen-orm-crud` | 生成 ORM CRUD 代码,含禁 `execSqlSync`、事务纪律 |
144
+ | `drogon-gen-redis-config` | 生成 Redis 配置 + 单例/异步/订阅防泄漏用法 |
145
+ | `drogon-gen-test` | 生成 DROGON_TEST 测试,含断言宏、CMake 扫描 |
146
+ | `drogon-setup-config` | 生成完整配置文件,含路径解析、键名黑名单、多环境 |
147
+ | `drogon-gen-session-auth` | 生成 Session 登录/登出/鉴权 handler(防 fixation) |
148
+ | `drogon-gen-file-upload` | 生成文件上传 handler(MultiPartParser + 校验 + 落盘) |
149
+ | `drogon-gen-advice` | 生成 AOP Advice(11 切面,拦截型/观察型) |
150
+ | `drogon-gen-coroutine-handler` | 生成协程 handler/中间件/ORM(参数按值,区分 Task/AsyncTask,含 `forwardCoro`) |
151
+ | `drogon-gen-http-client` | 生成出站 HttpClient 调用(异步/协程/反向代理) |
152
+ | `drogon-gen-lambda-handler` | 生成 `registerHandler` lambda 路由(`{N}` 参数绑定) |
153
+
154
+ ### 自动化检测钩子(PostToolUse)
155
+
156
+ 在 AI 编辑文件后自动扫描 drogon API 违规:
157
+
158
+ | 文件类型 | 检测项 |
159
+ |---------|--------|
160
+ | `.h/.cc/.cpp` | `FILTER_ADD`、`ADD_MIDDLEWARE`、`METHOD_LIST_ADD`、`createDbClient`、`AsyncTask`+`co_await` 未兜异常、回调式 `HttpMiddleware` 内 `co_await`、同步 `sendRequest` 死锁、`session->operator[]`、Advice 在 handler 内注册 |
161
+ | `.csp` | `{{ }}`、`<%raw%>`、`<%viewpath`、`@@key@@`、`<%extends`、`{% if %}` |
162
+ | `config.json/.yaml` | `"password"`、`"username"`、`"ssl": "字符串"` |
163
+ | `test*.cc` | `done()`、`ASSERT_*`、`createDbClient` |
164
+
165
+ > v0.2.0 修复:C++ 标识符检测改为大小写敏感(不再误报 `isDone()`);移除与 CLAUDE.md 示例冲突的 callback 变量名硬约束。
166
+
167
+ ## 使用
168
+
169
+ 在 drogon 项目中启用插件后,AI 自动生效。典型对话:
170
+
171
+ ```
172
+ > 创建一个 /api/users 的 REST 控制器
173
+ AI: [使用 drogon-create-controller 技能] 生成 UserController.h/.cc...
174
+
175
+ > 添加一个 JWT 认证过滤器
176
+ AI: [使用 drogon-gen-filter 技能] 生成 JwtAuthFilter.h + registerFilter()...
177
+
178
+ > 写一个测试验证用户注册接口
179
+ AI: [使用 drogon-gen-test 技能] 生成 DROGON_TEST(UserRegister)...
180
+
181
+ > 这个 handler 代码有问题吗?
182
+ AI: [对照 CLAUDE.md 异步回调纪律] 这个 handler 的提前返回路径没有调用 callback...
183
+ ```
184
+
185
+ ## 前提
186
+
187
+ - Claude Code CLI 已安装
188
+ - 插件用于 **依赖 drogon 框架的应用项目**(drogon 本身作为库被安装)
189
+ - Python 3 在 PATH 中(PostToolUse 钩子需要)
190
+
191
+ ## 仓库结构
192
+
193
+ ```
194
+ ├── .claude-plugin/
195
+ │ ├── plugin.json
196
+ │ └── marketplace.json
197
+ ├── .github/workflows/
198
+ │ ├── ci.yml # 插件结构/CLI 冒烟测试
199
+ │ └── publish.yml # tag 触发 → PyPI + npm + GitHub Release
200
+ ├── hooks/
201
+ │ ├── hooks.json
202
+ │ └── posttooluse.py
203
+ ├── src/drogon_plugin/ # PyPI 包(CLI 安装器)
204
+ │ ├── __init__.py
205
+ │ └── cli.py
206
+ ├── npm/ # npm 包(CLI 安装器)
207
+ │ ├── package.json
208
+ │ └── bin/cli.js
209
+ ├── skills/
210
+ │ ├── drogon-create-controller/
211
+ │ ├── drogon-gen-advice/
212
+ │ ├── drogon-gen-cmake/
213
+ │ ├── drogon-gen-coroutine-handler/
214
+ │ ├── drogon-gen-csp-view/
215
+ │ ├── drogon-gen-db-config/
216
+ │ ├── drogon-gen-file-upload/
217
+ │ ├── drogon-gen-filter/
218
+ │ ├── drogon-gen-http-client/
219
+ │ ├── drogon-gen-lambda-handler/
220
+ │ ├── drogon-gen-middleware/
221
+ │ ├── drogon-gen-orm-crud/
222
+ │ ├── drogon-gen-plugin/
223
+ │ ├── drogon-gen-redis-config/
224
+ │ ├── drogon-gen-session-auth/
225
+ │ ├── drogon-gen-test/
226
+ │ └── drogon-setup-config/
227
+ ├── CLAUDE.md
228
+ ├── LICENSE
229
+ ├── README.md
230
+ └── pyproject.toml # PyPI 打包配置
231
+ ```
232
+
233
+ ## 许可
234
+
235
+ MIT — 详见 [LICENSE](LICENSE)。
@@ -0,0 +1,186 @@
1
+ # drogon-claude-plugin
2
+
3
+ > **Drogon C++ 后端开发的 Claude Code 插件** — 提供 AI 辅助开发规则与代码生成技能,让 AI 写出正确的异步代码,避开回调/事件循环等高频陷阱。
4
+
5
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![PyPI version](https://img.shields.io/pypi/v/drogon-claude-plugin.svg)](https://pypi.org/project/drogon-claude-plugin/)
7
+ [![npm version](https://img.shields.io/npm/v/drogon-claude-plugin.svg)](https://www.npmjs.com/package/drogon-claude-plugin)
8
+ [![Claude Code](https://img.shields.io/badge/Claude%20Code-plugin-8A2BE2)](https://docs.anthropic.com/en/docs/claude-code/plugins)
9
+
10
+ 基于 [Drogon](https://github.com/drogonframework/drogon) C++ HTTP 框架的应用项目提供 **AI 辅助开发规则与代码生成技能**,让 AI 写出正确的异步代码,避开回调/事件循环等高频陷阱。
11
+
12
+ ## 安装
13
+
14
+ ### 方式 A:通过 marketplace(推荐)
15
+
16
+ ```bash
17
+ # 添加 marketplace 源(首次)
18
+ claude plugin marketplace add https://github.com/voidvec/drogon-claude-plugin
19
+
20
+ # 安装插件
21
+ claude plugin install drogon
22
+
23
+ # 更新到最新版
24
+ claude plugin update drogon
25
+ ```
26
+
27
+ ### 方式 B:通过 npm / PyPI(CLI 安装器)
28
+
29
+ ```bash
30
+ # npm
31
+ npx drogon-claude-plugin install
32
+
33
+ # 或 PyPI
34
+ pipx install drogon-claude-plugin
35
+ drogon-plugin install
36
+ ```
37
+
38
+ > 两种包共用同一份插件资产,CLI 提供 `install` / `verify` / `uninstall` 子命令,详见 [CLI 安装器](#--cli-安装器)。
39
+
40
+ ### 方式 C:本地安装
41
+
42
+ ```bash
43
+ git clone https://github.com/voidvec/drogon-claude-plugin
44
+ cd <你的 drogon 项目>
45
+ claude plugin install ../drogon-claude-plugin --scope project
46
+ ```
47
+
48
+ ### 验证安装
49
+
50
+ ```bash
51
+ claude plugin details drogon
52
+ ```
53
+
54
+ 应显示 17 个技能和 2 个钩子(SessionStart + PostToolUse)。
55
+
56
+ ## CLI 安装器
57
+
58
+ `drogon-claude-plugin` 同时发布到 [npm](https://www.npmjs.com/package/drogon-claude-plugin) 与 [PyPI](https://pypi.org/project/drogon-claude-plugin/),两种包内置同一份插件资产(skills / hooks / CLAUDE.md / .claude-plugin),并提供一致的命令行界面(bin 名均为 `drogon-plugin`):
59
+
60
+ | 命令 | 作用 |
61
+ |------|------|
62
+ | `drogon-plugin install [--scope project\|user\|local]` | 将插件资产拷贝到当前项目(或指定 scope),并提示执行 `claude plugin install` 启用 |
63
+ | `drogon-plugin verify` | 校验插件的技能数 / 钩子 / manifest,输出结构报告 |
64
+ | `drogon-plugin uninstall` | 从当前项目(或由 `--target` 指定目录)移除已安装的插件资产 |
65
+ | `drogon-plugin version` | 显示 CLI 与内置插件版本 |
66
+
67
+ 安装器只负责**分发与落盘**,不替换 Claude Code 官方插件机制——启用插件仍走 `claude plugin install`。
68
+
69
+ ## 功能组件
70
+
71
+ ### 规则层(CLAUDE.md,自动注入会话上下文)
72
+
73
+ CLAUDE.md 采用**精简路由**设计:只保留跨所有任务的顶层纪律(异步回调模型、事件循环模型)+ Skill 路由表,**详细知识(模板、API 速查、配置格式、禁止模式)全部下沉到各 Skill 的 `references/code-guide.md` 按需加载**,避免常驻占用上下文。
74
+
75
+ 顶层纪律覆盖:
76
+
77
+ - **A 异步回调模型**:回调恰好一次、按值捕获、禁阻塞、优先协程、异常安全
78
+ - **B 事件循环模型(Trantor IO)**:不阻塞循环、重活走线程池、跨循环共享状态加锁
79
+ - **通用纪律**:所有 I/O 异步、异步操作双回调、异常不逃逸 handler、配置加载 try/catch、键名严格
80
+
81
+ ### 代码生成技能(17 个)
82
+
83
+ 每个技能提供准确的 drogon API 用法、代码模板与常犯错误警告。遇到对应任务时 AI 主动调用,按需加载详细知识:
84
+
85
+ | 技能 | 用途 |
86
+ |------|------|
87
+ | `drogon-create-controller` | 生成控制器(Simple/Http/WebSocket),含路径前缀差异、`:param`、自动注册 |
88
+ | `drogon-gen-cmake` | 生成 CMakeLists.txt,含 Conan、插件过滤器编译 |
89
+ | `drogon-gen-csp-view` | 生成 CSP 视图模板,含 `drogon_ctl create view` 管线、布局 |
90
+ | `drogon-gen-db-config` | 生成数据库配置,含键名黑名单、SQL 注入防护、运行期异常 |
91
+ | `drogon-gen-filter` | 生成 Filter 请求拦截器 |
92
+ | `drogon-gen-middleware` | 生成 Middleware 处理链 |
93
+ | `drogon-gen-plugin` | 生成 Plugin 系统级扩展(连接池/SDK 初始化),含三者职责边界 |
94
+ | `drogon-gen-orm-crud` | 生成 ORM CRUD 代码,含禁 `execSqlSync`、事务纪律 |
95
+ | `drogon-gen-redis-config` | 生成 Redis 配置 + 单例/异步/订阅防泄漏用法 |
96
+ | `drogon-gen-test` | 生成 DROGON_TEST 测试,含断言宏、CMake 扫描 |
97
+ | `drogon-setup-config` | 生成完整配置文件,含路径解析、键名黑名单、多环境 |
98
+ | `drogon-gen-session-auth` | 生成 Session 登录/登出/鉴权 handler(防 fixation) |
99
+ | `drogon-gen-file-upload` | 生成文件上传 handler(MultiPartParser + 校验 + 落盘) |
100
+ | `drogon-gen-advice` | 生成 AOP Advice(11 切面,拦截型/观察型) |
101
+ | `drogon-gen-coroutine-handler` | 生成协程 handler/中间件/ORM(参数按值,区分 Task/AsyncTask,含 `forwardCoro`) |
102
+ | `drogon-gen-http-client` | 生成出站 HttpClient 调用(异步/协程/反向代理) |
103
+ | `drogon-gen-lambda-handler` | 生成 `registerHandler` lambda 路由(`{N}` 参数绑定) |
104
+
105
+ ### 自动化检测钩子(PostToolUse)
106
+
107
+ 在 AI 编辑文件后自动扫描 drogon API 违规:
108
+
109
+ | 文件类型 | 检测项 |
110
+ |---------|--------|
111
+ | `.h/.cc/.cpp` | `FILTER_ADD`、`ADD_MIDDLEWARE`、`METHOD_LIST_ADD`、`createDbClient`、`AsyncTask`+`co_await` 未兜异常、回调式 `HttpMiddleware` 内 `co_await`、同步 `sendRequest` 死锁、`session->operator[]`、Advice 在 handler 内注册 |
112
+ | `.csp` | `{{ }}`、`<%raw%>`、`<%viewpath`、`@@key@@`、`<%extends`、`{% if %}` |
113
+ | `config.json/.yaml` | `"password"`、`"username"`、`"ssl": "字符串"` |
114
+ | `test*.cc` | `done()`、`ASSERT_*`、`createDbClient` |
115
+
116
+ > v0.2.0 修复:C++ 标识符检测改为大小写敏感(不再误报 `isDone()`);移除与 CLAUDE.md 示例冲突的 callback 变量名硬约束。
117
+
118
+ ## 使用
119
+
120
+ 在 drogon 项目中启用插件后,AI 自动生效。典型对话:
121
+
122
+ ```
123
+ > 创建一个 /api/users 的 REST 控制器
124
+ AI: [使用 drogon-create-controller 技能] 生成 UserController.h/.cc...
125
+
126
+ > 添加一个 JWT 认证过滤器
127
+ AI: [使用 drogon-gen-filter 技能] 生成 JwtAuthFilter.h + registerFilter()...
128
+
129
+ > 写一个测试验证用户注册接口
130
+ AI: [使用 drogon-gen-test 技能] 生成 DROGON_TEST(UserRegister)...
131
+
132
+ > 这个 handler 代码有问题吗?
133
+ AI: [对照 CLAUDE.md 异步回调纪律] 这个 handler 的提前返回路径没有调用 callback...
134
+ ```
135
+
136
+ ## 前提
137
+
138
+ - Claude Code CLI 已安装
139
+ - 插件用于 **依赖 drogon 框架的应用项目**(drogon 本身作为库被安装)
140
+ - Python 3 在 PATH 中(PostToolUse 钩子需要)
141
+
142
+ ## 仓库结构
143
+
144
+ ```
145
+ ├── .claude-plugin/
146
+ │ ├── plugin.json
147
+ │ └── marketplace.json
148
+ ├── .github/workflows/
149
+ │ ├── ci.yml # 插件结构/CLI 冒烟测试
150
+ │ └── publish.yml # tag 触发 → PyPI + npm + GitHub Release
151
+ ├── hooks/
152
+ │ ├── hooks.json
153
+ │ └── posttooluse.py
154
+ ├── src/drogon_plugin/ # PyPI 包(CLI 安装器)
155
+ │ ├── __init__.py
156
+ │ └── cli.py
157
+ ├── npm/ # npm 包(CLI 安装器)
158
+ │ ├── package.json
159
+ │ └── bin/cli.js
160
+ ├── skills/
161
+ │ ├── drogon-create-controller/
162
+ │ ├── drogon-gen-advice/
163
+ │ ├── drogon-gen-cmake/
164
+ │ ├── drogon-gen-coroutine-handler/
165
+ │ ├── drogon-gen-csp-view/
166
+ │ ├── drogon-gen-db-config/
167
+ │ ├── drogon-gen-file-upload/
168
+ │ ├── drogon-gen-filter/
169
+ │ ├── drogon-gen-http-client/
170
+ │ ├── drogon-gen-lambda-handler/
171
+ │ ├── drogon-gen-middleware/
172
+ │ ├── drogon-gen-orm-crud/
173
+ │ ├── drogon-gen-plugin/
174
+ │ ├── drogon-gen-redis-config/
175
+ │ ├── drogon-gen-session-auth/
176
+ │ ├── drogon-gen-test/
177
+ │ └── drogon-setup-config/
178
+ ├── CLAUDE.md
179
+ ├── LICENSE
180
+ ├── README.md
181
+ └── pyproject.toml # PyPI 打包配置
182
+ ```
183
+
184
+ ## 许可
185
+
186
+ MIT — 详见 [LICENSE](LICENSE)。
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "drogon-claude-plugin"
7
+ version = "0.3.0"
8
+ description = "Drogon C++ backend Claude Code plugin - rules & code generation skills, plus a CLI installer (install/verify/uninstall)"
9
+ readme = { file = "README.md", content-type = "text/markdown; charset=UTF-8" }
10
+ requires-python = ">=3.9"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "voidvec" }]
13
+ keywords = ["drogon", "claude-code", "claude", "plugin", "cpp", "c++", "async", "web-framework", "backend"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Software Development :: Code Generators",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/voidvec/drogon-claude-plugin"
31
+ Repository = "https://github.com/voidvec/drogon-claude-plugin"
32
+ Documentation = "https://github.com/voidvec/drogon-claude-plugin#readme"
33
+ Changelog = "https://github.com/voidvec/drogon-claude-plugin/blob/main/CHANGELOG.md"
34
+
35
+ [project.scripts]
36
+ drogon-plugin = "drogon_plugin.cli:main"
37
+
38
+ [tool.setuptools]
39
+ package-dir = { "" = "src" }
40
+ packages = ["drogon_plugin"]
41
+ include-package-data = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+