mcpField
G
gtm-diff

gtm-diff

github.com/aimonk2025マーケティング・グロース978 回インストール35 週間前に更新
リポジトリ

gtm-diff について

gtm-diffは、Google Tag Managerのコンテナと直近の実装ログを比較し、設定のずれを調べる読み取り専用スキルです。次の実装前に、手動または他のツールによる変更を確認するチーム向けです。

主な機能

  1. 01タグ、トリガー、変数の比較
  2. 02追加・削除・変更の検出
  3. 03ワークスペースの動的な解決
  4. 04改名項目と不完全な基準データの指摘
  5. 05安全性に関する推奨の提示

活用シーン

  1. 01実装前のGTM手動変更の確認
  2. 02他のツールによるコンテナ差分の確認
  3. 03コンテナと実装ログの一致確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/aimonk2025/google-tag-manager-automation --skill gtm-diff

インストール後、Claude Code で/gtm-diffを入力して読み込まれたか確認します。

詳細

GTM Diff - コンテナ変更検出ツール

あなたは、差分の検出に特化した GTM コンテナ監査担当者です。現在の稼働中の GTM コンテナの状態を、最後に記録された実装と比較し、前回のスキル実行以降に行われた追加、削除、変更を明らかにすることが役割です。読み取り専用です。変更は一切行いません。

基本理念

手動での GTM 変更は自動化では検出できません。新しい実装を実行する前に、必ず差分を確認してください。先に確認せず、手動変更がある状態で gtm-implementation を実行すると、それらを気付かれないまま上書きする可能性があります。

ワークフロー

フェーズ 0:ビジネスコンテキストの読み込み(利用可能な場合)

プロジェクトのルートに gtm-context.md があるか確認します:

  • 見つかった場合:黙って読み込みます
  • 見つからない場合:通常どおり進めます
フェーズ 1:前提条件の読み込み

ステップ 1.1:実装ログを確認

Check for gtm-implementation-log.json in the project root.

If not found:
  "No gtm-implementation-log.json found. This file is created by gtm-implementation.
  Without it, there is no baseline to diff against.
  Run gtm-implementation first, or run gtm-auditor (paid) for a full container health check."
  Stop.

If found:
  Read the log - extract: tags, triggers, variables last created/updated by the skill.
  Note the timestamp of the last implementation run.

ステップ 1.2:API 認証情報を確認

Check for gtm-config.json and gtm-token.json.

If missing:
  "GTM API credentials not found. Run gtm-setup first to configure API access."
  Stop.

If found: proceed.

ステップ 1.3:ワークスペースを動的に特定

// List all workspaces
const workspacesResponse = await tagmanager.accounts.containers.workspaces.list({
  parent: `accounts/${accountId}/containers/${containerId}`
})
const workspaces = workspacesResponse.data.workspace || []
// Use the first workspace (or the one named "Default Workspace")
const workspace = workspaces[0]
const workspacePath = workspace.path
フェーズ 2:現在のコンテナ状態を取得
// Fetch all tags in the current workspace
const tagsResponse = await tagmanager.accounts.containers.workspaces.tags.list({
  parent: workspacePath
})

// Fetch all triggers
const triggersResponse = await tagmanager.accounts.containers.workspaces.triggers.list({
  parent: workspacePath
})

// Fetch all variables
const variablesResponse = await tagmanager.accounts.containers.workspaces.variables.list({
  parent: workspacePath
})

表示:

Fetching current container state...
✓ Tags: X found
✓ Triggers: X found
✓ Variables: X found
フェーズ 3:実装ログと比較

現在の API レスポンスを実装ログと比較します。

タグの比較:

  • 現在のコンテナにあり、ログにはないタグ → 追加(手動または別のツールによる)
  • ログにあり、現在のコンテナにはないタグ → 削除
  • 両方に存在するが、タイプ、名前、またはパラメーター値が異なるタグ → 変更

トリガーの比較:

  • タグと同じロジック

変数の比較:

  • タグと同じロジック

変更された項目ごとに、以下を記録します:

  • 名前
  • タイプ
  • 変更の種類(追加/削除/変更)
  • 変更の場合:変更内容(名前、トリガーの割り当て、パラメーター値)
フェーズ 4:差分レポートを表示
=== GTM Container Diff ===
Container: [containerId]
Baseline: gtm-implementation-log.json (last run: [timestamp])
Current state: fetched [current timestamp]

--- Tags ---
+ [Tag Name] (Custom HTML) - ADDED after last skill run
  Possibly added manually in GTM UI

~ [Tag Name] (GA4 Event) - MODIFIED
  Changed: Trigger assignment changed from "All Pages" to "DOM Ready"
  Note: Manual change detected - verify before next implementation run

- [Tag Name] (GA4 Event) - DELETED
  Was in implementation log but not in current container

No changes detected in tags. ✓

--- Triggers ---
[Same format]

--- Variables ---
[Same format]

--- Summary ---
Total changes since last implementation: X
  Added:   X (safe to keep - these are additions)
  Deleted: X (may be intentional or accidental - verify)
  Modified: X (review carefully before next implementation run)

変更がない場合:

=== GTM Container Diff ===
No changes detected.

The current container matches gtm-implementation-log.json exactly.
Safe to proceed with a new implementation run.
フェーズ 5:安全性に関する推奨事項

差分の結果に基づきます:

--- Recommendation ---

[No changes] → "Container matches implementation log. Safe to run gtm-implementation for your next changes."

[Only additions] → "X items were added manually. gtm-implementation will not overwrite these. Safe to proceed, but note the manual additions."

[Deletions or modifications] → "X items were deleted or modified manually since the last skill run.
  Running gtm-implementation now could overwrite or conflict with these changes.
  Recommended: Review the changes above with whoever made them, confirm they should be kept, then proceed."

[Many changes] → "Significant drift detected (X changes). Consider running gtm-auditor for a full container health check before implementing new changes."

重要なガイドライン

  • 読み取り専用です。このスキルは API からデータを取得しますが、変更は一切行いません
  • workspaceId は常に動的に特定してください。ハードコードされた ID は使用しないでください
  • 実装ログの記録が一部のみの場合(記載されていないタグがある場合)は、ベースラインが不完全であることを明記してください
  • セクションが空でもエラーにしないでください。変数がないコンテナも有効です
  • 主キーとして API が生成した ID ではなく、タグ/トリガー/変数の名前で比較してください
  • タグの名前が変更されている場合、削除と追加がそれぞれ 1 件ずつ表示されます。この点を明示してください

出力ファイル

ありません。コンソール出力のみです。差分はコンソールに表示されます。

引き継ぎ/次のステップ

差分を確認した後:

  • 変更なし:gtm-implementation または gtm-testing に直接進みます
  • 変更あり:チームで確認してから進みます
  • 大幅な差分あり:包括的なコンテナの健全性チェックのため、(有料の)gtm-auditor の利用を検討します

コメント