Skip to main content

Overview

The Stably CLI is a command-line tool for developers who prefer working in the terminal. It provides essential commands for authentication, resource creation, test execution, and the powerful stably fix command for automatic test maintenance.

Interactive Agent

Launch the interactive agent with stably:
stably
This opens a conversational interface where you can work with the AI agent to:
  • Create tests — Describe what you want to test and the agent generates Playwright tests
  • Fix failing tests — Paste error output or describe issues and get fixes applied
  • Explore your test suite — Ask questions about coverage, flaky tests, or test structure
  • Get guidance — Learn best practices or troubleshoot problems interactively
$ stably

🤖 Stably Agent
   Type your request or question. Press Ctrl+C to exit.

> Create a test for the checkout flow on our e-commerce site

Analyzing your application...
I'll create a test that covers:
  • Adding items to cart
  • Proceeding to checkout
  • Completing payment

✓ Created tests/checkout.spec.ts

> The login test is failing with a timeout error

Looking at the failure context...
The selector '.login-btn' no longer exists. I found a matching
element with '[data-testid="sign-in"]'.

Apply fix? (y/n): y
✓ Updated tests/auth.spec.ts

> What's our test coverage for the dashboard?

You have 12 tests covering the dashboard:
 4 tests for user settings
 3 tests for analytics widgets
 5 tests for navigation

Missing coverage: notification preferences, export functionality
The interactive agent is ideal when you want a flexible, back-and-forth workflow rather than running individual commands.

Running Tests

There are two ways to run your Playwright tests with Stably integration:

The stably fix Command

The most powerful CLI feature — diagnoses test failures and applies AI fixes:
# In CI: automatically uses the last failed run from the current CI job
stably fix

# Locally: provide the run ID from a failed test execution
stably fix <runId>

CI vs Local Usage

EnvironmentRun ID Required?Notes
CINoAutomatically detects the run ID from the CI environment
LocalYesCopy the run ID from the test output or Stably dashboard
(Upcoming) Local runs will also support automatic run ID detection, so you won’t need to provide the run ID manually.

How It Works

1

Run tests

Execute your test suite with stably test (reporter captures run data)
2

Identify failures

For failures, use stably fix [runId] with the run ID from the output
3

AI analysis

The AI analyzes the failure context (screenshots, logs, DOM, traces)
4

Apply fixes

It generates and applies fixes to your test code
5

Verify

Rerun the test to verify the fix worked
stably test
# Running tests...
# ✓ 45 tests passed
# ✗ 3 tests failed
# Run ID: run_abc123

stably fix run_abc123
# Analyzing failures...
#
# Test: checkout.spec.ts > complete purchase
# Issue: Selector '.checkout-button' not found
# Fix: Updated to '[data-testid="checkout-btn"]'
# Status: ✓ Fixed and verified
#
# Test: login.spec.ts > invalid credentials
# Issue: Error message assertion failed
# Fix: Updated expected text to match new design
# Status: ✓ Fixed and verified
#
# Summary: 2 auto-fixed

Command Reference

Core Commands

CommandDescription
stablyStart interactive agent session
stably initInitialize Playwright and Stably SDK (handles login automatically)
stably loginLogin via browser authentication (optional, init handles this)
stably logoutLogout and clear credentials
stably whoamiShow authentication status
stably create [prompt]Create tests with AI
stably testRun Playwright tests
stably fix [runId]Fix failing tests with AI (runId optional in CI)
stably installInstall browser dependencies

Additional Options

# Get version
stably --version

# Get help
stably --help

# Help for specific command
stably help [command]

Troubleshooting

# Clear and re-authenticate
stably logout
stably login

# Or use API key directly
export STABLY_API_KEY=stably_...

# Check current status
stably whoami
If you encounter browser-related errors:
# Install browser dependencies
stably install

# Or use Playwright directly
npx playwright install

Next Steps