security-lang-cpp

security-lang-cpp is a cursor rule for Cursor from AdobeDocs/ff-services-docs. It costs 0 tokens per session (3,529 once invoked), scanned A, original, Apache-2.0.

A set of rules for writing safer C++ code. It focuses on memory ownership, initialization, resource cleanup, and avoiding undefined behaviour.

In plain words
What is it for?
It guides C++ code generation and review, especially where pointers, dynamic memory, object lifetimes, and resource management are involved.
Why use it?
It helps prevent bugs such as using freed memory, freeing memory twice, leaking resources, or reading uninitialized values.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit It guides C++ code generation and review, especially where pointers, dynamic memory, object lifetimes, and resource management are involved.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/adobedocs/ff-services-docs/security-lang-cpp
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.

Clone the repo
git clone --depth 1 https://github.com/AdobeDocs/ff-services-docs

Made for: Cursor.

Wrote 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.

agentmods badge for security-lang-cpp

README.md
[![agentmods](https://agentmods.dev/badge/rules/adobedocs/ff-services-docs/security-lang-cpp/github.svg)](https://agentmods.dev/rules/adobedocs/ff-services-docs/security-lang-cpp)
Your own site
<a href="https://agentmods.dev/rules/adobedocs/ff-services-docs/security-lang-cpp"><img src="https://agentmods.dev/badge/rules/adobedocs/ff-services-docs/security-lang-cpp/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.

agentmods 80×15 button for security-lang-cpp

Your own site · 80×15
<a href="https://agentmods.dev/rules/adobedocs/ff-services-docs/security-lang-cpp"><img src="https://agentmods.dev/badge/rules/adobedocs/ff-services-docs/security-lang-cpp.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,529 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.03529
Opus 5.5 $0.00000 $0.01412
Sonnet 5.5 $0.00000 $0.00706
Haiku 4.5 $0.00000 $0.00353

Measured 1mo ago against content hash 133472889ee8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

security-lang-cpp 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.

.cursor/rules/security-lang/security-lang-cpp.mdc · 164 lines

How it starts

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

Secure C++ Development

These rules apply to all C++ source and header files in the repository and aim to prevent memory corruption, resource leaks, undefined behavior, and security vulnerabilities through modern C++ best practices.

All violations must include a clear explanation of which rule was triggered and why, to help developers understand and fix the issue effectively.
Generated code must not violate these rules. If a rule is violated, a comment must be added explaining the issue and suggesting a correction.

1. Prevent Use After Free and Double Free (CWE-416, CWE-415)

  • Rule: Use std::unique_ptr, std::shared_ptr, or std::weak_ptr instead of raw new/delete. Never access memory after it has been freed. Do not free the same memory twice. Smart pointers and RAII patterns automatically prevent use-after-free and double-free vulnerabilities.

2. Avoid Raw Pointers for Ownership

  • Rule: Do not use raw pointers (T*) to express ownership. Use smart pointers or containers. Raw pointers should only be used for non-owning references. Always verify non-owning pointers are not null before dereferencing.

3. Initialize All Variables (CWE-824)

  • Rule: Always initialize variables, including pointers, at declaration. Use uniform initialization {} to prevent narrowing conversions. Never leave objects in an indeterminate state. Accessing uninitialized pointers or variables leads to undefined behavior and potential security vulnerabilities.

4. Prevent Use-After-Move

  • Rule: After moving from an object with std::move(), do not access its value unless it has been reassigned. Document moved-from states clearly.

5. Prevent Out-of-Bounds Write and Read (CWE-787, CWE-125, CWE-119, CWE-676)

  • Rule: Use STL containers (std::vector, std::array, std::string, std::span for views) with bounds-checked access (.at()) instead of C-style arrays and manual index looping. When converting legacy C-style arrays, use std::to_array (C++20) to preserve size information and enable bounds-checked access. Never use potentially dangerous functions like strcpy, sprintf, gets, scanf, or other unbounded string functions. Prefer standard algorithms with .at() over unchecked operator[] in security-critical code. Out-of-bounds memory access is a leading cause of exploitable vulnerabilities.

Read the full file on GitHub · 164 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. 1mo ago First seen · 164 lines · 3,529 tokens per session scan A 133472889ee8

Subscribe to this mod's changes

security-lang-cpp is a cursor rule published in the GitHub repository AdobeDocs/ff-services-docs (4 stars, last pushed 3mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 3,529 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-31.