drogon-claude-plugin CLAUDE.md

Project instructions for building Drogon backends with C++, covering asynchronous request handling, the Trantor event-loop system, and routing work to related skills. Drogon is a C++ web framework, while an event loop runs network work without blocking its processing thread.

In plain words
What is it for?
Use it when writing Drogon request handlers, choosing callbacks or coroutines, handling errors, avoiding blocking database or file operations, and finding the right detailed coding guide.
Why use it?
It helps avoid common failures such as sending a response twice, leaving a request without a response, blocking the event loop, or allowing exceptions to escape a handler.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/voidvec/drogon-claude-plugin/claude-md
Clone the repo
git clone --depth 1 https://github.com/voidvec/drogon-claude-plugin
Per session 1,799 This file is loaded in full into every session.
When invoked 1,799 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01799 $0.01799
Opus 5 $0.00899 $0.00899
Sonnet 5 $0.00360 $0.00360
Haiku 4.5 $0.00180 $0.00180

Measured yesterday against content hash f4eae212034d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

drogon-claude-plugin CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 61 lines

How it starts

The opening of the file, as written. The whole thing — 61 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Drogon 后端开发规则

本文件由 drogon Claude Code 插件提供。规则针对 drogon v1.9.13。

本文只列顶层纪律(跨所有任务的高频陷阱)+ Skill 路由表。具体模板、API 速查、配置格式等详细知识已下沉到各 Skill 的 references/code-guide.md,按需加载——遇到对应任务时主动调用对应 Skill,不要凭记忆写代码。

A. 异步回调模型(所有 handler 的最高纪律)

Drogon 的每个 handler 接收一个 std::function<void(const HttpResponsePtr &)> 回调。响应的发出只与回调是否被调用有关,与 handler 是否 return 无关

  1. 恰好一次:每个 handler 必须在所有代码路径(含错误/异常/提前返回)上恰好调用一次 callback
  2. 绝不重复:禁止第二次调用 callback(未定义行为,可能重复响应或连接污染)。
  3. 禁止 handler 内同步阻塞:不得在 handler 内做阻塞式同步 I/O(同步读 DB、sleep、长计算、阻塞文件读写)后再 callback。改用 drogon 异步 API,或丢到线程池,完成处就近 callback
  4. 按值捕获回调:异步/延迟场景下 callback 必须按值捕获进闭包,确保生命周期超出 handler 栈帧;悬空回调会崩溃。
  5. 异常不得逃逸 handler:用 try/catch 包裹业务逻辑,每个 catch 路径都调 callback(错误响应)。框架默认异常处理器只是兜底,不能替代你对 callback 的保证。
  6. 优先协程__cpp_impl_coroutine 已定义且 CMake USE_COROUTINE=ON 时,优先用协程 handler(Task<HttpResponsePtr>,框架负责异常与响应交付)。AsyncTask 抛未处理异常会 std::terminate,用时必须 try/catch。协程细节用 drogon-gen-coroutine-handler skill。

B. 事件循环模型(Trantor IO)

Drogon 跑在 trantor 的事件循环上;配置项 number_of_threads 决定循环数(值为 0 表示按 CPU 硬件并发数自动设置),每条连接钉在某个循环上。

  1. 事件循环线程不可阻塞:禁止在事件循环线程做任何阻塞工作(同步 DB 调用、sleep、长计算、阻塞文件 I/O)——会拖死同一循环上所有其他连接。
  2. 重/阻塞活儿走线程池:把重活儿交给独立线程池;完成后用 runInLoop 派回连接所属的事件循环,再在那里 callback
  3. 跨循环共享状态加锁:跨循环共享的状态必须加锁;更优是保持状态"循环局部",或用 runInLoop 派发到归属循环访问。

Skill 路由表

遇到下列任务时,主动调用对应 Skill——详细模板、API 签名、禁止模式清单都在 skill 的 references/code-guide.md 里,按需加载以节省上下文。

任务 Skill 说明
创建控制器(.h+.cc) drogon-create-controller simple/http/websocket;含路径前缀差异、:param、WebSocket 宏、自动注册、生命周期纪律
现代 lambda 内联路由 drogon-gen-lambda-handler app().registerHandler + {N} 参数绑定;与经典宏二选一不混用
ORM CRUD 代码 drogon-gen-orm-crud 回调式 + 协程式;含禁 execSqlSync、双回调、事务纪律
数据库配置 drogon-gen-db-config PG/MySQL/SQLite;含键名黑名单、loadConfigFile 异常、运行期 DrogonDbException、SQL 注入防护
Redis 配置 + 用法 drogon-gen-redis-config 配置格式 + 单例/异步/异常/订阅防泄漏运行期纪律
通用配置文件 drogon-setup-config listeners/app/SSL/会话;含路径解析、加载异常、键名黑名单、多环境
CMake 构建 drogon-gen-cmake find_package/ORM/协程;含 Conan、插件过滤器编译、禁硬编码路径
协程 handler/中间件 drogon-gen-coroutine-handler Task/AsyncTask 语义、参数按值生命周期、forwardCoro
HTTP 出站请求 drogon-gen-http-client 异步/协程/反向代理 forward;含同步 sendRequest 死锁保护、timeout
CSP 视图模板 drogon-gen-csp-view 语法速查、布局、HttpViewData;含 drogon_ctl create view 管线、禁拼 HTML
Filter(请求拦截) drogon-gen-filter 认证/限流/输入校验;含 doFilter(fcb,fccb)AutoCreation=false
Middleware(全局处理链) drogon-gen-middleware 日志/CORS/性能计时;含 invoke(nextCb,mcb)
Plugin(系统级扩展) drogon-gen-plugin 连接池/第三方 SDK 初始化;含三者职责边界对比
Advice(AOP 切面) drogon-gen-advice 11 个内建切面;含拦截型 vs 观察型、注册时机
文件上传 drogon-gen-file-upload MultiPart 解析+校验+落盘;含 setClientMaxBodySize、路径穿越
Session 登录鉴权 drogon-gen-session-auth 登录/登出/鉴权;含 changeSessionIdToClient 防 fixation
测试 drogon-gen-test DROGON_TEST;含断言宏、异步测试、CMake 扫描、addDbClient

Read the full file on GitHub · 61 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 61 lines · 1,799 tokens per session scan A f4eae212034d

Subscribe to this mod's changes

drogon-claude-plugin CLAUDE.md is an instructions file published in the GitHub repository voidvec/drogon-claude-plugin (1 stars, last pushed 5d ago), licensed MIT. It adds 1,799 tokens to every session, about $0.0090 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.