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.
npx agentmods add skills/davidyichengwei/agentic-engineering-framework/bp-coding-best-practicesnpx skills add davidYichengWei/agentic-engineering-framework --skill bp-coding-best-practicesgit clone --depth 1 https://github.com/davidYichengWei/agentic-engineering-frameworkWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/davidyichengwei/agentic-engineering-framework/bp-coding-best-practices)<a href="https://agentmods.dev/skills/davidyichengwei/agentic-engineering-framework/bp-coding-best-practices"><img src="https://agentmods.dev/badge/skills/davidyichengwei/agentic-engineering-framework/bp-coding-best-practices.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00045 | $0.01213 |
| Opus 5 | $0.00023 | $0.00607 |
| Sonnet 5 | $0.00009 | $0.00243 |
| Haiku 4.5 | $0.00005 | $0.00121 |
Grade A, and why
bp-coding-best-practices 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 4d ago.
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.
How it starts
The opening of the file, as written. The whole thing — 128 lines — stays where its author put it; the contents beside it link to each section on GitHub.
通用编码最佳实践
设计原则(SOLID、设计模式):参见 bp-component-design Skill
特定语言/模块规范:参见相应的 standards skills
命名
| 原则 | 说明 |
|---|---|
| 自解释 | retryCount 而非 n |
| 无魔法数字 | const int SECONDS_IN_DAY = 86400; |
| 布尔命名 | isValid, hasAccess(问题形式) |
| 作用域匹配 | 小作用域可短(i),大作用域要描述性 |
函数设计
| 原则 | 说明 |
|---|---|
| 单一职责 | 一个函数做一件事;名字需要 "And" 说明做太多了 |
| 参数精简 | 超过 3-4 个参数 → 考虑结构体封装 |
| const 正确 | 不修改的参数标 const,防止意外修改 |
控制流
Guard Clause:失败情况先处理并返回,主逻辑保持左对齐
Early Return:显式采用 early return 编程范式,尽量将可 early return 的检查前置。
// ❌ 深层嵌套
if (order != nullptr) {
if (order->isValid()) {
if (order->hasItems()) {
// main logic
}
}
}
// ✅ Guard Clause
if (order == nullptr) return;
if (!order->isValid()) return;
if (!order->hasItems()) return;
// main logic (not nested)
资源安全
| 原则 | 说明 |
|---|---|
| RAII | 资源生命周期绑定对象生命周期,避免手动清理分散在多条路径 |
| 所有权显式 | 区分 owner 与 borrower,避免隐式转移所有权 |
| 窄作用域 | 变量声明靠近首次使用,减少悬空与误用概率 |
跨语言场景统一要求:新增分支/返回路径时,必须检查资源契约是否闭环(释放类资源 + 触发类资源)。
新增返回路径的契约检查
当新增 return、early exit 或新分支时,必须逐一检查函数入口处获取的所有"契约性资源"。
契约性资源:函数持有但不拥有、需要在特定时机交还/触发的资源:
- Closure/Callback(需要 Run)
- 锁(需要 Unlock)
- 引用计数(需要 Release)
- 事务上下文(需要 Commit/Rollback/清理)
- 幂等标记/Nonce(需要 Complete)
- 注册到外部管理器的对象(需要 Remove/Unregister)
检查方法:
- 识别:在函数开头找所有"获取但需要交还"的东西
- 对照:找一个功能相似的现有返回路径,逐行对比它处理了哪些资源
- 分类:这个新路径是成功、失败、还是新的第三种状态?现有 ownership 注释是否覆盖?
| ❌ 反例 | ✅ 正例 |
|---|---|
| 新分支只清理了数据结构,忘了 callback 的执行契约 | 对照已有的 early return 路径,发现它调用了 callback->Run(),新路径也需要 |
| 假设"返回成功后调用方会处理 closure" | 检查调用方逻辑,确认 closure 执行责任的真实归属 |
| 只关注"要释放什么",忽略"要触发什么" | 同时检查释放类资源(锁、内存)和触发类资源(回调、事件) |
注释
| 场景 | 做法 |
|---|---|
| 何时写 | 仅当意图不明显时;复杂算法;公共 API |
| 写什么 | Why(为什么这样做),不是 What(做了什么) |
| TODO | 包含上下文和负责人 |
// ❌ 复述代码
// Increment i by 1
++i;
// ✅ 解释意图
// Skip index 0 because it is the sentinel slot.
for (size_t i = 1; i < slots.size(); ++i) { ... }
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 4d ago First seen · 128 lines · 45 tokens per session scan A 0387e364e3f1
bp-coding-best-practices is a skill published in the GitHub repository davidYichengWei/agentic-engineering-framework (158 stars, last pushed 5mo ago), licensed MIT. It adds 45 tokens to every session and 1,213 once invoked, about $0.0002 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-30.
Other skills, from other repositories
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
auto-perf-optimize
Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.
chat-perf
Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.
chat-pet-sprite-creation
Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.
cpu-profile-analysis
Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…