Operational playbooks. Pair with release-manager and security-engineer subagents for the judgment calls.
For breaking (major) releases, see "Major release" below.
Refactron ships two artifacts per release: the npm package and the PyPI
wrapper (refactron-py/). They are versioned in lockstep. npm must be
published first, because the PyPI package is a thin shim that shells out to
the npm CLI: a pip user who installs before npm is live gets a wrapper that
correctly refuses to run. Publishing pip first is a broken window, not a
disaster, but the ordering is not optional.
-
Confirm clean working tree.
git statusshows nothing uncommitted onmain. -
Pull latest.
git checkout main && git pull origin main. -
Run the full pre-publish chain.
npm run prepublishOnly
Must be green. If anything fails, fix it on a branch and merge first.
-
Check dependency advisories.
npm audit
Resolve anything high or critical before publishing.
npm audit fix --package-lock-onlyhandles the transitive cases without touching declared ranges; anything needing a range change is a separate PR, not a release-day edit. -
Update CHANGELOG.md. Move items from
[Unreleased]to a new[X.Y.Z] — YYYY-MM-DDsection. Group: Added / Changed / Fixed / Deprecated / Removed / Security. Entries must be user-facing. -
Mirror the entry into
docs/changelog.mdx. Convert the<Update label="Unreleased">block into a released block:<Update label="X.Y.Z" description="Month D, YYYY">. The closing</Update>must sit at column 0 with a blank line before it, or Mintlify fails to parse the page (see PR #76). -
Bump both versions.
package.json#versionrefactron-py/refactron/__init__.py__version__
That Python literal is the single source of truth for the wrapper:
refactron-py/pyproject.tomlreads it statically via[tool.setuptools.dynamic], so there is nothing else to edit and the two cannot drift. Sync the lockfile's copy of the version withnpm install --package-lock-only. -
Sweep the docs for the old version. Install commands are pinned in prose.
grep -rn "refactron@0\.\|refactron==0\." README.md docs/ | grep -v changelog
Every hit must name the version you are about to publish.
-
Commit.
git commit -am "chore(release): vX.Y.Z" -
Tag.
git tag -a vX.Y.Z -m "vX.Y.Z"
- npm.
Verify the file list against
npm publish --dry-run
package.json#files: nodev-docs/, noplayground/, no.refactron/, notests/, nobench/, nodocs/. Source maps are shipped on purpose, so a user reading a CLI stack trace gets real line numbers; do not "fix" that. Confirm the Python sidecars are present:dist/verify/checks/_py/*.py(all three). There must be NOdist/transform/at all; migration mode left in 0.4.0. They are copied byscripts/postbuild.mjs, not emitted bytsc. That script derives the list fromsrc/verify/checks/_py/and asserts every file arrived indist/, so a copy regression fails the build instead of shipping a verification engine that dies at runtime. - PyPI.
Both artifacts must report
cd refactron-py rm -rf dist build refactron.egg-info python3 -m build # needs `pip install build` python3 -m twine check dist/* # needs `pip install twine`
PASSED. Confirm the version in the filenames is the one you bumped, and thatLICENSEandNOTICEare in the sdist (tar tzf dist/refactron-X.Y.Z.tar.gz). - Push.
git push origin main --tags
-
Push the tag and let CI publish.
git push origin main --tags
.github/workflows/release.ymlfires onv*.*.*and runs the whole release: it validates the tag against both versions, runs the full suite, publishes to npm and PyPI over OIDC trusted publishing, then drafts the GitHub Release. There are no tokens to paste and nothing to run by hand.Watch it:
gh run watch $(gh run list --workflow Release --limit 1 --json databaseId --jq '.[0].databaseId')If
Validate Tagfails, nothing publishes: every later job is skipped. Fix the mismatch onmain, delete the tag locally and on the remote, then re-tag the new commit. -
Manual publishing is a fallback, not the path. Use it only when the pipeline itself is broken, and never after a tag has already published, because a second attempt at the same version errors on npm and is silently skipped on PyPI.
npm publish # npm first: the pip wrapper shells out to this CLI cd refactron-py && python3 -m twine upload dist/*
PyPI credentials come from an API token in
~/.pypircorTWINE_USERNAME=__token__/TWINE_PASSWORD=pypi-.... PyPI does not allow re-uploading a filename, so a bad upload means burning the version number and shipping X.Y.Z+1. -
GitHub Release. CI drafts it from the tag. Review the body, replace the generated commit list with the CHANGELOG section, and publish it.
- npm install.
cd /tmp && rm -rf verify-release && mkdir verify-release && cd verify-release npm init -y npm install refactron@X.Y.Z npx refactron --version # should print X.Y.Z
- The sidecars survived the tarball.
Both must be non-empty.
ls node_modules/refactron/dist/verify/checks/_py/ ls node_modules/refactron/dist/verify/checks/_py/
- The MCP bin exists.
ls node_modules/.bin/refactron-mcp
- The pip wrapper works.
Then check the failure path, which is the one users actually hit. With the npm CLI off
cd /tmp && rm -rf verify-pip && python3 -m venv verify-pip ./verify-pip/bin/pip install refactron==X.Y.Z ./verify-pip/bin/refactron --version # should print X.Y.Z via the npm CLI
PATH, the wrapper must printnpm install -g refactron@X.Y.Zand exit non-zero. It must never install anything and must never loop: inside a venv the namerefactronresolves to the wrapper's own console script, and re-executing it is an infinite loop (fixed in 0.3.0, worth re-checking whenevercli.pychanges).
If any step fails after npm publish or twine upload, see "Rolling back a bad publish" below.
Same as the patch/minor process, plus:
- ADR exists for every breaking change, accepted before tagging.
- Migration guide at
docs/migrations/vX-to-vY.mdx. Pinned in the GitHub Release body. - Deprecation cycle complete. Anything being removed was deprecated in the prior minor with a warning pointing at the replacement.
- Codemod (where feasible). Eat our own dogfood —
npm install refactron-codemod-vX-to-vYshould automate the migration.
Do not ship a major on a Friday.
You cannot un-publish from npm. A npm unpublish is restricted to ≤ 72h after publish and is discouraged; even then it leaves a tombstone.
Instead:
- Immediately publish a patch reverting the change.
git revert <commit> # fix CHANGELOG to reflect the revert npm version patch -m "chore(release): vX.Y.Z+1 — revert <thing>" npm publish
npm dist-tagshenanigans are tempting but break consumers who pinned tolatest. Don't.- Issue a security advisory via
gh api repos/Refactron-ai/refactron/security-advisoriesif the bad publish has a security impact. - Communicate. Pin a notice in the GitHub Discussions; mention in the next CHANGELOG entry under
SecurityorFixed.
PyPI differs from npm here. You cannot re-upload a filename, ever, so the fix is always a new version, never a replacement. twine has no unpublish. You can yank a release from the PyPI web UI (Manage, then the release, then Options, then Yank), which hides it from new resolutions while leaving it installable for anyone who pinned it exactly. Yank a broken wrapper as soon as the replacement is up; a yanked release still satisfies refactron==X.Y.Z, which is what keeps existing lockfiles working.
Because the wrapper is version-locked to npm, a bad npm publish also makes the matching pip release wrong. Ship the patch to both, in the same npm-then-pip order.
Triage in order:
- Severity? Look at the CVSS score and the actual call paths. A 9.8 in a dep we never invoke at runtime is lower-priority than a 7.5 in a hot path.
- Patched version available?
- Yes, semver-compatible → bump the lockfile, run the suite, publish a patch.
- Yes, but requires a major bump → assess: file an ADR for the upgrade if it's a transitive dep that forces our majors; pin the safe version meanwhile.
- No → check if the vuln is exploitable in our usage; if not, add an exception with a documented expiry date.
- Disclose if needed. If our usage was exploitable, draft a GHSA via GitHub's Security Advisories. Coordinate disclosure timing.
- Read the migration guide for the version.
- Bump in
package.json. npm run test. Most failures will be config-shape changes (vitest.config.ts).- Pay attention to: snapshot serializer differences, timing semantics in
vi.useFakeTimers, mock isolation defaults. - If snapshots changed across versions for unrelated reasons, regen + diff manually (see above).
Mac / Linux:
brew install node python3 # or your distro's package manager
git clone https://github.com/Refactron-ai/refactron.git
cd refactron
git config core.hooksPath .githooks # enable commit-msg + pre-commit hooks
npm install
npm run build
npm testWindows: native Windows is supported and covered by CI (Node 18, 20 and 22). npm run build goes through scripts/postbuild.mjs rather than shell commands, because mkdir -p is a cmd.exe builtin that rejects -p and the old build silently never worked there.
- Reproducer? If not, ask for one. Most "bug reports" become non-bugs once a repro is attempted.
- Label —
bug/feature/docs/question/good-first-issue(only for tightly-scoped, low-context tasks). - Severity —
critical(data loss, security, prod down) /high(broken core feature) /medium(broken edge feature) /low(cosmetic, nit). - Assign if obvious; otherwise leave unassigned and let someone claim.
- Link any related issue/PR with
Related to #N.
- Write it down as you figure it out. Append a new section here.
- Open an ADR if the situation involves an architectural call you'd want a future person to find.
- A runbook entry that doesn't exist costs the next engineer an hour. Cheap to write, expensive to skip.