All skills

Use when bulk-migrating import paths, renaming workspace packages, or reorganizing modules across many files in a monorepo. Uses scripted bulk operations with verification gates and atomic commits. Keywords: migrate imports, rename package, bulk import path change, module reorganization, monorepo refactor. Triggers on "migrate imports" or "rename package".

Use this Skill: https://skilld.dev/gh/acedergren/agentic-tools/migrate

This session only. Nothing lands on disk.

SKILL.md

β‰ˆ92 tokens always: the name and description. β‰ˆ1.3k when used: this file.

Migrate

When to Use

Load this skill when the user request matches the frontmatter description for Migrate.

Orchestrates monorepo migrations: import path changes, package renames, module moves. Uses scripted bulk operations (never file-by-file edits), deduplicates against existing work, verifies types at each step, and commits atomically.

Do NOT load this skill when the change only touches one or two files, the user wants exploratory refactoring, or the package boundary decision is still unresolved.

NEVER

  • Never use the Edit tool file-by-file for bulk migrations β€” use grep | xargs sed instead (10x faster, no missed files).
  • Never start without a deduplication check β€” duplicate migrations cause import conflicts that are hard to debug.
  • Never commit without typecheck β€” silent import breakage is worse than a failed commit.
  • Never skip the residual check β€” 2 files left pointing to the old path cause subtle runtime errors.
  • Never migrate without a manifest β€” you must know the blast radius before touching anything.
  • Never run bulk sed without confirming the manifest count with the user if > 20 files or if packages/ is touched.

Decision Tree

Does the new import path already exist in the codebase?
β”œβ”€β”€ Yes (many files) β†’ Already migrated; verify or skip
β”œβ”€β”€ Yes (some files) β†’ Partial migration; check what's left
└── No β†’ Proceed with full migration

How many files are affected?
β”œβ”€β”€ 1-2 files β†’ Don't use this skill; use Edit tool directly
β”œβ”€β”€ 3-20 files β†’ Proceed with manifest + scripted sed
└── > 20 files β†’ Show manifest, get user confirmation before sed

Does the change touch packages/ (shared across workspaces)?
β”œβ”€β”€ Yes β†’ Get user confirmation before running sed
└── No β†’ Proceed

Scripts

bash scripts/build-manifest.sh @old/pkg/name
bash scripts/replace-imports.sh @old/pkg/name @new/pkg/name /tmp/migration-manifest.txt

Pipeline

Step 1: Deduplication Check

git log --oneline -20
grep -r "<new-import-path>" apps/ packages/ --include="*.ts" --include="*.svelte" -l | head -10

If migration is already complete or partial: report what exists, ask whether to verify/clean up or skip.

Step 2: Build Migration Manifest

grep -rl "<old-import-path>" apps/ packages/ --include="*.ts" --include="*.tsx" --include="*.svelte" > /tmp/migration-manifest.txt
echo "Files to migrate: $(wc -l < /tmp/migration-manifest.txt)"
cat /tmp/migration-manifest.txt

Print summary grouped by workspace. Ask user to confirm before proceeding if > 20 files or packages/ is affected.

Step 3: Scripted Bulk Replacement

grep -rl "@old/pkg" apps/api/ --include="*.ts" | \
  xargs sed -i '' "s|@old/pkg|@new/pkg|g"

grep -rl "@old/pkg" apps/frontend/ --include="*.ts" --include="*.svelte" | \
  xargs sed -i '' "s|@old/pkg|@new/pkg|g"

macOS note: sed -i '' (empty string required for in-place edit without backup). Linux uses sed -i without the empty string.

Step 4: Verification Gate

cd apps/api && npx tsc --noEmit 2>&1 | head -30
cd apps/frontend && npx svelte-check --threshold error 2>&1 | tail -20
cd packages/server && npx tsc --noEmit 2>&1 | head -20

Common causes of type errors after migration:

  • Import path changed but exported symbol name also differs β†’ check the actual export
  • Package not yet built β†’ pnpm --filter <package-name> build
  • Circular dependency introduced β†’ pnpm run check:circular

Step 5: Residual Check

grep -r "<old-import-path>" apps/ packages/ --include="*.ts" --include="*.svelte" -l

Remaining occurrences may be in:

  • Dynamically constructed import strings β†’ manual inspection required
  • Test fixture data (strings, not imports) β†’ may be intentional
  • Comments or docs β†’ update if they describe the API

Step 6: Run Tests

npx vitest run apps/api --reporter=dot
npx vitest run apps/frontend --reporter=dot

If tests fail: check if mock paths still point to the old module path (common missed case in test files).

Step 7: Atomic Commit

git commit -m "refactor(imports): migrate @old/pkg β†’ @new/pkg

Affects N files across apps/api, apps/frontend, packages/server.
All typechecks pass. Full test suite green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>"

Stage only migrated files β€” never git add -A.

Common Migration Patterns

Pattern From To
Package rename @company/old-pkg @company/new-pkg
Path restructure @app/shared/utils @app/core/utils
Index consolidation ./auth/helpers ./auth/index
Framework alias $lib/server/* src/lib/server/*

Arguments

  • $ARGUMENTS: Migration description
    • "@old/pkg/utils β†’ @new/pkg/utils" β€” import path migration
    • "move packages/server/src/auth.ts to packages/server/src/auth/index.ts" β€” file move
    • "rename @company/old-shared β†’ @company/core" β€” package rename
    • If empty: ask for source and target

Source: SKILL.md on GitHub

1 alert5mo5 checks Β· Risk SAFE
  • Gen Agent Trust Hub6mo

    This skill provides a set of scripts and guidelines for performing bulk code migrations within a monorepo, such as renaming packages or updating import paths. It uses standard command-line tools like grep, sed, and perl for file operations and includes verification steps like type-checking and running tests.

  • Socket6mo

    No alerts

  • Snyk6mo

    Risk: LOW Β· No issues

  • Runlayer6mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 Β· 2 sections analyzed

Signed by skilld at 887b0ac. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 27 minutes ago.

Activeupdated yesterday

README badge

README badge for acedergren/agentic-tools/migrate