branch-prediction-and-speculation

branch-prediction-and-speculation is a skill for Codex from OutlineDriven/outline-driven-development. It costs 49 tokens per session (1,216 once invoked), scanned A, original, Apache-2.0.

An explanation and measurement guide for how processors guess the result of conditional branches and run instructions ahead of time. It also covers security problems such as Spectre and Meltdown, where speculative execution can expose data.

In plain words
What is it for?
Use it to examine a hot branch, assess a branchless rewrite, understand mitigations such as retpolines or KPTI, or reason about speculative-execution risks.
Why use it?
It helps explain slow branch-heavy code and distinguish ordinary performance issues from leaks caused by secret-dependent branches. Measurements can show whether branch mispredictions are actually occurring.

Skill for Codex

Written for Codex: agents/openai.yaml present.

Good fit Use it to examine a hot branch, assess a branchless rewrite, understand mitigations such as retpolines or KPTI, or reason about speculative-execution risks.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation
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 OutlineDriven/outline-driven-development --skill branch-prediction-and-speculation
Clone the repo
git clone --depth 1 https://github.com/OutlineDriven/outline-driven-development

Made for: 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 branch-prediction-and-speculation

README.md
[![agentmods](https://agentmods.dev/badge/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation/github.svg)](https://agentmods.dev/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation)
Your own site
<a href="https://agentmods.dev/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation"><img src="https://agentmods.dev/badge/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation/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 branch-prediction-and-speculation

Your own site · 80×15
<a href="https://agentmods.dev/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation"><img src="https://agentmods.dev/badge/skills/outlinedriven/outline-driven-development/branch-prediction-and-speculation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,216 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
  • 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.00049 $0.01216
Opus 5 $0.00024 $0.00608
Sonnet 5 $0.00010 $0.00243
Haiku 4.5 $0.00005 $0.00122

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

Security

Grade A, and why

branch-prediction-and-speculation 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 3d 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.

.devin/skills/branch-prediction-and-speculation/SKILL.md · 60 lines

How it starts

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

Branch prediction and speculation

Contract

Field Bound contract
Trigger Branchy hot code underperforms, a likely or branchless refactor needs judgment, a kernel mitigation such as retpoline or KPTI needs explaining, or code branches on secret data.
Authority Read-only. The skill runs perf stat on a user-named binary, reads sysfs, and answers in chat. Nothing on disk changes, so there is nothing to roll back. No remote mutation.
Side effect Chat output only. perf stat writes counters to stdout.
Done The answer names the branch that mispredicts or the speculation path that leaks, gives a measured branch-misses count where a binary exists, and states the fix with the condition under which it helps.

Inputs

  • Code or hot loop (required): the source or disassembly around the branch in question.
  • Binary and workload (optional): needed for a measured verdict. Without them the answer is a hypothesis.
  • Threat model (optional): whether the question is performance only or also side-channel safety.

Procedure

  1. Explain the mechanism in one pass. The front end predicts a direction for each conditional branch, executes the predicted path, and on resolve either commits or squashes the wrong-path work and refetches from the correct address. The squash cost grows with the distance from fetch to resolve, so a deeper pipeline pays more per mispredict. Backward branches are usually loop closers and predict taken; a data-dependent forward branch with no pattern is the hard case. Done when: the user can say why a given branch is predictable or not.
  2. Measure before changing code. Done when: a branch-misses count and its ratio to branches for the real workload is recorded, or no binary exists and the answer is marked as unmeasured.
perf stat -e branches,branch-misses ./app

Read the ratio against the workload, not against a fixed number: a tight loop over sorted data should show a ratio near zero, while a parser over random input can sit far higher and still be at its floor. Only a ratio that drops after a change proves the change.

Read the full file on GitHub · 60 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. 3d ago First seen · 60 lines · 49 tokens per session scan A f01cc380134d

Subscribe to this mod's changes

branch-prediction-and-speculation is a skill published in the GitHub repository OutlineDriven/outline-driven-development (52 stars, last pushed 4d ago), licensed Apache-2.0. It adds 49 tokens to every session and 1,216 once invoked, about $0.0002 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-06.