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 rules/wangqiqi/cursor-ai-rules/c-advancedgit 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/c-advanced)<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/c-advanced"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/c-advanced.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.00000 | $0.02940 |
| Opus 5 | $0.00000 | $0.01470 |
| Sonnet 5 | $0.00000 | $0.00588 |
| Haiku 4.5 | $0.00000 | $0.00294 |
Grade A, and why
c-advanced 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 — 447 lines — stays where its author put it; the contents beside it link to each section on GitHub.
C 高级实践
本文档是从 @c-basics 分割出来的高级主题部分,涵盖测试策略、性能优化、安全实践和最佳实践。
⚠️ 执行原则
MUST 遵循以下C高级开发准则:
- MUST 正确管理内存和资源
- NEVER 忽略缓冲区溢出风险
- ALWAYS 使用静态分析工具
- DO NOT 使用不安全的函数
- MUST 进行性能测试和优化
- ALWAYS 验证跨平台兼容性
编译优化
// 条件编译优化
#ifdef __GNUC__
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif
// 内联函数优化
static inline int fast_max(int a, int b) {
return LIKELY(a > b) ? a : b;
}
// 分支预测优化
int process_data_optimized(const int* data, size_t count) {
int sum = 0;
for (size_t i = 0; i < count; ++i) {
if (LIKELY(data[i] > 0)) { // 正数更常见
sum += data[i];
} else {
sum -= data[i]; // 负数处理
}
}
return sum;
}
// SIMD优化 (需要编译器支持)
#ifdef __AVX2__
#include <immintrin.h>
void vector_add_float(float* result, const float* a, const float* b, size_t count) {
size_t i = 0;
// SIMD处理
for (; i + 8 <= count; i += 8) {
__m256 va = _mm256_load_ps(&a[i]);
__m256 vb = _mm256_load_ps(&b[i]);
__m256 vr = _mm256_add_ps(va, vb);
_mm256_store_ps(&result[i], vr);
}
// 处理剩余元素
for (; i < count; ++i) {
result[i] = a[i] + b[i];
}
}
#else
void vector_add_float(float* result, const float* a, const float* b, size_t count) {
for (size_t i = 0; i < count; ++i) {
result[i] = a[i] + b[i];
}
}
#endif
🔒 安全实践
缓冲区溢出防护
#include <string.h>
#include <stdio.h>
// ✅ 推荐:安全的字符串操作
size_t safe_strncpy(char* dest, const char* src, size_t dest_size) {
if (!dest || !src || dest_size == 0) {
return 0;
}
size_t src_len = strnlen(src, dest_size);
if (src_len < dest_size) {
// 源字符串完全适合
memcpy(dest, src, src_len);
dest[src_len] = '\0';
return src_len;
} else {
// 需要截断
memcpy(dest, src, dest_size - 1);
dest[dest_size - 1] = '\0';
return dest_size - 1;
}
}
size_t safe_strncat(char* dest, const char* src, size_t dest_size) {
if (!dest || !src || dest_size == 0) {
return 0;
}
size_t dest_len = strnlen(dest, dest_size);
if (dest_len >= dest_size) {
return 0; // 目标缓冲区已满或无效
}
size_t remaining = dest_size - dest_len;
size_t src_len = strnlen(src, remaining);
memcpy(dest + dest_len, src, src_len);
dest[dest_len + src_len] = '\0';
return src_len;
}
// ✅ 推荐:安全的内存操作
void* safe_memcpy(void* dest, const void* src, size_t count) {
if (!dest || !src) {
return NULL;
}
// 检查重叠
if ((char*)dest < (char*)src + count &&
(char*)src < (char*)dest + count) {
// 重叠,使用memmove
return memmove(dest, src, count);
}
return memcpy(dest, src, count);
}
void* safe_malloc(size_t size) {
if (size == 0) {
size = 1; // 避免分配0字节
}
if (size > SIZE_MAX / 2) {
return NULL; // 防止整数溢出
}
return malloc(size);
}
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 · 447 lines · 0 tokens per session scan A 66ea80c40451
c-advanced is a cursor rule published in the GitHub repository wangqiqi/cursor-ai-rules (16 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,940 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
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.