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

Example Session

$ 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.

Authentication

# Authenticate via browser
stably login

# Check authentication status
stably whoami

# Get your API key from https://app.stably.ai/settings
export STABLY_API_KEY=stably_...

# Logout
stably logout

Creating Tests

The create command generates tests non-interactively from a prompt. For an interactive experience, use stably instead.
# Create a test with a prompt
stably create "test the user signup flow with email validation"

Running Tests

Run tests on your machine or in your CI:
# Run all tests
stably test

# Run with Playwright options
stably test --headed --project=chromium

# Install browser dependencies
stably install

The stably fix Command

The most powerful CLI feature—diagnoses test failures and applies AI fixes:
# Fix a specific test run
stably fix [runId]

# Use the run ID from a failed test execution
# The AI will analyze the failure and suggest/apply fixes

How It Works

  1. Run your test suite with stably test
  2. For failures, use stably fix [runId] with the run ID from the output
  3. The AI analyzes the failure context (screenshots, logs, DOM)
  4. It generates and applies fixes to your test code
  5. Rerun the test to verify the fix worked

Example Output

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

stably                    # Start interactive agent session
stably login              # Login via browser authentication
stably logout             # Logout and clear credentials
stably whoami             # Show authentication status
stably create [prompt]    # Create tests with AI
stably test               # Run Playwright tests
stably fix [runId]        # Fix failing tests with AI
stably install            # Install browser dependencies

Additional Options

# Get version
stably --version

# Get help
stably --help

# Help for specific command
stably help [command]

Troubleshooting

Authentication Issues

# Clear and re-authenticate
stably logout
stably login

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

# Check current status
stably whoami

Installation Issues

If you encounter browser-related errors:
# Install browser dependencies
stably install

# Or use Playwright directly
npx playwright install

Next Steps