C Extension Review Toolkit
A Claude Code plugin for reviewing CPython C extensions — finding API misuse, memory safety bugs, compatibility issues, and correctness problems specific to code that consumes the Python/C API.
Built for the specific concerns of C extension authors — reference counting from the caller's perspective, borrowed-reference lifetimes, module state management, type slot correctness, free-threading readiness, parity between C and Python implementations, stable ABI compliance, and version compatibility — not general-purpose C analysis.
⚠️ Read this before you use the toolkit on someone else's project
This tool finds bugs in other people's code. That code is usually written by someone giving away their work for free. Before running this on a project you don't own:
- Read WORKING_WITH_MAINTAINERS.md. It is the most important document in this repository.
- Reach out to the maintainer first. A short, friendly message — "I'd like to run a static-analysis tool on your project, would the report be useful?" — takes five minutes and changes everything that follows.
- Don't auto-file issues. Don't auto-open PRs. Every finding should pass through human triage before reaching the maintainer.
- Security findings need responsible disclosure, not a public issue.
A 50-finding report is 50 hours of homework for a maintainer who didn't ask for it. The tool's value depends entirely on whether they want to receive what you produce.
Why a Separate Tool?
| Concern | CPython internals (cpython-review-toolkit) | C extensions (this toolkit) |
|---|
| Perspective | Code that implements the C API | Code that calls the C API |
| Parsing | Regex (PEP 7 code is regular) | Tree-sitter (extension code varies wildly) |
| Top bug class | Refcount leaks in runtime code | Borrowed refs held across callbacks; UAF in proxy callbacks |
| Module state | N/A (CPython manages its own) | Core concern — init style, global state, sub-interpreter compat |
| Type definitions | Part of the runtime | Must follow slot contracts correctly |
| ABI | Defines the ABI | Must comply with the ABI |
| Dependencies | stdlib only | tree-sitter, tree-sitter-c (optional: tree-sitter-cpp, tree-sitter-cython) |
Installation
Marketplace install (recommended)
claude plugin marketplace add devdanzin/cext-review-toolkit
claude plugin install cext-review-toolkit@cext-review-toolkit
Direct install from GitHub
claude plugin install cext-review-toolkit --source github:devdanzin/cext-review-toolkit --path plugins/cext-review-toolkit
Without installing (try it first)
git clone https://github.com/devdanzin/cext-review-toolkit.git
claude --plugin-dir cext-review-toolkit/plugins/cext-review-toolkit
Prerequisites
- Claude Code installed and running
- Python 3.10+ for the analysis scripts
- tree-sitter and tree-sitter-c:
pip install tree-sitter tree-sitter-c
- tree-sitter-cpp (optional):
pip install tree-sitter-cpp — enables C++ file parsing
- tree-sitter-cython (optional, for Cython extensions):
pip install git+https://github.com/devdanzin/tree-sitter-cython.git@fix/grammar-gaps
- clang-tidy and cppcheck (optional): system packages — enables external tool cross-referencing
- libfiu (optional): for OOM-injection reproducers
Quick Start
Navigate to a C extension project, then:
/cext-review-toolkit:health # Quick health dashboard
/cext-review-toolkit:hotspots # Refcount leaks + error bugs + complexity
/cext-review-toolkit:explore # Full exploration (mapper preflight + 13 audit agents + reproducer pass)
/cext-review-toolkit:migrate # Modernization checklist
Start with health for a quick overview, then hotspots to find the highest-impact bugs. Use explore for the full audit pipeline.
Cost and time expectations
A full /explore on a medium extension (~5 KLOC) typically runs:
- ~10-30 minutes wall-clock for the audit phase
- Real money in Claude API tokens — a thorough multi-pass review can cost anywhere from a few dollars to tens of dollars depending on extension size, agent count, and whether you run the reproducer pass
- Significantly more for large extensions (~25 KLOC+) or when the 2-naive + 1-informed methodology is run end-to-end
This isn't free to run, and it isn't free for the maintainer to receive. Plan accordingly.
What's Included
Agents (13 audit + 1 phase-0 specialist)
Phase-0 specialist