HyperAnalyzer

Documentation

Install, wire up MCP, and browse the rule catalog.

1. Install

HyperAnalyzer ships as a Python package. Python 3.11 or newer.

pip install hyperanalyzer

libclang is bundled, no separate Clang installation required.

2. Analyze a file from the CLI

hyperanalyzer analyze src/loader.cpp
hyperanalyzer analyze --compile-db build/ src/

When a compile_commands.json is present, HyperAnalyzer honours the exact compile flags your build system uses so the AST and type info are identical to what your compiler sees.

3. Wire it into Claude Code

HyperAnalyzer ships with an MCP server entry point. Add it to your Claude Code config:

{
  "mcpServers": {
    "hyperanalyzer": {
      "command": "hyperanalyzer-mcp",
      "args": []
    }
  }
}

From then on Claude can call the analyze_file, analyze_snippet, analyze_diff, list_rules and explain_finding tools as part of its normal edit loop.

4. Rule catalog

19 rules · 9 shipping · 2 beta · 8 planned

Windows

HA001 high shipping CWE-667

Forbidden Win32 API invoked from DllMain

Calling CreateThread, LoadLibrary, CoInitialize or any loader-lock-sensitive API inside DllMain can deadlock the loader lock at process load time.

HA002 medium shipping CWE-440

CreateThread / ExitThread in C or C++ code

Use _beginthreadex / _endthreadex so the CRT can initialise per-thread state. Raw CreateThread leaks CRT state and causes subtle heap corruption.

HA003 high planned CWE-667

LoadLibrary invoked inside DllMain

Extension of HA001. Loading a DLL inside another DLL's entry point recurses into the loader lock and deadlocks the process.

Security

HA101 high shipping CWE-467

sizeof(pointer) passed to memcpy / memset / memcmp

sizeof on a pointer returns the pointer width, not the buffer size. Classic under-copy bug LLMs produce when refactoring arrays into heap buffers.

HA102 medium shipping CWE-191

Unsigned subtraction compared with < / > / <= / >=

(a - b) < c on unsigned types wraps around zero and silently becomes a huge value, producing logic bugs that compile cleanly and pass review.

HA103 high beta CWE-226

Sensitive buffer not securely cleared on exit paths

Password, key or token buffers that are not memset_s / SecureZeroMemory'd on every return path leak through stack reuse and core dumps.

HA104 medium planned CWE-690

Null dereference after malloc / new without check

Allocation result used immediately without a null / nothrow check. Low-memory paths are exactly where LLMs skip defensive code.

HA105 high planned CWE-120

strcpy / strcat / sprintf on user input

Unbounded string APIs on any tainted source. Use snprintf / strncpy_s / std::format.

HA107 high planned CWE-798

Hard-coded cryptographic key literal

AES / HMAC / signing keys embedded as string or byte-array literals. Detected via entropy + call-site heuristic.

Correctness

HA201 medium shipping CWE-563

Local variable assigned twice with no read between

Typical refactoring leftover: a new assignment is added but the old one is not deleted. Dead stores hide real logic errors.

HA202 medium shipping CWE-570

Boolean expression always true or always false

Unsigned compared with < 0, sizeof() compared with a negative. Dead branches that look defensive but never execute.

HA203 high planned CWE-480

Assignment instead of comparison in if / while

if (x = 10) { ... } the classic single-equals bug. High precision, catches real refactoring slip-ups.

HA204 medium planned CWE-484

Missing break / fall-through in switch case

Fall-through without an explicit [[fallthrough]] attribute or comment. LLMs generate these when translating if/else chains.

Performance

HA301 low shipping n/a

push_back(Type{…}) where emplace_back would skip a copy

Cheap win: emplace_back constructs in place. LLMs default to push_back because the training data predates C++11.

HA302 low shipping n/a

Copy-assigned local where source is not used afterwards

Source object is dead after the copy; a move would be free. Detected via libclang liveness on the enclosing block.

HA303 low shipping n/a

Struct fields reorderable to save padding

Reordering fields by descending size can shrink the struct by 20–40 % on 64-bit targets.

Concurrency

HA401 high planned CWE-362

std::atomic used where a mutex is actually needed

Multi-variable invariants guarded by a single atomic, a classic data race pattern. Suggests std::mutex or std::shared_mutex.

Resources

HA501 medium planned CWE-404

FILE* / HANDLE / socket not closed on all return paths

Manual resource acquisition without RAII. Suggests unique_ptr with custom deleter or a scope guard.

Secrets

HA901 high beta CWE-798

Hard-coded AWS / GCP / Stripe credential

Regex + entropy detection on known key prefixes (AKIA, AIzaSy, sk_live_, ghp_, …). Language-agnostic.

Missing a rule?

Our rule roadmap is driven by the failure modes we see in real LLM-generated code. If Claude keeps writing the same bug class in your codebase, tell us and a well-documented failure case usually becomes a rule within a week.