refactor-swarm

Parallelize file-local refactors across many files using concurrent per-file agents.

2|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/nseng-ai/ns --skill refactor-swarm-nseng-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-swarm
Source: https://github.com/nseng-ai/ns/tree/main/skills/internal/agent-engineering/refactor-swarm
Command: npx skills add https://github.com/nseng-ai/ns --skill refactor-swarm-nseng-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Applying the same refactor across dozens of files sequentially is slow and error-prone, while pure codemods cannot handle natural-language references in comments, docstrings, and log messages. This skill coordinates a swarm of cheap, fast per-file agents so each file is refactored independently with light judgment, in two controlled waves. ## Core Features & Use Cases - Two-wave parallel execution: Launch one agent per file on the harness's cheapest fast model tier, source files first, then test files, with a checkpoint between waves. - Structured agent prompt template: Each agent receives a self-contained brief with explicit boundary constraints (what not to touch) and authorized judgment (what it may decide per file). - Verification protocol: Grep for leftover identifiers after literal renames, and run the test suite, type checker, and linter for judgment-involved refactors. - Use Case: Rename a parameter across 20 source and test files, including docstring and log-message references, by dispatching one agent per file and verifying no stale occurrences remain. ## Quick Start Ask the agent to apply the same refactor across all matching files using the refactor-swarm pattern, with one cheap-model agent per file in source and test waves.

Frequently Asked Questions about refactor-swarm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I apply the same refactor across many files in parallel?

Grep for all files matching the refactor anchor, split them into source and test groups, then launch one Task agent per file with a shared brief. Run the source wave first, review results, then launch the test wave and verify with grep and the test suite.

When should I use an agent swarm instead of a codemod tool?

Prefer codemods like libcst or jscodeshift for purely syntactic refactors. Use the swarm when natural-language references in docstrings, comments, or log messages must move with the code, or when light per-file judgment is required.

What is the minimum number of files for a parallel refactor swarm?

The skill recommends 5 or more files receiving the same refactor shape. Below 5 files, sequential edits are simpler and carry less orchestration overhead than dispatching per-file agents.

When should I not use a per-file agent swarm for refactoring?

Avoid it for cross-file cascading refactors where edits in one file determine changes in another, for decisions that must be consistent across files like picking a single new name, and for refactors needing deep whole-program type or behavior reasoning.

How do I verify a swarm refactor completed correctly?

For literal renames, grep for the old identifier and confirm only intentional exceptions remain. For judgment-involved refactors, run the test suite, type checker, and linter, and read a sample of diffs for high-stakes changes.