Skip to content

Overview

Fixwright Overview

Fixwright is an AI-powered service that automatically detects and fixes broken Playwright tests using Claude AI. It works seamlessly with Stepwright failure cases.

Why Fixwright?

Browser automation tests break frequently. Selectors change, page layouts evolve, and timing issues occur. Fixwright automates the maintenance:

AI Analysis

Claude AI analyzes failures using screenshots, DOM, and error context

Automatic Fixes

Proposes and applies code fixes automatically

Validation

Re-runs tests to validate fixes actually work

PR Creation

Creates pull requests with detailed explanations

How It Works

┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Stepwright │────▶│ Fixwright │────▶│ Pull Request │
│ Failure Case │ │ AI Analysis │ │ with Fix │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
Screenshots Claude AI Validated
DOM Snapshot Agent SDK Working Fix
Console Logs
  1. Capture - Stepwright captures failure artifacts (screenshots, DOM, console logs)
  2. Analyze - Claude AI examines the failure and understands the root cause
  3. Fix - AI applies code changes to resolve the issue
  4. Validate - Re-runs the script to verify the fix works
  5. PR - Creates a pull request with the fix and explanation

Basic Example

import { FixWright } from '@korvol/fixwright';
const fixwright = new FixWright({
ai: {
apiKey: process.env.ANTHROPIC_API_KEY!,
model: 'claude-sonnet-4-20250514', // Optional
},
git: {
baseBranch: 'main',
fixBranchPrefix: 'fix/stepwright-',
},
github: {
token: process.env.GITHUB_TOKEN!,
owner: 'your-org',
repo: 'your-repo',
},
});
// Watch a directory for failure cases
fixwright.useFileSource('./failure-cases');
// Listen to events
fixwright.on('attempt:success', (attempt) => {
console.log('Fix successful!', attempt.proposedFix);
});
fixwright.on('pr:created', (prUrl) => {
console.log('PR created:', prUrl);
});
// Start processing failures
await fixwright.start();

Key Features

Claude Agent SDK

Fixwright uses the Claude Agent SDK for autonomous code analysis and fixing:

  • Reads source files to understand context
  • Searches codebase with grep/glob patterns
  • Applies targeted code edits
  • Validates changes compile correctly

Multiple Failure Sources

Process failures from different sources:

// File-based (for development)
fixwright.useFileSource('./failure-cases');
// Database (for production)
fixwright.useSource(new DatabaseFailureSource({
connectionString: process.env.DATABASE_URL,
}));
// Custom sources
fixwright.useSource(myCustomSource);

Automatic Retry Logic

Multiple fix attempts with learning:

{
fixing: {
maxAttempts: 3, // Try up to 3 different fixes
maxRetriesPerAttempt: 2, // Retry validation 2 times
cooldownMs: 1000, // Wait between attempts
}
}

Full Event System

Subscribe to detailed events:

// Attempt lifecycle
fixwright.on('attempt:start', (attempt) => ...);
fixwright.on('attempt:analyzing', (attempt) => ...);
fixwright.on('attempt:fixing', (attempt) => ...);
fixwright.on('attempt:validating', (attempt) => ...);
fixwright.on('attempt:success', (attempt) => ...);
fixwright.on('attempt:failed', (attempt) => ...);
// Agent activity
fixwright.on('agent:thinking', (text) => ...);
fixwright.on('agent:tool_use', (tool, input) => ...);
fixwright.on('agent:edit', (editInfo) => ...);
// Results
fixwright.on('pr:created', (prUrl) => ...);
fixwright.on('failure:completed', (summary) => ...);

Architecture

┌─────────────────────────────────────────────────────────────────┐
│ FixWright │
├─────────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │FailureSource │ │ FixingLoop │ │ EventEmitter │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ AgentFixer │ │ GitManager │ │ PRCreator │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ Claude Agent SDK │
│ (Read, Edit, Bash, Grep, Glob tools) │
└─────────────────────────────────────────────────────────────────┘

Requirements

  • Node.js 18.x or higher
  • Anthropic API key - For Claude AI access
  • GitHub token (optional) - For PR creation

Configuration

interface FixWrightConfig {
// Required: Claude AI configuration
ai: {
apiKey: string;
model?: string; // Default: 'claude-sonnet-4-20250514'
};
// Git branch configuration
git?: {
baseBranch: string;
fixBranchPrefix: string;
};
// GitHub for PR creation
github?: {
token: string;
owner: string;
repo: string;
};
// Validation settings
validation?: {
stepwrightPath: string;
timeout: number;
};
// Retry settings
fixing?: {
maxAttempts: number;
maxRetriesPerAttempt: number;
};
}

Next Steps