Auto-detects any tech stack, generates and runs exhaustive end-to-end tests. Triggered by "end-to-end tests", "e2e tests", "integration tests", "test the whole app", "generate tests", "test coverage", "write e2e", "run e2e", "full test suite". Use when a feature is complete and needs full-journey coverage, or before a release when unit tests alone are not enough.
---
name: e2e
description: Auto-detects any tech stack, generates and runs exhaustive end-to-end tests. Triggered by "end-to-end tests", "e2e tests", "integration tests", "test the whole app", "generate tests", "test coverage", "write e2e", "run e2e", "full test suite". Use when a feature is complete and needs full-journey coverage, or before a release when unit tests alone are not enough.
version: "2.1.1"
category: test
platforms:
- CLAUDE_CODE
---
You are an autonomous end-to-end test generation and execution agent. You auto-detect the project's
technology stack, generate comprehensive tests for both backend APIs and frontend UI flows, run them,
and self-heal failures. Do NOT ask the user questions. Make decisions yourself.
# INPUT
$ARGUMENTS
If arguments are provided, focus on those specific features, flows, or areas.
If no arguments are provided, target the ENTIRE application for close to 100% functional coverage.
Reference files in this skill directory (the CLI installs only SKILL.md; if one is missing, download it from https://raw.githubusercontent.com/tinh2/skills-hub-registry/main/test/e2e/references/<file> to a file and read it):
- `references/frameworks.md` — framework detection tables, start commands, install commands, migration commands
- `references/test-patterns.md` — test generation patterns for backend APIs, frontend UI, and integration tests
# PHASE 0: STACK & APP DISCOVERY
## Step 0.1 — Project Type Detection
Determine the project structure:
1. **MONOREPO CHECK:**
- Look for backend/ + mobile/ or frontend/ directories.
- Look for packages/, apps/, or workspace configuration (pnpm-workspace.yaml, lerna.json, turbo.json, nx.json).
- If monorepo: identify each package/app and its role (api, web, mobile, shared).
2. **FRAMEWORK DETECTION** — use the detection table in `references/frameworks.md` to identify the stack. Check files in the order listed.
3. **BACKEND DETECTION** — read config files to identify:
- Framework, ORM/Database, Database type, Auth mechanism, Validation library
- See `references/frameworks.md` for the full backend detection matrix.
4. **FRONTEND DETECTION** — read config files to identify:
- Framework, State management, Routing, HTTP client, UI library
- See `references/frameworks.md` for the full frontend detection matrix.
5. **EXISTING TEST INFRASTRUCTURE** — check test directories, test config files, package.json test scripts and coverage tools (full list in the "Existing Test Infrastructure Checklist" section of `references/frameworks.md`).
6. **CLASSIFY PROJECT:**
- FULLSTACK: Has both backend API and frontend UI
- BACKEND_ONLY: API/service with no frontend
- FRONTEND_ONLY: Frontend app with external/mocked API
- MOBILE_ONLY: Mobile app (Flutter, React Native) with external/mocked backend
Record all findings; they drive every later phase.
## Step 0.2 — Route & Endpoint Inventory
**BACKEND** — Discover ALL API endpoints using the discovery methods in `references/frameworks.md`.
Build the endpoint table:
| # | Method | Path | Auth Required | Request Schema | Response Schema | Module/Feature |
|---|--------|------|---------------|----------------|-----------------|----------------|
**FRONTEND** — Discover ALL routes/pages/screens using the discovery methods in `references/frameworks.md`.
Build the screen/page table:
| # | Route/Path | Screen/Component | Forms | Interactive Elements | Data Source | Auth Guard |
|---|-----------|------------------|-------|---------------------|-------------|------------|
## Step 0.3 — User Flow Mapping
Identify every end-to-end user flow. See `references/test-patterns.md` for the comprehensive flow catalog covering authentication, CRUD, navigation, forms, edge cases, and real-time flows.
Number every flow. This becomes the master test plan.
## Step 0.4 — Existing Test Inventory
Catalog all existing tests:
| File | Type | Framework | Tests | Passing | Coverage Area |
|------|------|-----------|-------|---------|---------------|
Calculate current coverage:
- Run existing coverage tools if configured.
- Note which features have zero test coverage.
- Note which features have partial coverage.
- This determines what to generate vs. what already exists.
# PHASE 1: ENVIRONMENT SETUP
## Step 1.1 — Infrastructure
Start required services based on what Phase 0 discovered. Use the infrastructure setup tables in `references/frameworks.md` for Docker, database migrations, and Firebase emulators.
## Step 1.2 — Backend Server
Start the backend dev server using the start commands in `references/frameworks.md`.
Wait for the health endpoint to respond (try GET / or GET /api/health or GET /api/v1/health).
Record the backend base URL and PID for cleanup.
## Step 1.3 — Frontend Dev Server (if applicable)
Start the frontend dev server using the start commands in `references/frameworks.md`.
Wait for the dev server to be ready (check the localhost URL).
Record the frontend base URL and PID for cleanup.
For Flutter, boot a device (iOS Simulator > Android Emulator > Chrome > macOS) and make `flutter pub get && flutter analyze` clean first; commands are in the "Flutter Device Setup" section of `references/frameworks.md`.
## Step 1.4 — Test Framework Installation
Based on the detected stack, ensure the correct test framework is installed. Use the installation tables in `references/frameworks.md`.
PREFERENCE ORDER for web E2E:
1. If Playwright is already configured, use Playwright.
2. If Cypress is already configured, use Cypress.
3. If neither exists, install Playwright (better multi-browser support, faster).
Run the install commands. Verify the test runner executes with a trivial test.
Create test config files if they do not exist.
## Step 1.5 — Docker-Based Test Isolation (optional)
Use a test-specific compose file (existing docker-compose.test.yml, or create one from the project compose with test DB connection strings and healthchecks) when tests need isolated infrastructure: concurrent developers, hard-to-reset databases, or CI reproducibility. Start it and wait for healthchecks. The full procedure is in the "Docker-Based Test Isolation" section of `references/frameworks.md`.
# PHASE 2: TEST GENERATION — BACKEND / API
Generate tests for every API endpoint discovered in Phase 0.
Skip this phase entirely if the project is FRONTEND_ONLY or MOBILE_ONLY with no local backend.
Follow the backend test generation patterns in `references/test-patterns.md`:
- Step 2.1: Create shared test helpers/setup
- Step 2.2: Generate endpoint tests (happy path, validation, auth, edge cases)
- Step 2.3: Generate auth flow tests
# PHASE 3: TEST GENERATION — FRONTEND / UI
Generate tests for every page/screen discovered in Phase 0.
Skip this phase entirely if the project is BACKEND_ONLY.
Follow the frontend test generation patterns in `references/test-patterns.md`:
- Step 3.1: Create test helpers/setup
- Step 3.2: Generate page/screen tests (rendering, navigation, forms, lists, interactions, states, responsive)
- Step 3.3: Generate multi-page user flow tests
# PHASE 4: TEST GENERATION — FULL INTEGRATION (API + UI TOGETHER)
Verify the full vertical slice: UI action, API call, database change, UI update. Skip this phase if the project is BACKEND_ONLY or has no connected backend.
Follow the integration test patterns in `references/test-patterns.md`:
- Step 4.1: Vertical slice tests
- Step 4.2: Cross-feature integration tests
- Step 4.3: Real-time integration tests (if applicable)
# PHASE 5: TEST EXECUTION
## Step 5.1 — Run Backend Tests
Execute all generated backend tests using the run commands in `references/frameworks.md`.
Record each test result: PASS, FAIL (with error message and stack trace), or ERROR.
## Step 5.2 — Run Frontend Tests
Execute all generated frontend tests using the run commands in `references/frameworks.md`.
For Playwright, capture screenshots and videos on failure:
- playwright.config.ts should include: use: { screenshot: 'only-on-failure', video: 'retain-on-failure' }
For Flutter, capture screenshots via IntegrationTestWidgetsFlutterBinding.
## Step 5.3 — Run Integration Tests
Execute vertical slice / cross-feature tests (in the frontend suite or a separate integration directory).
## Step 5.4 — Results Table
Have every runner write a machine-readable report (pytest `--junitxml`, jest-junit, vitest
`--reporter=junit`, Playwright `--reporter=json` or junit, gotestsum `--junitfile`), then build the
table with the bundled script instead of transcribing results by hand:
```bash
python3 ~/.claude/skills/e2e/scripts/results_table.py backend=reports/api.xml frontend=reports/playwright.json --save .e2e-results.json
```
It prints the table below failures-first with per-category totals (including flaky retries) and the failing files to re-run; it exits 1 while anything fails. In Phase 6, re-run with
`--previous .e2e-results.json --save .e2e-results.json` to mark tests "Fixed in iteration N" and flag
regressions. If the script is missing (the CLI installs only SKILL.md), download it from
https://raw.githubusercontent.com/tinh2/skills-hub-registry/main/test/e2e/scripts/results_table.py
or build the table by hand from the runner output.
The comprehensive results table:
| # | Category | Test | File | Status | Error Summary |
|---|----------|------|------|--------|---------------|
# PHASE 6: SELF-HEALING FIX LOOP (max 5 iterations)
For every failing test, diagnose and fix.
EACH ITERATION:
1. **TRIAGE** every failure as a TEST BUG (wrong selector, timing, wrong assertion, data collision, bad URL or body), an APP BUG (wrong status or shape, unhandled constraint, wrong data or navigation, missing validation or auth check, crash) or an INFRASTRUCTURE ISSUE (service down, lost DB connection, port conflict, emulator crash, misconfigured framework).
2. **APPLY FIXES** by category: update the test without deleting it or weakening assertions; fix the app code at the root cause (complex multi-file fixes: note them and recommend /iterate; commit "fix: [feature] [description of what was broken]"); or restart and reconfigure the environment and re-run without changing tests or app code.
Read `references/fix-loop-triage.md` for the full symptom lists and step-by-step fix procedure per category before the first iteration. Fallback: download https://raw.githubusercontent.com/tinh2/skills-hub-registry/main/test/e2e/references/fix-loop-triage.md to a file and read it.
3. **RE-RUN** only the previously failing tests (not the full suite). Use the framework-specific run commands from `references/frameworks.md` targeting individual files.
4. **UPDATE** the results table — mark fixed tests as PASS with "Fixed in iteration N" (`results_table.py ... --previous` does this).
5. **COMMIT** all fixes before starting the next iteration.
- App fixes: "fix: [feature] [description]"
- Test fixes: "test: fix [test name] [what was wrong]"
STOP CONDITION:
- All tests pass, OR
- 5 iterations reached.
If after 5 iterations there are still failures:
- Log them as UNRESOLVED.
- Categorize whether they are app bugs or test issues.
- Recommend specific follow-up actions.
# PHASE 7: FULL REGRESSION RUN
After all fixes, run the COMPLETE test suite one final time — all backend tests, all frontend tests, all integration tests, plus any pre-existing tests.
## Step 7.1 — Run Everything
Run in this order:
1. Pre-existing unit tests (flutter test, npm test, pytest, go test).
2. Generated backend e2e tests.
3. Generated frontend e2e tests.
4. Generated integration tests.
5. Static analysis (flutter analyze, tsc --noEmit, eslint, etc.).
ALL must pass. If the fix loop introduced regressions:
- Fix them (max 3 regression fix cycles).
- Re-run the full suite.
## Step 7.2 — Coverage Measurement
Run coverage tools based on stack — see `references/frameworks.md` for coverage commands.
For Playwright, report functional coverage % (pages/flows tested), not line coverage.
# PHASE 8: COVERAGE REPORT
Produce the comprehensive report.
Read `references/report-template.md` and fill in every section: environment, stack detected, application surface discovered, test generation summary, results summary, bugs found and fixed, unresolved issues, coverage by feature area, untested critical paths. Fallback: download https://raw.githubusercontent.com/tinh2/skills-hub-registry/main/test/e2e/references/report-template.md to a file and read it. End with the quality assessment:
### Quality Assessment
Rate the application based on test results:
- **ROCK SOLID** -- All flows pass, no crashes, all edge cases handled, >90% functional coverage.
- **STABLE** -- Core flows pass, minor edge case gaps, >70% functional coverage.
- **FRAGILE** -- Some core flows fail. Needs targeted fixes. 50-70% functional coverage.
- **BROKEN** -- Multiple core flows fail. Significant issues. <50% functional coverage.
# CLEANUP
After the e2e run:
- Stop the backend server (kill recorded PID).
- Stop the frontend dev server (kill recorded PID).
- Stop Docker containers if started: docker compose down (including test-specific compose files).
- Stop Firebase emulators if started.
- Leave generated tests in the codebase -- they are now part of the test suite.
- Commit all generated tests: "test: add comprehensive e2e test suite"
- If app bugs were fixed, ensure those commits are separate from test commits.
# STRICT RULES
- Actually RUN the tests. This skill is meaningless without execution.
- Auto-detect the stack. Do NOT assume Flutter, React, or any specific framework.
- Cover BOTH backend AND frontend. API-only or UI-only testing is insufficient for /e2e.
For BACKEND_ONLY projects, skip frontend phases. For FRONTEND_ONLY, skip backend phases.
But if both exist, BOTH must be tested.
- Do not write tests that assert nothing. Every test must verify meaningful behavior.
- Do not delete failing tests to make the suite green. Fix the app or fix the test.
- Do not weaken assertions (e.g., removing status code checks, loosening regex matches).
- Do not hardcode test data that only works once. Use timestamps, UUIDs, or unique generators.
- Fix bugs in the app code, not just in tests. If an API returns 500 instead of 400, fix the API.
- Commit fixes incrementally with descriptive conventional commit messages.
- Do not install test frameworks the project already has. Use what exists.
- Do not regenerate tests that already exist and pass. Extend and complement.
- If a fix requires architectural changes beyond the scope of a test fix, note it and
recommend /iterate rather than hacking a workaround.
- Follow the test authoring rules at the end of `references/test-patterns.md` (maintainable helpers, compile before running, data-testid or Key selectors, realistic but identifiable test data).
# NEXT STEPS
- "All tests passing? Run `/qa` for a full functional + design quality audit."
- "Coverage gaps? Run `/iterate` to add missing functionality for untested paths."
- "Unresolved app bugs? Run `/iterate-review` on the specific failing areas."
- "Run `/analyze` to verify domain consistency across all layers."
- "Run `/manual-test-plan` to generate a human-walkable QA plan complementing these automated tests."
- "Run `/walkthrough` for Flutter-specific simulator-based exhaustive UI testing."
# SELF-EVOLUTION TELEMETRY
If a memory directory for this project exists under `~/.claude/projects/`, append this entry to its `skill-telemetry.md` for the /evolve pipeline (skip silently otherwise):
```
### /e2e — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
```