Community程式設計與開發github.com

ComposioHQ/codebase-migrate

執行大型程式碼庫遷移與多檔案重構。使用 Composio CLI 協調問題追蹤、批次 PR 與 CI 驗證,同時讓代理在本機處理數百個檔案的轉換。

codebase-migrate 是什麼?

這個技能讓 AI 代理能夠協調大規模的程式碼庫遷移任務,例如框架升級、API 更名或設定檔格式轉換。代理會在本機執行轉換腳本(如 jscodeshift、ts-morph 或 ast-grep),而 Composio CLI 則負責管理周邊流程:建立問題、產生批次 Pull Request、監控 CI 驗證狀態。它支援 GitHub 和 Linear/Jira 等工具,讓大型重構可以分批進行、逐一審查,降低一次性大量變更的風險。透過預先定義的精確轉換規則、批次範圍與安全檢查(例如保留已遷移清單、每批次執行完整測試),這個技能確保遷移過程可追蹤、可回退,特別適合需要「對數百個檔案以相同方式修改並分批交付」的場景。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComposioHQ/awesome-codex-skills/tree/main/codebase-migrate

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

程式碼庫遷移 (Codebase Migrate)

協調框架升級、API 更名、設定檔重寫與結構化重構,橫跨數百個檔案。本機編輯由代理驅動;Composio CLI 負責周邊流程:追蹤問題、每批次 PR 與 CI 驗證。

使用時機

  • 框架升級 (React 17 → 19, Node 18 → 22, Django 4 → 5)。
  • 在單一儲存庫中進行 API 更名 (例如 getUserById → users.byId)。
  • 設定檔/格式遷移 (webpack → vite, eslint → biome, jest → vitest)。
  • 任何需要「以相同方式變更 200 個檔案」並以可審查的批次交付的任務。

前置需求

curl -fsSL https://composio.dev/install | bash
composio login
composio link github        # 用於 PR 與 CI 狀態
composio link linear        # 或 jira — 用於遷移追蹤

代理將直接使用的本機工具:git、rg、jscodeshift/ts-morph/comby/ast-grep (依語言選擇),以及你的測試執行器。

規劃階段

  1. 精確定義轉換規則。 不好:「遷移到 vitest。」 好:「將 jest.mock 替換為 vi.mock,將 jest.fn() 換成 vi.fn(),將 jest.config.js 重新命名為 vitest.config.ts 並使用範本 X。」
  2. 評估影響範圍:
    rg -l 'jest\.(mock|fn|spyOn)' | wc -l
    rg -l 'from "jest"' | sort
    
  3. 建立追蹤問題:
    composio execute LINEAR_CREATE_ISSUE -d '{
      "teamId":"TEAM_ID",
      "title":"遷移測試執行器:jest → vitest",
      "description":"每批次約 25 個檔案。每個 PR 綠燈後設為檢查點。"
    }'
    

以可審查的批次執行

循環:選取 N 個檔案 → 轉換 → 測試 → PR → 等待綠燈 → 合併 → 下一批次。

# 批次輔助:第一個 25 個未處理且符合模式的檔案
BATCH=$(rg -l 'jest\.mock' | grep -v done.list | head -25)
echo "$BATCH" > batch.list

代理會對 batch.list 執行 codemod,然後:

git checkout -b migrate/vitest-batch-03
xargs < batch.list codemod-runner   # 例如 jscodeshift / ts-morph / comby
npm test -- --changed
git add -A && git commit -m "migrate(test): jest → vitest (batch 3)"
git push -u origin migrate/vitest-batch-03

composio execute GITHUB_CREATE_A_PULL_REQUEST -d '{
  "owner":"acme","repo":"app",
  "head":"migrate/vitest-batch-03","base":"main",
  "title":"migrate(test): jest → vitest (batch 3)",
  "body":"這是 LIN-482 的一部分。25 個檔案。Codemod:`transforms/jest-to-vitest.ts`。"
}'

然後輪詢 CI 並在綠燈時合併:

composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \
  -d '{"owner":"acme","repo":"app","branch":"migrate/vitest-batch-03"}'

工作流程腳本

scripts/migrate-batch.ts,透過 composio run --file scripts/migrate-batch.ts -- --batch 3 每批次執行一次:

const batch = process.argv[process.argv.indexOf("--batch") + 1];

const pr = await execute("GITHUB_CREATE_A_PULL_REQUEST", {
  owner: "acme", repo: "app",
  head: `migrate/vitest-batch-${batch}`, base: "main",
  title: `migrate(test): jest → vitest (batch ${batch})`,
  body: `這是 LIN-482 的一部分。請參閱 transforms/jest-to-vitest.ts。`
});

await execute("LINEAR_CREATE_COMMENT", {
  issueId: "LIN-482",
  body: `已開啟 PR #${pr.number}:${pr.html_url}`
});

安全機制

  • 每個 PR 只做一種轉換。 絕不將更名與格式變更混在一起。
  • 保留 done.list 記錄已遷移的檔案,讓下一批次跳過它們。
  • 對最後一個批次執行完整測試套件,即使每批次 PR 已執行過 --changed。
  • 先執行 Codemod,再手動編輯。 如果 codemod 遺漏 3 個檔案,手動修補並在 PR 說明中註明。
  • 逐批次回退,而非全域。每個 PR 都應能乾淨地還原。

驗證循環

每次合併後:

rg 'jest\.(mock|fn|spyOn)' | wc -l     # 應趨近於 0
npm test                                # 完整套件
composio execute GITHUB_LIST_WORKFLOW_RUNS_FOR_A_REPOSITORY \
  -d '{"owner":"acme","repo":"app","branch":"main","event":"push"}' \
  | jq '.workflow_runs[0].conclusion'

疑難排解

  • Codemod 正則表達式匹配過多 → 改用基於 AST 的工具 (ast-grep、ts-morph) 進行結構化匹配。
  • 本端測試通過,CI 失敗 → 確保 Node/Python 版本一致;檢查 .nvmrc / pyproject.toml。
  • PR 太大難以審查 → 將批次大小減半;維護者不會審查超過 800 行的 diff。
  • 批次之間發生衝突 → 在合併當前批次前,先 rebase 開啟中的批次;切勿強制推送已合併的批次。

完整 CLI 參考:docs.composio.dev/docs/cli

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComposioHQ/-21risk-automation

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/-2chat-automation

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/ably-automation

Automate Ably tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abstract-automation

Automate Abstract tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abuselpdb-automation

Automate Abuselpdb tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/abyssale-automation

Automate Abyssale tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accelo-automation

Automate Accelo tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/accredible-certificates-automation

Automate Accredible Certificates tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/acculynx-automation

Automate Acculynx tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/active-campaign-automation

Automate ActiveCampaign tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/addresszen-automation

Automate Addresszen tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adobe-automation

Automate Adobe tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adrapid-automation

Automate Adrapid tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/adyntel-automation

Automate Adyntel tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aeroleads-automation

Automate Aeroleads tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/aero-workflow-automation

Automate Aero Workflow tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinda-automation

Automate Affinda tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/affinity-automation

Automate Affinity tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agencyzoom-automation

Automate Agencyzoom tasks via Rube MCP (Composio). Always search tools first for current schemas.

ComposioHQ/agent-deep-links

Build, validate, and troubleshoot deep links for Codex, Cursor, VS Code, Visual Studio, and similar tools. Use when users ask for clickable links (especially in Slack) that open threads, files, folders, or app settings.

相關技能