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/c-basics-memory)<a href="https://agentmods.dev/rules/wangqiqi/cursor-ai-rules/c-basics-memory"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/c-basics-memory/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/c-basics-memory"><img src="https://agentmods.dev/badge/rules/wangqiqi/cursor-ai-rules/c-basics-memory.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.00655 |
| Opus 5.5 | $0.00000 | $0.00262 |
| Sonnet 5.5 | $0.00000 | $0.00131 |
| Haiku 4.5 | $0.00000 | $0.00065 |
Grade A, and why
c-basics-memory 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 3mo 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 — 113 lines — stays where its author put it; the contents beside it link to each section on GitHub.
C 语言内存与资源管理 (Memory)
本规则由
@c-basics引用
错误处理
typedef enum {
ERROR_SUCCESS = 0,
ERROR_INVALID_ARGUMENT,
ERROR_OUT_OF_MEMORY,
ERROR_FILE_NOT_FOUND
} ErrorCode;
#define RETURN_IF_ERROR(expr) \
do { ErrorCode err = (expr); if (err != ERROR_SUCCESS) return err; } while (0)
#define GOTO_IF_ERROR(expr, label) \
do { ErrorCode err = (expr); if (err != ERROR_SUCCESS) goto label; } while (0)
RAII 风格资源管理
typedef struct {
FILE* file;
bool valid;
} FileHandle;
ErrorCode file_handle_open(FileHandle* handle, const char* filename);
void file_handle_close(FileHandle* handle);
// 使用
ErrorCode process_file(const char* filename) {
FileHandle handle = {0};
ErrorCode err = file_handle_open(&handle, filename);
if (err != ERROR_SUCCESS) return err;
// 使用文件...
file_handle_close(&handle);
return ERROR_SUCCESS;
}
goto 清理 (Linux 内核风格)
ErrorCode complex_operation(const char* input) {
void* buffer1 = NULL;
void* buffer2 = NULL;
FileHandle file = {0};
buffer1 = malloc(1024);
if (!buffer1) return ERROR_OUT_OF_MEMORY;
buffer2 = malloc(2048);
if (!buffer2) goto cleanup_buffer1;
if (file_handle_open(&file, input) != ERROR_SUCCESS)
goto cleanup_buffers;
// 主逻辑...
if (fails()) goto cleanup_all;
cleanup_all: file_handle_close(&file);
cleanup_buffers: free(buffer2);
cleanup_buffer1: free(buffer1);
return err;
}
内存池
typedef struct {
void* buffer;
size_t buffer_size;
size_t used;
void** free_list;
size_t free_count;
} MemoryPool;
MemoryPool* memory_pool_create(size_t block_size, size_t block_count);
void* memory_pool_alloc(MemoryPool* pool);
void memory_pool_free(MemoryPool* pool, void* ptr);
void memory_pool_destroy(MemoryPool* pool);
缓存友好结构
#define CACHE_LINE_SIZE 64
typedef struct {
int id;
char padding[60]; // 填充到缓存行
} CacheAlignedItem;
原则
- MUST 配对 malloc/free、fopen/fclose
- MUST 检查分配返回值
- MUST 使用 goto 统一清理多资源
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.
- 3mo ago First seen · 113 lines · 0 tokens per session scan A 2189a4a8a3cb
c-basics-memory is a cursor rule published in the GitHub repository wangqiqi/cursor-ai-rules (16 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 655 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.
c-basics-memory compared with cursor rules from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| c-basics-memorywangqiqi/cursor-ai-rules | Cursor rule | 16 | 6mo ago | MIT | A | 0 | Cursor |
| djangosanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 8d ago | CC0-1.0 | A | 2,043 | Cursor |
| richsanjeed5/awesome-cursor-rules-mdc | Cursor rule | 3.6k | 8d ago | CC0-1.0 | A | 1,749 | Cursor |
| pythonPatrickJS/awesome-cursorrules | Cursor rule | 41k | 6mo ago | CC0-1.0 | A | 734 | Cursor |
| gosupertokens/create-supertokens-app | Cursor rule | 24 | 5d ago | Apache-2.0 | A | 0 | Cursor |
| fastapi-rulesbeel-collab/presets.dev | Cursor rule | 3 | 8d ago | MIT | A | 0 | Cursor |
| shared-librarieskubev2v/forklift-console-plugin | Cursor rule | 11 | today | Apache-2.0 | A | 16 | Cursor |