本文へ移動
cccskills
無料GitHub で公開

trace-mcp-codemod

Use trace-mcp apply_codemod for any bulk mechanical change instead of repeated Edit calls. Activate whenever the same edit pattern would be applied 2+ times, across one file or many.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

trace-mcp — Codemod Workflow

apply_codemod is the correct tool for any repeated mechanical change. Using Edit for the same pattern twice or more is a waste of tokens and is error-prone.

When to Use — HARD RULE

If you are about to make the same kind of change 2 or more times — whether in one file or across many — stop and use apply_codemod. This includes:

  • Adding async/await to a set of functions
  • Updating a function signature everywhere it is called
  • Fixing import paths after a move
  • Adding or removing keywords/decorators
  • Wrapping calls in a logger, try/catch, or feature flag
  • Replacing a deprecated API usage
  • Any regex-replaceable refactor

No exceptions. "It's just three edits" is still a violation — use apply_codemod.

Standard Workflow

1. Preview with dry run (default)

apply_codemod({
  pattern: "oldFunction\\(",
  replacement: "newFunction(",
  file_pattern: "src/**/*.ts",
  dry_run: true        // default
})

Review the preview: matched files, context lines, and replacement correctness. Look for false positives.

2. Narrow scope when needed

Use filter_content to only touch files that also contain a second marker:

apply_codemod({
  pattern:        "extractNodes\\(",
  replacement:    "extractNodes(ctx, ",
  file_pattern:   "src/**/*.ts",
  filter_content: "import.*extractNodes",
  dry_run:        true
})

For patterns that cross line boundaries, enable multiline mode:

apply_codemod({
  pattern:     "function\\s+foo\\([^)]*\\)\\s*\\{",
  replacement: "async function foo() {",
  multiline:   true,
  dry_run:     true
})

3. Apply the change

apply_codemod({ ..., dry_run: false })

If more than 20 files are affected, add confirm_large: true.

4. Reindex and verify

  • register_edit is not needed for codemods — apply_codemod handles reindexing internally.
  • Run the test suite or check_quality_gates with scope: "changed".

Planning Larger Changes

For changes that span packages or require version awareness (e.g. upgrading a dependency), use plan_batch_change first:

plan_batch_change({
  package:      "lodash",
  from_version: "4.17.0",
  to_version:   "5.0.0"
})

This returns an impact report with all affected files and import references. Combine it with apply_codemod for the actual rewrite.

Anti-Patterns to Avoid

  • Using Edit with replace_all for renames — use apply_rename (see trace-mcp-refactoring).
  • Chaining 3–10 Edit calls with the same old_string pattern shape — use apply_codemod.
  • Skipping the dry-run preview — always review matches first.
  • Forgetting confirm_large: true on changes >20 files.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

trace-mcp

無料

Use trace-mcp tools for code navigation, impact analysis, and framework-aware queries instead of Read/Grep/Glob/Bash. Activate whenever the agent needs to explore, understand, or modify a codebase that has trace-mcp indexed.

日本語の概要は準備中です。原文の説明を表示しています。

nikolai-vysotskyi/trace-mcp1902026年10月12日 更新

trace-mcp

無料

Use trace-mcp through bb to search indexed code and recall project decisions with compact context.

日本語の概要は準備中です。原文の説明を表示しています。

nikolai-vysotskyi/trace-mcp1902026年10月12日 更新

Run trace-mcp security, quality-gate, and antipattern checks before committing or opening a PR. Activate when the agent is about to create a commit or pull request in a project indexed by trace-mcp.

日本語の概要は準備中です。原文の説明を表示しています。

nikolai-vysotskyi/trace-mcp1902026年10月12日 更新

Safe refactoring workflow using trace-mcp — assess risk, find candidates, check impact, and rename symbols across all files without missing import sites or cross-file references.

日本語の概要は準備中です。原文の説明を表示しています。

nikolai-vysotskyi/trace-mcp1902026年10月12日 更新

nikolai-vysotskyi のスキルをすべて見る

このスキルの問題を報告する