Loading...
Loading...
Expert setup assistant for the Stably Playwright SDK. Use this skill when installing Stably SDK in a new project, migrating from @playwright/test, or configuring Stably reporter for CI/CD. Triggers on tasks like "setup stably", "install stably sdk", or "configure playwright with stably".
npx skill4agent add stablyai/agent-skills stably-sdk-setupWelcome to Stably Playwright SDK Setup!
I'll guide you through the 9-step installation process.
## Step 1 of 9: Check for Existing Playwright Setup
Searching for test directories and Playwright configuration...testDir@playwright/testpackage.jsonI found [describe what you found].
Test directories identified:
- [list directories]
Proceeding to Step 2...## Step 2 of 9: Check Playwright Installation Status
Verifying Playwright installation and version...package.json@playwright/testI see you have Playwright ${version} installed. This is compatible with Stably SDK.Your Playwright version (${version}) is below the required 1.52.0.
Would you like to upgrade to the latest version?
I'll run: npm install -D @playwright/test@latestpnpm-lock.yamlyarn.lockpackage-lock.jsonnpm-shrinkwrap.json# npm
npm init playwright@latest
# pnpm
pnpm create playwright@latest
# yarn
yarn create playwrightStep 2 Complete: [Summary of Playwright installation status]
Proceeding to Step 3...## Step 3 of 9: Install/Update Stably SDK
Checking for @stablyai/playwright-test...@stablyai/playwright-testpackage.jsonnpm install -D @stablyai/playwright-test@latest# npm
npm install -D @stablyai/playwright-test@latest
# yarn
yarn add -D @stablyai/playwright-test@latest
# pnpm
pnpm add -D @stablyai/playwright-test@latestWould you like to install the Stably Email SDK (@stablyai/email) for testing email-dependent flows
(OTP codes, verification links, magic links, order confirmations)?
This is optional and can be installed later.# npm
npm install -D @stablyai/email@latest
# yarn
yarn add -D @stablyai/email@latest
# pnpm
pnpm add -D @stablyai/email@latestpnpm detected a store location conflict. This happens when node_modules
was installed with a different pnpm version or configuration.
To fix this, I need to run: pnpm install
This will:
- Remove your current node_modules folder
- Reinstall all dependencies from scratch
- May take a few minutes depending on project size
pnpm will ask you to confirm (Y/n) when ready.
Would you like me to proceed?pnpm installpnpm add -D @stablyai/playwright-test@latest@playwright/testdependenciesdevDependenciesFixed: Moved @playwright/test to devDependencies where it belongs.Step 3 Complete: [Summary of Stably SDK installation]
Proceeding to Step 4...## Step 4 of 9: Replace Playwright Imports
Finding test files with @playwright/test imports...@playwright/testfind . -type f \( -name "*.spec.ts" -o -name "*.test.ts" -o -name "*.spec.js" -o -name "*.test.js" \) -not -path "*/node_modules/*" -exec grep -l "@playwright/test" {} \;I found ${count} test files that need import updates:
- tests/example.spec.ts
- tests/login.spec.ts
...
I'll update them all at once using this command:
find <test_directory> -name "*.spec.ts" -o -name "*.spec.js" -o -name "*.test.ts" -o -name "*.test.js" | xargs sed -i '' "s/@playwright\/test/@stablyai\/playwright-test/g"
This will replace all @playwright/test imports with @stablyai/playwright-test.
May I proceed with the bulk update?Updated imports in ${count} test files
Verified: All test files now import from @stablyai/playwright-testStep 4 Complete: Test file imports updated
Proceeding to Step 5...## Step 5 of 9: Setup AI Rules & Commands
Adding Stably SDK rules so your AI coding assistant knows when and how to use the SDK...tests/e2e/test/claude.mdagents.mdclaude.mdclaude.md<!-- ── Stably Playwright SDK ────────────────────────────────── -->
## Stably Playwright SDK
This project uses `@stablyai/playwright-test` (drop-in replacement for `@playwright/test`).
Always import from `@stablyai/playwright-test`.
### Capabilities
| Method | When to use |
|---|---|
| `expect(page\|locator).aiAssert(prompt)` | Visual assertions on dynamic UIs |
| `page.extract(prompt)` / `locator.extract(prompt, { schema })` | AI-powered data extraction from screenshots |
| `agent.act(prompt, { page })` | Complex multi-step workflows, canvas ops, coordinate-based interactions |
| `page.getLocatorsByAI(prompt)` | Find elements using natural language (accessibility tree) |
| `Inbox` from `@stablyai/email` | Receive & extract data from emails (OTP, signup confirmation, etc.) |
| Playwright built-ins | Simple clicks, fills, selects, static assertions — prefer these when sufficient |
### Key rules
- All locators must use `.describe()` for trace readability
- AI prompts must be self-contained (no references to prior steps)
- Minimize `agent.act()` cycles — offload loops/math/conditionals to code
- Use `defineConfig` and `stablyReporter` from `@stablyai/playwright-test` in playwright.config.ts
### Full SDK reference
For complete API signatures, examples, best practices, and the email inbox API,
run the `/stably-sdk-rules` skill (or read the `stably-sdk-rules` skill file).<!-- ── Stably Playwright SDK.cursor/rules/stably-sdk-rules.mdcstably-sdk-rules.cursor/commands/create-e2e-test.mdstably-sdk-rulesStep 5 Complete: AI rules configured
Files created/updated:
- claude.md (in <location>) — Claude Code knows Stably SDK capabilities
and will load the full reference via /stably-sdk-rules when writing tests
- agents.md (in <location>) — Same rules for other AI agents
- .cursor/rules/stably-sdk-rules.mdc — Full Cursor rules (if applicable)
- .cursor/commands/create-e2e-test.md — Cursor command (if applicable)
Proceeding to Step 6...## Step 6 of 9: Configure playwright.config.ts
Updating configuration to use Stably's defineConfig and reporter...playwright.config.tsplaywright.config.jsplaywright.config.mjsdefineConfigimport { defineConfig, devices } from '@playwright/test';import { defineConfig, stablyReporter } from '@stablyai/playwright-test';
import { devices } from '@playwright/test';defineConfig@stablyai/playwright-teststablydevices@playwright/testreporterreporter: [
["list"],
stablyReporter({
apiKey: process.env.STABLY_API_KEY,
projectId: process.env.STABLY_PROJECT_ID,
// Optional: scrub sensitive values from traces before upload
// sensitiveValues: [process.env.SECRET_PASSWORD].filter(Boolean),
}),
],useuse: {
trace: 'on', // Required for Stably trace uploads
},.envapp/e2e/.env.envplaywright.config.tsimport { defineConfig, stablyReporter } from '@stablyai/playwright-test';
import { devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['list'],
stablyReporter({
apiKey: process.env.STABLY_API_KEY,
projectId: process.env.STABLY_PROJECT_ID,
}),
],
use: {
trace: 'on',
screenshot: 'on',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});Step 6 Complete: playwright.config.ts updated
Key changes:
- defineConfig now imported from @stablyai/playwright-test
- stablyReporter added to reporter array
- Tracing enabled (required for Stably trace uploads)
Credentials are read from STABLY_API_KEY and STABLY_PROJECT_ID env vars.
We'll set those up in the next step.
Proceeding to Step 7...## Step 7 of 9: Setup API Credentials
Now let's configure your Stably API credentials so you can run tests!
To connect to Stably, you need to configure your API credentials. How would you like to proceed?
1. **Guide me to set up .env file** (recommended) - I'll show you exactly what to add
2. **Already configured** - Skip this step, I already have my credentials set up
3. **Other secret management** - I use a different approach (e.g., AWS Secrets Manager, Vault, CI/CD variables)
Please choose an option (1, 2, or 3):Great! Please add your Stably credentials to your .env file:
1. Get your credentials from: https://auth.stably.ai/org/api_keys/
2. Open (or create) the .env file in your project root or test directory
3. Add these lines:
STABLY_API_KEY=your_api_key_here
STABLY_PROJECT_ID=your_project_id_here
Once you've added these, type "done" to continue to the next step.Skipping credential setup - assuming they're already configured.
Proceeding to Step 8...Please describe how you manage secrets in your project:
- Are you using a service like AWS Secrets Manager, HashiCorp Vault, Azure Key Vault, etc.?
- Or do you inject environment variables through your CI/CD pipeline?
- How are STABLY_API_KEY and STABLY_PROJECT_ID made available at runtime?
I'll provide guidance based on your setup.process.env.STABLY_API_KEYprocess.env.STABLY_PROJECT_IDStep 7 Complete: API Credentials configured
Proceeding to Step 8...## Step 8 of 9: Install Playwright MCP (Optional)
Stably SDK is compatible with Playwright MCP. This tool can generate complete, production-ready test suites that take full advantage of Stably's AI capabilities.
Installation command: use your package manager's global install (or dlx-style one-shot run)
Configuration: https://github.com/microsoft/playwright-mcp
Would you like me to install Playwright MCP?npm install -g @playwright/mcppnpm add -g @playwright/mcpyarn global add @playwright/mcpyarn dlx @playwright/mcp --helpStep 8 Complete: [Playwright MCP installed / Skipped]
Proceeding to final step...## Step 9 of 9: Run Verification Test (Final Step)
Installation is complete! Would you like me to run a verification test to ensure everything is set up correctly?
This will:
1. Create a simple test that navigates to stably.ai
2. Run the test to verify the SDK is working
Ready to proceed?${test_directory}/stably-verification.spec.tsimport { test, expect } from '@stablyai/playwright-test';
test('stably sdk verification', async ({ page }) => {
await page.goto('https://www.stably.ai');
await expect(page).aiAssert("the page shows the Stably home page");
});npm exec playwright test stably-verification.spec.tspnpm exec playwright test stably-verification.spec.tsyarn playwright test stably-verification.spec.tsStably Playwright SDK Setup Complete!
Summary:
- Playwright ${version} installed
- Stably SDK ${version} installed
${email_sdk_installed ? '- Stably Email SDK installed' : ''}
- ${count} test files updated
- AI rules configured for ${ide_name}
- Playwright config updated with Stably reporter
- API credentials configured
${mcp_installed ? '- Playwright MCP installed' : ''}
Next steps:
1. Run your tests with your package manager (`npm exec playwright test`, `pnpm exec playwright test`, or `yarn playwright test`)
2. View results in Stably Dashboard: https://app.stably.ai
3. Check out the docs: https://docs.stably.ai
Happy testing!cd <directory> && <package-manager> add <package>