migrate

migrate is a command for coding agents from ReviewToolkits/cext-review-toolkit. It costs 58 tokens per session (1,345 once invoked), scanned A, original, MIT.

A review command for planning updates to a Python C extension, which is software written in C that adds native features to Python.

In plain words
What is it for?
Use it to assess an extension before modernization, including its module state, type definitions, deprecated APIs, stable ABI, and supported Python versions.
Why use it?
It identifies changes needed for newer extension practices, stable ABI support, version compatibility, and preparation for free-threading or subinterpreters.

Command

Part of the cext-review-toolkit plugin — 1 skill, 4 commands, 14 agents shipped together

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 commands/reviewtoolkits/cext-review-toolkit/migrate
Clone the repo
git clone --depth 1 https://github.com/ReviewToolkits/cext-review-toolkit

Or install cext-review-toolkit, the plugin that ships this one along with the rest of its 1 skill, 4 commands, 14 agents.

Wrote 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.

agentmods badge for migrate

README.md
[![agentmods](https://agentmods.dev/badge/commands/reviewtoolkits/cext-review-toolkit/migrate.svg)](https://agentmods.dev/commands/reviewtoolkits/cext-review-toolkit/migrate)
Your own site
<a href="https://agentmods.dev/commands/reviewtoolkits/cext-review-toolkit/migrate"><img src="https://agentmods.dev/badge/commands/reviewtoolkits/cext-review-toolkit/migrate.svg" alt="Measured on agentmods" height="20"></a>
Per session 58 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,345 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.00058 $0.01345
Opus 5 $0.00029 $0.00673
Sonnet 5 $0.00012 $0.00269
Haiku 4.5 $0.00006 $0.00135

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

Security

Grade A, and why

migrate 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 5d 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.

plugins/cext-review-toolkit/commands/migrate.md · 113 lines

How it starts

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

Extension Migration Assessment

Run the modernization-focused agents to assess what needs to change to bring the extension up to current best practices: module-state-checker, type-slot-checker, stable-abi-checker, and version-compat-scanner. Answers the question: "What do I need to change to modernize this extension?"

Scope: "$ARGUMENTS" (default: entire project)

Plugin root: <plugin_root> refers to the directory containing this command file's parent -- i.e., the plugins/cext-review-toolkit/ directory. Resolve it relative to this file's location.

Workflow

  1. Run python <plugin_root>/scripts/discover_extension.py [scope] to detect the extension layout
  2. If no C extension found, inform the user and stop
  3. Check the code_generation field. If "cython" or "mypyc", note that migration recommendations apply to the code generator, not the generated output. Skip stable-abi-checker and version-compat-scanner (answers are always "generator limitation").
  4. Run applicable modernization agents with at most 2 in parallel, feeding discovery context:
    • module-state-checker -- init style, global state, module lifecycle
    • type-slot-checker -- type definition correctness and modernity
    • stable-abi-checker -- ABI compliance assessment
    • version-compat-scanner -- version compatibility and dead code
  5. Synthesize into a migration report with concrete checklist:
# Extension Migration Report

## Extension: [name]

## Current State
- Init style: [single-phase (legacy) / multi-phase]
- Global state: [N] static PyObject* variables, [N] other static mutable variables
- Type definitions: [N] types ([N] static, [N] heap)
- Stable ABI: [not used / claimed / fully compliant]
- Minimum Python: [version from python_requires or inferred]
- Dead compatibility code: [N] version guard blocks below minimum

## Migration Checklist

### Phase 1: Multi-phase Initialization
[Skip if already using multi-phase init]

**Difficulty: [Easy / Moderate / Hard]** (based on amount of global state)

- [ ] Convert `PyInit_xxx` from `PyModule_Create` to `PyModuleDef_Init`
- [ ] Add `Py_mod_exec` slot with module initialization logic
- [ ] Create module state struct to hold [N] global PyObject* variables:
  [list each variable and what it holds]
- [ ] Set `m_size` to `sizeof(module_state_struct)`
- [ ] Add `m_traverse` visiting all PyObject* in module state
- [ ] Add `m_clear` clearing all PyObject* in module state
- [ ] Add `m_free` if any non-Python cleanup is needed
- [ ] Replace direct global access with `PyModule_GetState()` calls
- [ ] Convert [N] static PyTypeObject(s) to heap types:
  [list each type]

### Phase 2: Type Slot Correctness
[Only items that need fixing -- skip if all types are correct]

For each type with issues:
- [ ] [type name]: [specific issue and fix]

### Phase 3: Stable ABI Adoption
[Skip if already compliant or if stable ABI is not desired]

**Difficulty: [Easy / Moderate / Hard]** (based on private API usage)

- [ ] Replace [N] internal struct accesses with accessor functions:
  [list each: e.g., "op->ob_type -> Py_TYPE(op)"]
- [ ] Replace [N] private API calls:
  [list each: e.g., "_PyObject_GC_TRACK -> PyObject_GC_Track"]
- [ ] Remove [N] forbidden header includes:
  [list each]
- [ ] Add `#define Py_LIMITED_API 0x03[XX]0000` before `#include <Python.h>`
- [ ] Update build system to pass `-DPy_LIMITED_API=0x03[XX]0000`

### Phase 4: Compatibility Cleanup
[Skip if no dead code or deprecated APIs]

- [ ] Remove [N] dead version guard blocks (targeting Python < [minimum]):
  [list files and line ranges]
- [ ] Replace [N] deprecated API calls:
  [list each: e.g., "PyModule_AddObject -> PyModule_AddObjectRef"]
- [ ] Consider adding `pythoncapi_compat.h` for forward-compatible macros

### Phase 5: Free-Threading Readiness (Optional)
[Only if targeting Python 3.13+]

- [ ] Add `{Py_mod_gil, Py_MOD_GIL_NOT_USED}` to module slots (or `Py_MOD_GIL_USED` if GIL is needed)
- [ ] Audit [N] static mutable variables for thread safety
- [ ] Add synchronization for shared mutable state

## Estimated Total Effort
[Summary: "N items across M phases. Core migration (Phase 1) is [difficulty]
and touches [N] files. Phases 2-5 are incremental and can be done separately."]

## References
- [PEP 489 -- Multi-phase extension module initialization](https://peps.python.org/pep-0489/)
- [PEP 384 -- Defining a Stable ABI](https://peps.python.org/pep-0384/)
- [PEP 703 -- Making the Global Interpreter Lock Optional](https://peps.python.org/pep-0703/)
- [pythoncapi-compat](https://github.com/python/pythoncapi-compat)
- [Porting C extensions to Python 3.13+](https://docs.python.org/3/howto/isolating-extensions.html)

Read the full file on GitHub · 113 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. 5d ago First seen · 113 lines · 58 tokens per session scan A f8523f96cada

Subscribe to this mod's changes

migrate is a command published in the GitHub repository ReviewToolkits/cext-review-toolkit (28 stars, last pushed 1mo ago), licensed MIT. It adds 58 tokens to every session and 1,345 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.