mechanical-refactor-verify

Make mechanical refactoring (file splits, function moves, module extractions, renames) machine-checkable instead of eyeballed. Reproduce a relocation commit byte-for-byte from faithful primitives, and split an extraction into a verifiable prepare + move + postpare. Use when doing or reviewing such changes.

Install
npx skills add 'https://github.com/sgl-project/sglang/tree/main/.claude/skills/mechanical-refactor-verify'
Download bundle ↓
main · a9fb1c3Scanned 2026-09-17

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗

scripts/tests/reproduction_utils/reproduction_testlib.py

scripts/tests/reproduction_utils/reproduction_testlib.pyBrowse 41 files
View on GitHub
← Back to SKILL.md
import subprocessimport sysfrom pathlib import Path import pytest sys.path.insert(0, str(Path(__file__).resolve().parents[2])) import mechanical_refactor_reproduction_utils as rrfrom mechanical_refactor_reproduction_utils import (    Repro,    _def_span,    _find_class,    _find_def,    _replace_span,    _slice_span,    dedent,    exec_command,    git_add_and_commit,    verify_mechanical_refactor,)  def _apply(repro: Repro, root: Path) -> None:    """Run a built Repro's recorded operations against a plain directory (no git)."""    for op in repro.ops:        op(root)  def _git(repo: Path, *args: str) -> str:    return subprocess.run(        ["git", *args], cwd=repo, check=True, capture_output=True, text=True    ).stdout.strip()  def _write(repo: Path, **files: str | None) -> None:    for name, content in files.items():        path = repo / name.replace("__", "/")        if content is None:            path.unlink()        else:            path.parent.mkdir(parents=True, exist_ok=True)            path.write_text(content)  def _commit(repo: Path, message: str) -> str:    _git(repo, "add", "-A")    _git(repo, "commit", "-q", "-m", message)    return _git(repo, "rev-parse", "HEAD")