stop-chasing-the-optimizer-reduce-instead

stop-chasing-the-optimizer-reduce-instead is a skill for Claude Code, Codex from chen3feng/agent-skills. It costs 36 tokens per session (1,893 once invoked), scanned A, original, Apache-2.0.

A debugging rule for compiler optimization failures. Compiler optimization changes code to improve speed, and this rule says to simplify the failing example after repeated workaround attempts.

In plain words
What is it for?
Investigating code that works with one compiler but fails or crashes with GCC or Clang when optimization is enabled.
Why use it?
It prevents temporary compiler workarounds from hiding the real cause or moving the failure elsewhere.

Skill for Claude CodeCodex

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

Good fit Investigating code that works with one compiler but fails or crashes with GCC or Clang when optimization is enabled.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead
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 chen3feng/agent-skills --skill stop-chasing-the-optimizer-reduce-instead
Clone the repo
git clone --depth 1 https://github.com/chen3feng/agent-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 stop-chasing-the-optimizer-reduce-instead

README.md
[![agentmods](https://agentmods.dev/badge/skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead.svg)](https://agentmods.dev/skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead)
Your own site
<a href="https://agentmods.dev/skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,893 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.00036 $0.01893
Opus 5 $0.00018 $0.00946
Sonnet 5 $0.00007 $0.00379
Haiku 4.5 $0.00004 $0.00189

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

Security

Grade A, and why

stop-chasing-the-optimizer-reduce-instead 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 8d 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/stop-chasing-the-optimizer-reduce-instead/SKILL.md · 158 lines

How it starts

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

Stop chasing the optimizer; reduce the repro instead

When to use

You have a hot function that passes on one toolchain (typically MSVC) but miscompiles or crashes under GCC / Clang at -O2 (or higher), and you're on attempt three of sprinkling anti-optimization decorations:

  • volatile on a local / a parameter
  • __attribute__((noinline)) on the callee
  • __attribute__((optimize("O0"))) on the callee
  • -fno-strict-aliasing on the TU
  • asm volatile("" ::: "memory") barriers

Each one "almost works" — the symptom moves by a few bytes or into a different test case — but never fully goes away. That's the signal to stop.

Problem

Adding anti-optimization pragmas is a local fix applied to a global belief: "the optimizer is wrong." Three things go wrong in practice:

  1. The decorations change the bug, not the cause. noinline in one spot shifts the inlining decision elsewhere; the miscompile now lives in a different frame. You spend another iteration finding it.
  2. Some decorations are themselves traps. __attribute__((optimize("O0"))) on a single function inside an -O2 TU is known to produce ABI mismatches between the -O0 callee and the -O2 caller on GCC (frame pointer, red-zone, stack alignment). The "fix" introduces a new SIGSEGV on the first call.
  3. You never learn whether it's a compiler bug, your UB, or your aliasing. All three present identically — "works on MSVC, breaks on GCC -O2" — and have very different fixes. Patching blindly leaves the root cause unknown, so the same bug returns the next time someone touches the file.

The heuristic: after two anti-optimization patches in a row have failed to fully fix the symptom, the next step is not a third patch. It's reduction.

Solution

Switch from "patch" mode to "reduce" mode:

  1. Extract a standalone repro. Rip the suspect function out of the project into a single .cpp of ≤ 200 lines that links with nothing but libc. Must reproduce the divergence between MSVC and GCC/Clang -O2. If it doesn't reproduce standalone, the bug is in how the function is called, not the function itself — go up a frame.
  2. Diff the codegen. g++ -O2 -S -masm=intel repro.cpp vs clang++ -O2 -S -masm=intel repro.cpp vs MSVC /FAs. Look for loads from offsets you never wrote, or stores that the compiler elided. This usually tells you within minutes whether it's UB (compiler is within its rights) or a real miscompile.
  3. Shrink with creduce / cvise. Feed the standalone repro plus a predicate script (g++ -O2 x.cpp && ./a.out; [ $? -ne 0 ]) to cvise. 200 lines typically collapses to 20.
  4. Decide once, fix once.
    • UB in your code → fix the UB (e.g. replace x >> 64 with a branch, use memcpy instead of pointer-punning, add an explicit bounds check). No volatile needed.
    • Real compiler bug → file upstream with the reduced repro, then put one narrow workaround (guarded by compiler-version macros) with a link to the bug report.
    • Aliasing assumption → use memcpy or __attribute__((may_alias)) at the type, not -fno-strict-aliasing on the whole TU.

Read the full file on GitHub · 158 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. 8d ago First seen · 158 lines · 36 tokens per session scan A d13610f1e0f4

Subscribe to this mod's changes

stop-chasing-the-optimizer-reduce-instead is a skill published in the GitHub repository chen3feng/agent-skills (5 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 36 tokens to every session and 1,893 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-08-31.

Related

Other skills, from other repositories

dynamic-instrumentation

Expertise in LLVM-based dynamic binary instrumentation, runtime tracing, and program monitoring. Use this skill when implementing runtime analysis tools, code coverage systems, profilers, or dynamic security monitors.

gmh5225/awesome-llvm-security · 42 tokens

llvm-optimization

Expertise in LLVM optimization passes, performance tuning, and code transformation techniques. Use this skill when implementing custom optimizations, analyzing pass behavior, improving generated code quality, or understanding LLVM's optimization pipeline.

gmh5225/awesome-llvm-security · 44 tokens

llvm-tooling

Expertise in LLVM tooling development including Clang plugins, LLDB debugger extensions, Clangd/LSP, and LibTooling. Use this skill when building source code analysis tools, refactoring tools, debugger extensions, or IDE integrations.

gmh5225/awesome-llvm-security · 52 tokens

static-analysis

Expertise in LLVM-based static analysis including dataflow analysis, pointer analysis, taint tracking, and program verification. Use this skill when implementing security scanners, bug finders, code quality tools, or performing program analysis research.

gmh5225/awesome-llvm-security · 48 tokens

binary-lifting

Expertise in binary lifting techniques - converting machine code to LLVM IR for analysis, decompilation, and recompilation. Use this skill when working on reverse engineering, binary analysis, deobfuscation, or converting binaries to higher-level representations.

gmh5225/awesome-llvm-security · 53 tokens

ebpf

Guide agents through writing, loading, and debugging eBPF programs using libbpf, bpftrace, and bpftool. Covers map types, program types, verifier errors, XDP networking, and CO-RE portability.

mohitmishra786/low-level-dev-skills · 102 tokens