Twinrun

Twinrun

A Python CLI that runs your old and new code on the same inputs, diffs everything that could differ, and tells you exactly what changed behavior during a refactor or migration.

🔗 Visit Twinrun
📁 Editors, IDEs & Dev Tools🗣️ English📅 September 6, 2026

Description

Refactoring code — or migrating it to a new library version, a new framework, or a rewritten module — always carries the same fear: did I just quietly change behavior somewhere I didn't test? Writing new unit tests to catch every possible regression is slow and you can never be sure you covered everything the old code actually did. Twinrun takes a different approach: instead of writing new assertions by hand, it runs both the old and new versions of your code on the same generated inputs and automatically flags anywhere the outputs, exceptions, printed output, or even mutated arguments diverge.

Under the hood, Twinrun checks out both code revisions into isolated git worktrees, generates test inputs automatically from type annotations, existing test-suite literals, and guard constants in the code (with an optional --llm flag to generate more when it runs out of ideas), and executes both versions in separate subprocesses for clean isolation. It compares far more than return values — types, exceptions raised, stdout, argument mutation, and instance state are all checked — then filters out flaky/non-deterministic noise and clusters related findings so a hundred symptoms of one root cause don't look like a hundred separate bugs. An --accept flag lets you formally record a behavior change as intentional rather than a regression. It's free, open source, Python 3.10+, and has zero external dependencies.

💬 Our review

The short version: Twinrun automates the tedious part of verifying a refactor — actually generating enough inputs to exercise the differences and comparing every observable effect — which is exactly the work engineers usually skip under time pressure, and skipping it is how regressions slip through.

It occupies a narrower, more specific niche than heavier hitters like Semgrep or CodeQL (static analysis for known bug patterns, not behavioral diffing) or Diffblue (AI-generated unit tests from scratch) — Twinrun's value is specifically comparing two concrete revisions of the same code, closer in spirit to GitHub's own Scientist library or Diffy, but as a standalone CLI rather than something you wire into production traffic. The automatic input generation is clever but has real limits: it can only generate as good a corpus as the type hints and constants it finds, so behavior gated behind complex runtime state may need the --llm assist or manual seeding to actually get exercised. Being free, open source, and dependency-free removes any adoption friction. Worth adding to your refactor/migration checklist if you're on Python 3.10+; not a substitute for integration or property-based tests, but a strong complement to them.

💰 Pricing

FreeFree and open-source, no external dependencies
Open Source 0

📊 Global score

53Average
🌐Availability15/100Faible

1 language · 0 platform

📄Profile90/100Excellent

Profile completeness

🤖 AI-enriched data

💰 Pricing model
🆓 Gratuit

Open source, gratuit, zéro dépendance externe

👥 Target audienceDéveloppeurs Python faisant du refactoring, des migrations, ou de la détection de régression comportementale
🗣️ Languagesen
🌍 Target countriesInternational
👍

Pros

Génération automatique d'inputs de test depuis les type hints et le code existant

Compare bien plus que la valeur de retour : exceptions, stdout, mutations d'arguments, état d'instance

Filtrage du flaky et clustering des findings liés

Gratuit, open source, zéro dépendance

👎

Cons

Limité à Python 3.10+

Qualité des inputs générés dépend des type hints/constantes présents dans le code

Ne remplace pas les tests d'intégration ou property-based, les complète seulement

❓ Frequently asked questions

What is Twinrun in one sentence?
How much does it cost?
Does it work outside Python?
How does it generate test inputs automatically?
Is it worth the money compared to alternatives?
Which tool should you pick for your case?