Codebase migrate

From manu14357/zskills · View interactive version

Codebase migrate is an AI agent skill from the GitHub repository manu14357/zskills. Coordinate large-scale codebase migrations and multi-file refactors across hundreds of files. Manage framework upgrades, API renames, and config rewrites using batched PRs, issue tracking, and CI verification.

How to use this skill

Skill file

Codebase Migrate

Use This Skill When

When NOT to Use

Context: Migration Maturity

Undeveloped: Single massive PR, hard to review, hard to debug failures.

Target: Changes batched into 25–50 file chunks, each PR passes CI, easy to revert per-batch.

Optimized: Fully automated pipelines, parallel batch testing, quick rollback, minimal manual intervention.

Core Principle

Large codebase migrations succeed when broken into small, reviewable, verifiable chunks. Batch changes to keep PRs under 10–15 files each, run full tests per batch, and use issue tracking to maintain checkpoint progress.

Prerequisites

curl -fsSL https://composio.dev/install | bash
composio login
composio link github        # PR creation + CI status
composio link linear        # Issue tracking (or jira)

Local Tools Required:

Instructions

Step 1: Define and Scope the Transform

Good Definition Example:

Bad Definition Example:

Scope the Blast Radius:

# Find all files that need changes
rg -l 'jest\.(mock|fn|spyOn)' | wc -l
rg -l 'from "jest"' | sort | wc -l

Document Findings:

| Metric | Value |

|--------|-------|

| Total files to migrate | X |

| Estimated batch size | 25–50 files |

| Number of batches | X / 25 = N |

| Est. review time per PR | 15–30 min |

Step 2: File a Tracking Issue

Create a central tracking issue to monitor progress:

composio execute LINEAR_CREATE_ISSUE -d '{
  "teamId":"TEAM_ID",
  "title":"Migrate: jest → vitest",
  "description":"Batches of ~25 files per PR. Track: batch-1, batch-2, ..."
}'

Document the issue ID (e.g., LIN-482).

Step 3: Plan Batch Strategy

Batch Structure:

| Batch | Files | Scope | Depends On |

|-------|-------|-------|-----------|

| 1 | 1–25 | Core test config + base setup | None |

| 2 | 26–50 | Unit tests in src/ | Batch 1 ✓ |

| 3 | 51–75 | Integration tests | Batch 2 ✓ |

| N | ... | ... | Batch N-1 ✓ |

Create Batch List:

# Extract files matching pattern
BATCH=$(rg -l 'jest\.mock' | grep -v done.list | head -25)
echo "$BATCH" > batch-01.list

Step 4: Execute Transform Per Batch

Workflow:

  1. Checkout feature branch
  2. Run codemod on batch files
  3. Test locally
  4. Commit and push
  5. Create PR with issue reference
  6. Wait for CI green
  7. Merge and move to next batch

Example:

# Start batch branch
git checkout -b migrate/vitest-batch-01

# Run codemod (language-specific)
xargs < batch-01.list jscodeshift -t transforms/jest-to-vitest.ts

# Test changed files
npm test -- --changed

# Commit
git add -A
git commit -m "migrate(test): jest → vitest (batch 1 of 8)"
git push -u origin migrate/vitest-batch-01

Step 5: Create PR and Track Progress

Create PR with automation:

composio execute GITHUB_CREATE_A_PULL_REQUEST -d '{
  "owner":"org","repo":"app",
  "head":"migrate/vitest-batch-01","base":"main",
  "title":"migrate(test): jest → vitest (batch 1 of 8)",
  "body":"Issue: LIN-482. Files: batch-01.list. Codemod: jest-to-vitest.ts"
}'

Update tracking issue:

composio execute LINEAR_CREATE_COMMENT -d '{
  "issueId":"LIN-482",
  "body":"Batch 1 PR opened. Waiting for CI. Tracking spreadsheet: [link]"
}'

Step 6: Verify and Merge

Check CI Status:

composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \
  -d '{"owner":"org","repo":"app","branch":"migrate/vitest-batch-01"}' \
  | jq '.workflow_runs[0].conclusion'

Verify Migration Progress:

# Count remaining jest references
rg 'jest\.(mock|fn|spyOn)' | wc -l

# Should trend toward 0 as batches merge

Merge when green:

Safety Rails

Critical Rules:

| Rule | Reason |

|------|--------|

| One transform per PR | Never mix rename + format change |

| Maintain done.list | Skip already-migrated files in next batch |

| Full test suite on final batch | Catch integration issues |

| Codemod first, hand-edit second | Patch exceptions manually, note in PR |

| Per-batch rollback only | Each PR reverts cleanly |

| Keep batch size <50 files | Reviewable in 20–30 minutes |

| Never force-push merged branches | Maintain clean history |

Quality Checklist

After each batch merges:

Troubleshooting

| Issue | Solution |

|-------|----------|

| Codemod regex too broad | Switch to AST-based tool (ts-morph, ast-grep) |

| Tests pass locally, fail in CI | Check Node/Python version parity (.nvmrc, pyproject.toml) |

| PR too large to review | Reduce batch size from 50→25 files |

| Batch conflicts | Rebase open batch before merging current one |

| Manual edits in multiple batches | Document in PR description for maintainers |

Output

Provide:

  1. Migration Plan Document
  1. Per-Batch Deliverables
  1. Progress Dashboard
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.