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.
npx skills add chen3feng/agent-skills --skill stop-chasing-the-optimizer-reduce-insteadgit clone --depth 1 https://github.com/chen3feng/agent-skillsWrote 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.
[](https://agentmods.dev/skills/chen3feng/agent-skills/stop-chasing-the-optimizer-reduce-instead)<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>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.
| Model | Per session | Once 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 |
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.
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:
volatileon a local / a parameter__attribute__((noinline))on the callee__attribute__((optimize("O0")))on the callee-fno-strict-aliasingon the TUasm 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:
- The decorations change the bug, not the cause.
noinlinein one spot shifts the inlining decision elsewhere; the miscompile now lives in a different frame. You spend another iteration finding it. - Some decorations are themselves traps.
__attribute__((optimize("O0")))on a single function inside an-O2TU is known to produce ABI mismatches between the-O0callee and the-O2caller on GCC (frame pointer, red-zone, stack alignment). The "fix" introduces a new SIGSEGV on the first call. - 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:
- Extract a standalone repro. Rip the suspect function out of the
project into a single
.cppof ≤ 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. - Diff the codegen.
g++ -O2 -S -masm=intel repro.cppvsclang++ -O2 -S -masm=intel repro.cppvs 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. - Shrink with
creduce/cvise. Feed the standalone repro plus a predicate script (g++ -O2 x.cpp && ./a.out; [ $? -ne 0 ]) tocvise. 200 lines typically collapses to 20. - Decide once, fix once.
- UB in your code → fix the UB (e.g. replace
x >> 64with a branch, usememcpyinstead of pointer-punning, add an explicit bounds check). Novolatileneeded. - 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
memcpyor__attribute__((may_alias))at the type, not-fno-strict-aliasingon the whole TU.
- UB in your code → fix the UB (e.g. replace
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.
- 8d ago First seen · 158 lines · 36 tokens per session scan A d13610f1e0f4
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.
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.
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.
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.
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.
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.
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.