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.
git clone --depth 1 https://github.com/wangqiqi/cursor-ai-rulesWrote 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/rules/wangqiqi/cursor-ai-rules/cpp-advanced-practices)<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/cpp-advanced-practices"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/cpp-advanced-practices/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/cpp-advanced-practices"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/cpp-advanced-practices.svg" alt="Reviewed on agentmods" width="80" 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.1 | $0.00000 | $0.00616 |
| Opus 5.5 | $0.00000 | $0.00246 |
| Sonnet 5.5 | $0.00000 | $0.00123 |
| Haiku 4.5 | $0.00000 | $0.00062 |
Grade A, and why
cpp-advanced-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 1mo 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.
What it actually says
C++ 最佳实践 (Practices)
本规则由
@cpp-advanced引用
Catch2 单元测试
#include <catch2/catch_test_macros.hpp>
TEST_CASE("MathUtils - Basic", "[math]") {
SECTION("Addition") { REQUIRE(utils.add(2, 3) == 5); }
SECTION("Division by zero") { REQUIRE_THROWS_AS(utils.divide(1.0, 0.0), std::domain_error); }
}
安全实践
void safeCopy(const char* src, char* dst, size_t dstSize) {
size_t srcLen = std::strlen(src);
if (srcLen >= dstSize) throw std::length_error("Buffer overflow");
std::memcpy(dst, src, srcLen + 1);
}
class FileLock {
int fd_;
bool locked_;
public:
explicit FileLock(int fd) : fd_(fd), locked_(false) {
if (lockf(fd_, F_LOCK, 0) == -1) throw std::system_error(...);
locked_ = true;
}
~FileLock() { if (locked_) lockf(fd_, F_ULOCK, 0); }
};
对象池
template<typename T>
class ObjectPool {
std::vector<std::unique_ptr<T>> pool_;
std::vector<T*> available_;
public:
template<typename... Args>
T* acquire(Args&&... args) {
if (!available_.empty()) {
T* obj = available_.back();
available_.pop_back();
return new (obj) T(std::forward<Args>(args)...);
}
pool_.push_back(std::make_unique<T>(std::forward<Args>(args)...));
return pool_.back().get();
}
void release(T* obj) { obj->~T(); available_.push_back(obj); }
};
设计模式 (策略)
class SortStrategy {
public:
virtual void sort(std::vector<int>& data) = 0;
};
class Sorter {
std::unique_ptr<SortStrategy> strategy_;
public:
void setStrategy(std::unique_ptr<SortStrategy> s) { strategy_ = std::move(s); }
void sort(std::vector<int>& data) { if (strategy_) strategy_->sort(data); }
};
原则
- MUST 使用智能指针管理资源
- MUST 进行边界检查
- PREFER C++11/14,C++17+ 待项目成熟
引用: @cpp-advanced
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.
- 1mo ago First seen · 90 lines · 0 tokens per session scan A 3d689b237e0c
cpp-advanced-practices is a cursor rule published in the GitHub repository wangqiqi/cursor-ai-rules (17 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 616 tokens. 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 cursor rules, from other repositories
move-copy-semantics
Avoid std::move(const&) silent copies; use sink-by-value + std::move.
vios-error-security
Error handling and security rules for VIOS C++ code.
cuda
Definitive guidelines for writing high-performance, maintainable, and error-resistant CUDA C++ code, focusing on modern practices, memory management, kernel optimization, and robust error handling.
cpp
Name methods (casing, etc) like "isvalid", "streamtext".
monitor-c-conventions
C coding conventions for HPCPerfStats monitor (C-only).
monitor-c-refactor-standards
Behavior-preserving C refactor standards for HPCPerfStats monitor.