move-copy-semantics

move-copy-semantics is a cursor rule for Cursor from xLLM-AI/xllm. It costs 410 tokens per session, scanned A, original, Apache-2.0.

A C++ coding rule about how to pass and move values when a function keeps them. It explains that applying std::move to a const value can cause a copy instead of a move.

In plain words
What is it for?
Use it when reviewing or writing C++ constructors and functions that retain arguments, especially for large data objects.
Why use it?
It helps prevent silent, expensive copies caused by code that appears to move data but cannot use the move operation.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when reviewing or writing C++ constructors and functions that retain arguments, especially for large data objects.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/xllm-ai/xllm/move-copy-semantics
About the project

xLLM is an inference engine, meaning software that runs trained AI models to produce outputs from inputs, for large language, vision-language, diffusion, and recommendation models on different AI accelerators. Organizations use it to deploy these models with high-throughput and low-latency inference. The catalogue entries provide skills and instructions for working with xLLM.

xLLM-AI/xllm · 1,562 stars · on GitHub · xllm-ai.com

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/xLLM-AI/xllm

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 move-copy-semantics

README.md
[![agentmods](https://agentmods.dev/badge/rules/xllm-ai/xllm/move-copy-semantics.svg)](https://agentmods.dev/rules/xllm-ai/xllm/move-copy-semantics)
Your own site
<a href="https://agentmods.dev/rules/xllm-ai/xllm/move-copy-semantics"><img src="https://agentmods.dev/badge/rules/xllm-ai/xllm/move-copy-semantics.svg" alt="Measured on agentmods" height="20"></a>
Per session 410 This file is loaded in full into every session.
When invoked 410 The same file — it is already loaded in full.
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.00410 $0.00410
Opus 5 $0.00205 $0.00205
Sonnet 5 $0.00082 $0.00082
Haiku 4.5 $0.00041 $0.00041

Measured today against content hash 61fb3fe98e89, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

move-copy-semantics 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 today.

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/move-copy-semantics.mdc · 33 lines

What it actually says

Move & Copy Semantics

std::move(x) is only a cast to T&&. When x is const& (or const), it yields a const T&& that binds to the copy constructor, not the move constructor — so it compiles, looks like a move, and silently deep-copies. This is the bug that made Request/RequestState construction copy their whole payload.

  • Never std::move a const& / const value. The two ingredients of the bug are always "a const source + std::move". Don't combine them.
  • Sink parameters go by value + std::move. If a function/ctor retains its argument, take it by value and std::move it into the member. Use const& only for parameters you read but do not retain.
  • Make callers move. Pass std::move(local) when you hand an owned local to a sink parameter and don't use it afterwards; an lvalue silently copies.
  • Consider making heavy, rarely-copied domain types move-only (= delete copy) with an explicit clone(), so an accidental copy is a compile error.
// Bad – const& + std::move => copies
Request(const RequestState& state) : state_(std::move(state)) {}

// Good – sink by value; caller chooses copy (lvalue) vs move (std::move)
Request(RequestState state) : state_(std::move(state)) {}

clang-tidy's performance-move-const-arg (see repo .clang-tidy) flags this.

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. today First seen · 33 lines · 410 tokens per session scan A 61fb3fe98e89

Subscribe to this mod's changes

move-copy-semantics is a cursor rule published in the GitHub repository xLLM-AI/xllm (1,562 stars, last pushed today), licensed Apache-2.0. It adds 410 tokens to every session, about $0.0020 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-09-08.