一键导入
sparqrefactor
Updating E2E test files after codebase refactoring. Bulk renaming selectors, imports, class names, and string references across test suites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Updating E2E test files after codebase refactoring. Bulk renaming selectors, imports, class names, and string references across test suites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate automated E2E tests from scratch for a feature or bug ticket (Playwright or Cypress per config). Combines requirements analysis with automated test generation. Use when: (1) creating E2E tests for a new feature, (2) generating E2E tests from Jira ticket, (3) building automation suite from requirements, (4) creating a regression test from a bug ticket — orchestrator auto-detects and applies REG- IDs + inline-append behavior.
Generating both manual test cases AND automated E2E tests in a single pipeline. Combines requirements analysis, manual test generation, and E2E code generation. Use when: (1) creating complete test coverage for a feature, (2) generating manual tests and automated E2E together, (3) full QA pipeline from requirements to E2E code, (4) need both QA documentation and automation, (5) generating tests for multiple Jira tickets in batch.
Bootstrap SparQ configuration. Use when: starting SparQ for the first time, re-initializing config, or switching projects.
Convert manual test cases into automated E2E tests. Use when: (1) automating existing manual tests, (2) transforming TMS test cases to E2E tests, (3) automating a manual test suite, (4) converting TestRail or Qase test cases to Playwright E2E via MCP. Accepts test cases as text, file path, TMS reference (TestRail XML, Qase JSON, local JSON), CSV export, or live TMS connection (TestRail MCP, Qase MCP).
Consulting Playwright enterprise best practices — architecture, authentication, assertions, mocking, CI/CD, accessibility, visual regression, and anti-patterns. Providing production-ready patterns and code examples for Playwright test suites. Use when: user asks about Playwright best practices, test architecture, auth patterns, assertion strategies, CI setup, accessibility testing, visual regression, or wants to avoid common Playwright anti-patterns.
Advanced prompt optimization for Claude Code agents. Token budgeting, context engineering, Claude 4.6 specifics, data format selection, and prompt compression. Use when writing or refining skills, CLAUDE.md rules, multi-agent prompts, or debugging verbose/irrelevant output. Complements base formatting rules in CLAUDE.md.
| name | sparq:refactor |
| description | Updating E2E test files after codebase refactoring. Bulk renaming selectors, imports, class names, and string references across test suites. |
| audience | internal |
| input_type | text |
Config, version check, pattern rules, and E2E code generation preamble per claude/rules/skills.md.
--from (required): old name, selector, import path, or string to find--to (required): new name, selector, import path, or string to replace withe2e/ directory per e2e.structure.* config)data-testid values, CSS selectors, import paths, route URLs, class names, variable names--from and --to identical -> exit immediately--from, --to, and scope paths from user input. Validate both flags are present and differ.--from value. Search across: spec files, page objects, step definitions, component objects, fixtures, barrel files. Do NOT search: src/ (application code), node_modules/, config files.LoginForm also matching LoginFormModal). Warn about import path changes that may break barrel re-exports.file:line context. Include near-matches in a separate section. Wait for approval of which replacements to apply.Non-interactive mode: When
preferences.interactiveModeisfalse, checkpoints are auto-approved except when near-matches or barrel re-export warnings are present. See orchestrator Checkpoint Policy.
npx playwright test --list (when e2e.framework is playwright) or npx tsc --noEmit.git checkout -- {files}. Wait for approval.sparq lint {scope-directory}/ to verify renamed references follow code-quality rubrics (locator quality, naming conventions, flaky patterns). Confirms no structural regressions were introduced. Instant, CI-compatible..sparq/validation/refactor-report.md.Delegation: Routes to sparq-test-validator in refactor mode. The orchestrator adds mode: "refactor" and refactorParams: { from, to, scope } to the dispatch. This is an S4 variant, not a new scenario.
{from} found in scoped files" and exitgit checkout -- {files}, list affected files# Modified project files (in-place edits)
{e2e.structure.pages}/{affected}.page.ts
{e2e.structure.specs}/{affected}.spec.ts
{e2e.structure.steps}/{affected}.steps.ts
# Refactor report (metadata)
.sparq/validation/refactor-report.md
Files are edited directly in the project E2E directory. Git is the safety net for review (git diff) and revert (git checkout).
<done_criteria>
sparq.config.json read and --from / --to patterns parsed and validated as non-identical--from value located across scoped E2E files (specs, pages, steps, components, fixtures, barrels) with near-matches flagged separatelye2e.framework (npx playwright test --list for Playwright, npx cypress run --spec {path} or npx tsc --noEmit for Cypress) passed without errors.sparq/validation/refactor-report.md listing replacement count, affected files, and smoke verify result
</done_criteria>.claude/skills/sparq-shared/references/validation-checklist.md.claude/skills/sparq-shared/references/pattern-adherence.md.claude/skills/sparq-shared/references/degradation-strategy.md/sparq:refactor --from "LoginForm" --to "AuthenticationForm" e2e/
-> greps e2e/ for "LoginForm": 14 occurrences across 5 files
-> near-matches: "LoginFormModal" (3 occurrences) -- flagged separately
-> CHECKPOINT: review 14 replacements + 3 near-matches
-> user approves 14 exact matches, skips near-matches
-> applies replacements in login.page.ts, login.spec.ts, auth.steps.ts, loginFixture.ts, pages/index.ts
-> smoke verify: npx playwright test --list -- PASSED
-> CHECKPOINT: all green
-> output: .sparq/validation/refactor-report.md (14 replacements across 5 files)
/sparq:refactor --from "data-testid='submit-btn'" --to "data-testid='form-submit'" e2e/specs/auth/
-> greps e2e/specs/auth/ for "submit-btn": 6 occurrences across 2 files -> user approves
-> applies, smoke verify FAILED: login.page.ts still references old testid
-> CHECKPOINT: 1 failure, offer rollback or expand scope to e2e/pages/