memory-model

memory-model is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 83 tokens per session (1,627 once invoked), scanned A, original, MIT.

A guide to the C++ and Rust memory models, which define how threads see shared data and how atomic operations synchronize them. It explains memory ordering, fences, happens-before relationships, and lock-free data structures.

In plain words
What is it for?
Use it to select atomic memory orderings, understand acquire and release operations, write fences, diagnose concurrent bugs, and design lock-free queues in C++ or Rust.
Why use it?
It helps prevent data races and incorrect assumptions about the order in which threads observe changes. It also helps choose synchronization that is strong enough without adding unnecessary overhead.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

not rated 196repo +3 2mo ago A scan Socket: passSnyk: passSkillSpector: pass 83 tokens original MIT

Good fit Use it to select atomic memory orderings, understand acquire and release operations, write fences, diagnose concurrent bugs, and design lock-free queues in C++ or Rust.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/memory-model
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.

Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill memory-model
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

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 memory-model

README.md
[![agentmods](https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/memory-model.svg)](https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/memory-model)
Your own site
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/memory-model"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/memory-model.svg" alt="Measured on agentmods" height="20"></a>
Per session 83 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,627 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. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk pass 21 Feb 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00083 $0.01627
Opus 5 $0.00042 $0.00813
Sonnet 5 $0.00017 $0.00325
Haiku 4.5 $0.00008 $0.00163

Measured 4d ago against content hash ba86a8a3f7db, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

memory-model 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.

skills/low-level-programming/memory-model/SKILL.md · 194 lines

How it starts

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

Memory Model

Purpose

Guide agents through C++ and Rust memory models: memory orderings, the happens-before relation, atomic operations, fences, and practical patterns for lock-free data structures.

Triggers

  • "What is the C++ memory model?"
  • "What memory order should I use for my atomic operation?"
  • "What is the difference between acquire-release and seq_cst?"
  • "How do I use std::atomic in C++?"
  • "What is acquire/release in Rust atomics?"
  • "How do I implement a lock-free queue?"

Workflow

1. Memory ordering overview

Modern CPUs and compilers reorder operations for performance. The memory model specifies what reorderings are allowed and how synchronisation is achieved.

Ordering strength (weakest to strongest):
Relaxed < Release/Acquire < AcqRel < SeqCst

Stronger ordering = more synchronization = more correct, but slower
Weaker ordering  = fewer barriers = faster, but needs careful analysis

2. Memory orderings

Order C++ Rust What it means
Relaxed memory_order_relaxed Ordering::Relaxed No ordering guarantee; just atomicity
Consume memory_order_consume (use Acquire) Data dependency ordering
Acquire memory_order_acquire Ordering::Acquire This load sees all writes before the matching release
Release memory_order_release Ordering::Release All writes before this store are visible to acquire
AcqRel memory_order_acq_rel Ordering::AcqRel Both acquire and release on RMW ops
SeqCst memory_order_seq_cst Ordering::SeqCst Total order across all seq_cst operations

3. C++ std::atomic

#include <atomic>
#include <thread>

std::atomic<int> counter{0};
std::atomic<bool> ready{false};

// Producer thread
void producer() {
    data = 42;                              // (1) write data
    ready.store(true, std::memory_order_release);  // (2) signal
}

// Consumer thread
void consumer() {
    while (!ready.load(std::memory_order_acquire));  // (3) wait
    assert(data == 42);                              // (4) guaranteed to see (1)
}

Read the full file on GitHub · 194 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 194 lines · 83 tokens per session scan A ba86a8a3f7db

Subscribe to this mod's changes

memory-model is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (196 stars, last pushed 2mo ago), licensed MIT. It adds 83 tokens to every session and 1,627 once invoked, about $0.0004 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-03.