analyze-wat

A compiler-output checker that turns source code into WAT, the readable text form of WebAssembly code, and looks for inefficient generated instructions.

In plain words
What is it for?
It helps inspect generated WebAssembly after code-generation changes, investigate slow code, and create optimization issues based on detected patterns.
Why use it?
It shows whether a compiler change produces unnecessary code and gives performance investigations evidence from the actual output.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/loopdive/js2/analyze-wat
Any agent
npx skills add loopdive/js2 --skill analyze-wat
Clone the repo
git clone --depth 1 https://github.com/loopdive/js2

Made for: Claude Code, Codex.

Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 751 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00050 $0.00751
Opus 5 $0.00025 $0.00376
Sonnet 5 $0.00010 $0.00150
Haiku 4.5 $0.00005 $0.00075

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

Security

Grade A, and why

analyze-wat 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 2d 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.

.claude/skills/analyze-wat/SKILL.md · 65 lines

How it starts

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

Analyze WAT Output

Compile a source file to WAT and analyze the output for codegen inefficiencies.

When to use

  • After implementing a codegen change, to verify the output is clean
  • When investigating performance issues
  • When creating optimization issues from real compiler output

Steps

  1. Compile the source to WAT:
node --input-type=module -e "
import { compile } from './scripts/compiler-bundle.mjs';
import fs from 'fs';
const src = fs.readFileSync('SOURCE_FILE', 'utf8');
const result = compile(src, { fileName: 'test.ts', emitWat: true });
if (!result.success) { console.log('ERRORS:', result.errors.slice(0,5).map(e => e.message).join('\n')); process.exit(1); }
fs.writeFileSync('/tmp/output.wat', result.wat);
console.log('WAT:', result.wat.length, 'chars | Binary:', result.binary.length, 'bytes');
"
  1. Check for known inefficiency patterns:
Pattern How to detect Severity
Duplicate locals Same (local $name appearing twice with different types Medium — bloats binary
Infinity guard on constant modulo f64.abs + f64.const Infinity + f64.eq near f64.div/f64.trunc High — 10 extra instructions per %
Dead drops local.tee N followed later by drop with no intervening use Medium — wasted stack ops
TDZ flags unused (local $__tdz_ that are set to 1 but never checked Low — extra locals
String concat chains Multiple consecutive call $concat_import Medium — N-1 intermediate strings
If-chain → br_table candidate Same local.get + f64.const N + f64.eq + if repeated 3+ times High — O(n) vs O(1)
f64↔i32 roundtrip f64.convert_i32_s immediately followed by i32.trunc_sat_f64_s High — pure waste
Redundant null guards ref.is_null + if on provably non-null values (literals, new, struct.new) Medium — unnecessary branches
  1. For each pattern found, note:
    • Source line that produced it
    • WAT line numbers
    • How many instructions could be saved
    • Which codegen file to fix

Read the full file on GitHub · 65 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. 2d ago First seen · 65 lines · 50 tokens per session scan A f7f16a537307

Subscribe to this mod's changes

analyze-wat is a skill published in the GitHub repository loopdive/js2 (59 stars, last pushed 2d ago), licensed Apache-2.0. It adds 50 tokens to every session and 751 once invoked, about $0.0003 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-30.