CPython C extension analysis toolkit: 10 specialized agents for refcount auditing, error path analysis, NULL safety, GIL discipline, module state validation, type slot correctness, stable ABI compliance, version compatibility, complexity measurement, and git history analysis. Tree-sitter-powered for accurate analysis…
Instructions for ReviewToolkits/cext-review-toolkit, covering claude.md — cext-review-toolkit development guide, project overview, prerequisites, dev commands and run all tests.
Use this agent to measure and analyze C code complexity in extension modules, identifying hotspots and suggesting simplifications.\n\n \nUser: What are the most complex functions in this extension?\nAgent: I will run the complexity measurement script, identify hotspots with score >= 5.0, assess inherent vs reducible…
Use this agent to audit error handling correctness in C extension code that calls the Python/C API.\n\n \nUser: Check the error handling in my C extension.\nAgent: I will run the error path scanner, prioritize missing NULL checks and return-without-exception findings, and review extension-specific error patterns like…
Use this agent FIRST in every cext-review-toolkit explore pipeline on a C extension that uses a code generator (Cython, pybind11, nanobind, custom codegen). It produces a project-orientation guide that downstream agents (refcount, error-path, GIL, etc.) consume to triage findings accurately. The orientation captures…
Use this agent to audit GIL (Global Interpreter Lock) management in C extension code, including foreign C library interaction and free-threaded Python readiness.\n\n \nUser: Check GIL handling in my C extension that wraps a foreign library.\nAgent: I will run the GIL usage scanner, verify matched…
Use this agent for temporal analysis of a C extension codebase -- finding similar bugs via git history and prioritizing review by churn patterns.\n\n \nUser: We just fixed a NULL check bug -- did we miss any similar bugs elsewhere?\nAgent: I will run the history analyzer, examine recent fix commits for bug patterns…
Use this agent to audit module initialization and state management in C extension code, including single-phase vs multi-phase init and global state migration.\n\n \nUser: Review the module state management in my C extension.\nAgent: I will run the module state scanner, assess the init style, catalog global PyObject…
Use this agent to audit NULL pointer safety in C extension code.\n\n \nUser: Check for NULL pointer dereference risks in my C extension.\nAgent: I will run the NULL safety scanner, verify each unchecked allocation and dereference-before-check finding, and review extension-specific NULL patterns like PyDictGetItem…
Use this agent to find behavioral differences between C and Python implementations of the same functionality in extensions that ship dual implementations.\n\n \nUser: Check if the C and Python parsers in my extension behave the same.\nAgent: I will identify dual C/Python implementations, compare validation logic…
Use this agent to audit PyErrClear() usage in C extension code, finding calls that silently swallow exceptions like MemoryError and KeyboardInterrupt.\n\n \nUser: Check for dangerous PyErrClear usage in my extension.\nAgent: I will run the PyErrClear scanner, triage each unguarded clear call, and assess whether…
Use this agent to audit reference counting correctness in C extension code that calls the Python/C API.\n\n \nUser: Review the reference counting in my C extension module.\nAgent: I will run the refcount scanner, triage each finding, and perform deep analysis of potential leaks, borrowed-ref-across-call hazards, and…
Use this agent to audit non-PyObject resource lifecycle in C extension code -- malloc/free pairing, HDF5 handle leaks, buffer protocol, and file descriptor management.\n\n \nUser: Check for resource leaks in my C extension.\nAgent: I will run the resource lifecycle scanner, triage each finding for true leaks on error…
Use this agent to audit Python stable ABI and limited API compliance in C extension code.\n\n \nUser: Check if my C extension is compatible with the stable ABI.\nAgent: I will determine whether the extension claims limited API compliance, verify that claim against the stable ABI surface, check for private API usage…
Use this agent to audit Python type definitions (PyTypeObject, PyTypeSpec) in C extension code for correctness of slots, dealloc, traverse, and GC integration.\n\n \nUser: Check the type definitions in my C extension.\nAgent: I will run the type slot scanner, verify dealloc/traverse/GC flag consistency, check…
Use this agent to audit Python version compatibility in C extension code, including deprecated API usage, version-guarded code, and pythoncapi-compat opportunities.\n\n \nUser: Check Python version compatibility in my C extension.\nAgent: I will determine the target Python versions, check for unguarded…
Comprehensive C extension analysis using specialized agents. Use when the user asks to analyze, audit, or review a C extension, find bugs in C extension code, run all checks on an extension, or do a full extension review. Covers refcount safety, error handling, NULL safety, GIL discipline, module state, type slots…
Quick health dashboard scoring a C extension across all dimensions. Use when the user asks for a quick overview, health check, status, score, or summary of a C extension's quality.
Find the worst functions to fix first by combining refcount issues, error handling bugs, and complexity scoring. Use when the user asks where to focus review effort, which functions are most dangerous, what to fix first, or wants a prioritized list of hotspots in a C extension.
Extension modernization assessment covering multi-phase init migration, stable ABI adoption, version compatibility, and free-threading readiness. Use when the user asks to modernize an extension, prepare for subinterpreters, migrate to stable ABI, clean up deprecated APIs, or assess migration effort for a C extension.