$npx -y skills add dsifry/metaswarm --skill migrateMigrate from npm-installed metaswarm to the marketplace plugin — removes redundant files with safety checks
| 1 | # Migration Skill |
| 2 | |
| 3 | Migrate a project from npm-installed metaswarm (`npx metaswarm init`) to the marketplace plugin. Removes redundant embedded files with a safety protocol that prevents data loss. |
| 4 | |
| 5 | **When to use**: The SessionStart hook detects `.claude/plugins/metaswarm/.claude-plugin/plugin.json` (legacy embedded plugin) and recommends running this skill. |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## IMPORTANT: Safety & Messaging Guidelines |
| 10 | |
| 11 | **The user MUST understand this before any file list is shown:** |
| 12 | |
| 13 | Before presenting any migration preview or file list, ALWAYS lead with this framing: |
| 14 | |
| 15 | > **What this migration does**: The marketplace plugin now provides all the skills, commands, rubrics, and guides that were previously copied into your project directory. This migration simply removes those redundant copies — the originals now live in the plugin itself. |
| 16 | > |
| 17 | > **Nothing is lost**: Your project-specific files (CLAUDE.md, .coverage-thresholds.json, .beads/, bin/, scripts/) are NEVER touched. Only duplicate metaswarm framework files are removed. |
| 18 | > |
| 19 | > **Fully reversible**: All removals are staged with `git rm` (not permanently deleted). Before you commit: |
| 20 | > - Undo everything: `git restore --staged . && git checkout -- .` |
| 21 | > - After committing: `git revert HEAD` |
| 22 | > |
| 23 | > **No commit is made automatically** — you review and commit when you're satisfied. |
| 24 | |
| 25 | **Tone**: Be reassuring, not alarming. Say "cleaning up XX redundant copies" not "deleting XX files". Say "these files now live in the plugin" not "these files will be removed". Frame the migration as housekeeping, not destruction. |
| 26 | |
| 27 | **When showing file counts**: If there are many files (e.g., 40+), explain that the large count is because the old npm installer copied the entire plugin framework into `.claude/plugins/metaswarm/` — that one directory accounts for most of the count, and it's all framework code that's now served directly by the plugin. |
| 28 | |
| 29 | --- |
| 30 | |
| 31 | ## Step 1: Pre-flight Check |
| 32 | |
| 33 | 1. Confirm this skill is running from the marketplace plugin (if this skill loaded, the plugin is active) |
| 34 | 2. Read `.metaswarm/project-profile.json` -- if `"distribution": "plugin"` is already set, inform the user migration was already completed and exit |
| 35 | 3. Verify `.claude/plugins/metaswarm/.claude-plugin/plugin.json` exists -- if not, there is nothing to migrate; inform the user and exit |
| 36 | |
| 37 | If the plugin is not loaded, the user needs to install it first: `/plugin marketplace add dsifry/metaswarm-marketplace` |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ## Step 2: Inventory Legacy Files |
| 42 | |
| 43 | Scan for files installed by `npx metaswarm init` that are now provided by the marketplace plugin. |
| 44 | |
| 45 | **Candidates for removal:** |
| 46 | |
| 47 | | Category | Path pattern | |
| 48 | |---|---| |
| 49 | | Embedded plugin | `.claude/plugins/metaswarm/` (entire directory) | |
| 50 | | Rubrics | `.claude/rubrics/*.md` | |
| 51 | | Guides | `.claude/guides/*.md` | |
| 52 | | Old commands | `.claude/commands/metaswarm-setup.md`, `.claude/commands/metaswarm-update-version.md` | |
| 53 | |
| 54 | **NEVER removed** (project-local files): `CLAUDE.md`, `.coverage-thresholds.json`, `.metaswarm/project-profile.json`, `.beads/`, `bin/`, `scripts/`, `.github/workflows/`, `.claude/commands/` shims. |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## Step 3: Content Verification |
| 59 | |
| 60 | For each removal candidate, verify it is an unmodified metaswarm file using SHA-256 hash comparison. |
| 61 | |
| 62 | **Hash protocol:** |
| 63 | 1. Read file content |
| 64 | 2. Normalize line endings to LF (`\r\n` -> `\n`, `\r` -> `\n`) |
| 65 | 3. Strip trailing whitespace from each line |
| 66 | 4. Strip trailing newlines |
| 67 | 5. Compute SHA-256 of normalized content |
| 68 | 6. Compare against hash of the corresponding file from the marketplace plugin's own directories (rubrics/, guides/, etc.) |
| 69 | |
| 70 | Computing hashes from the plugin's live files ensures the hash list stays current -- no hardcoded hashes that drift. |
| 71 | |
| 72 | **Classification:** |
| 73 | |
| 74 | | Result | Action | |
| 75 | |---|---| |
| 76 | | Hash matches | **Unmodified** -- add to deletion list | |
| 77 | | Hash differs | **User-modified** -- flag for user decision, never auto-delete | |
| 78 | | Not in hash list | **Unknown file** -- skip entirely | |
| 79 | |
| 80 | --- |
| 81 | |
| 82 | ## Step 4: Dry Run Preview |
| 83 | |
| 84 | Display the complete migration plan before any changes. **Lead with the safety framing from the guidelines above**, then show the preview: |
| 85 | |
| 86 | ``` |
| 87 | ## Migration Preview |
| 88 | |
| 89 | These are redundant copies of framework files that are now provided by the plugin. |
| 90 | All removals are staged (not committed) — you can undo everything before committing. |
| 91 | |
| 92 | ### Redundant framework files to clean up (XX files) |
| 93 | These are unmodified copies that the plugin now provides directly: |
| 94 | - .claude/plugins/metaswarm/ (embedded plugin copy — XX files, now served by marketplace plugin) |
| 95 | - .claude/rubrics/<each matching file> (now in plugin's rubrics/) |
| 96 | - .claude/guides/<each matching file> (now in plugin's guides/) |
| 97 | - .claude/commands/metaswarm-setup.md (replaced by plugin command) |
| 98 | - .claude/commands/metaswarm-update-version.md (replaced by plugin command) |
| 99 | |
| 100 | ### Files you've customized (require your decision) |
| 101 | - .claude/rubric |