workflows.fit
Back to exploration
MediumContributed by Community

Parallel Test Refactoring and Visualizer

Fans out subagents to migrate legacy Jest tests to Vitest in parallel, verifying syntax correctness and running tests at each phase.

RefactoringTestingVitest
128 stars890 pulls

Workflow fit

适用场景

  • 边界清晰、可拆分成并行子任务的工程自动化工作。
  • 迁移、重构、性能优化或测试补齐这类能用构建/测试收敛的任务。
  • 希望沉淀为团队可复用 slash command,而不是一次性长提示词。

不适用场景

  • 单文件小改动、没有明确验收标准的开放式需求,或 token 成本不值得并行化的任务。
  • 需要生产凭据、客户数据、付款操作或不可回滚外部副作用的自动执行。
  • 无法用测试、引用、人工复核或对抗审查确认结果质量的任务。

Orchestration Logic

Workflow Graph Visualizer
Generating visual workflow graph...

How to Use Today

1.Install vitest in your project if the migration needs it: pnpm add -D vitest
2.Ask Claude Code to create and run a workflow for this scoped refactor, then review the raw script before approving it.
3.After a successful run, open /workflows, select the run, save it into .claude/workflows/, and reuse it later as /parallel-test-refactoring.

Validation method

Tests or lint

Reviewer pass

Before/after diff

Workflow Script Code

.claude/workflows/parallel-test-refactoring.js
// .claude/workflows/parallel-test-refactoring.js
import { orchestrator, agent } from 'claude';

export async function run(context) {
  // Step 1: Scan codebase for test files
  const files = await context.glob('**/*.test.js');
  console.log(`Found ${files.length} test files to convert.`);
  
  // Step 2: Fan out agents to convert in parallel
  const phases = files.map(file => async () => {
    const subagent = await agent.create({
      instructions: `Convert ${file} from Jest to Vitest. Maintain all logic.`
    });
    await subagent.run();
  });
  
  // Run in parallel with a max concurrency of 5
  await orchestrator.parallel(phases, 5);
  
  // Step 3: Adversarial verify
  const testVerifier = await agent.create({
    instructions: 'Run `pnpm test` and verify that all converted tests pass successfully.'
  });
  await testVerifier.run();
}

Save as Claude Code command

Claude Code currently runs workflows from the interactive session. After a run is saved from /workflows, invoke it as a slash command.

$/parallel-test-refactoring
There is no current `claude workflow run` CLI command.

Specifications

Cost / RiskMedium cost / scoped review
Concurrency MaxRuntime bounded
Verification LoopsAdversarial Checks
Platform SupportClaude Code surfaces

Tools / MCP / skills

Claude Code/workflowsJavaScript workflow runtimeRefactoringTestingVitest

Commercial fit

Free workflow pattern today; suitable for a paid pro bundle once examples, tests, and maintainer support are attached.

Risk level follows workflow complexity and external side effects.

Related recommendations

MCP connectorsAgent skillsRefactoringTestingVitest

Review Before Running

Treat community workflows as patterns. Review the raw script, planned phases, and allowed tools before approving a run in your own project.