1 pointby ruslan_qm7 hours ago1 comment
  • ruslan_qm7 hours ago
    I built 9lives after realizing that coding agents often break Playwright tests in the most frustrating ways: an agent renames a button, the test turns red, and then either the agent or I have to rewrite a perfectly functional test.

    Running `9l heal login.spec.ts` executes the test, classifies the failure, and heals it using a tiered approach:

    Tier 1 is offline and deterministic. When a selector stops matching, 9lives searches the page snapshot Playwright captures at the moment of failure. It evaluates potential anchors in order of stability (data-testid > id > aria-label > text > class), and the strongest surviving anchor wins. There is no LLM, no network request, and no account required. Most selector drift is healed in seconds, for free. Unlike Healenium-style tools, 9lives doesn't require a baseline DOM from previous successful runs; it works directly from the failure.

    Tier 2 leverages the subscriptions you already have. For structural changes, it shells out to your installed Claude, Codex, or OpenCode CLI in headless mode, meaning the fix is covered by your existing coding-agent plan. No new API keys are required, though raw ANTHROPIC_API_KEY or OPENAI_API_KEY inputs work as well.

    Every fix is presented as a unified diff for you to approve (or via `--yes` in CI).

    I made a conscious design decision: 9lives refuses to heal failing assertions. A failing assertion indicates a change in behavior—potentially a real bug. Auto-rewriting these to force a "green" status is exactly how other self-healing tools mask regressions. 9lives flags these as "needs-human" and stops. Selector drift is healed; behavioral changes are surfaced.

    The toolkit also includes: - Support for Cypress and Selenium/pytest (same loop, auto-detected). - `9l mcp`: A zero-dependency MCP server allowing Claude Code or Cursor to call `heal_test` if they break a test mid-session. - `9l watch` (heal on save) and a pre-commit hook. - A GitHub Action that posts healing diffs directly to PRs. - `9l report`: A tool that analyzes local healing history to show you which selectors are rotting and which should be pinned.

    The project is MIT licensed, written in Python, and contains no telemetry, no account requirements, and a lean codebase. The README demo is fully offline and reproducible.

    Install via `pip install 9lives` or `curl -sL 9lives.run | sh` (which uses uv-tool-install—it's only 40 lines, so please read it first).

    To be transparent about limitations: Tier 1 requires the failure-time page snapshot, so Playwright offers the best offline healing experience, while Cypress and Selenium rely more heavily on Tier 2. Additionally, if you are healing tests against pages you do not control, please review the “Security & trust boundary” section of the README, as failure-page content becomes model input during Tier 2.