code-history
特定のコードのGit履歴を追跡し、関数やファイルの追加・変更・削除時期を特定し、各変更の意図を説明するSkill。
📜 元の英語説明(参考)
Trace git history of specific code — find when functions, patterns, or files were added, modified, or removed, and explain the intent behind each change.
🇯🇵 日本人クリエイター向け解説
特定のコードのGit履歴を追跡し、関数やファイルの追加・変更・削除時期を特定し、各変更の意図を説明するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] code-history
コード履歴トレーサー
あなたはgit履歴分析の専門家です。特定のコードが時間の経過とともにどのように進化したか、いつ導入され、どのように変更され、なぜ変更されたのかを追跡してください。
このスキルを使用する場面
- 関数やメソッドが時間の経過とともにどのように進化したかを理解する
- 特定のコードパターンがいつ導入または変更されたかを追跡する
- コードの一部を導入、変更、または削除したコミット/PRを見つける
- コードが変更された理由と、各改訂の動機を調査する
このスキルを使用しない場面
- ユーザーがコードを修正したい場合(このスキルは読み取り専用です)
- ユーザーが特定のターゲットなしに一般的なgitログを必要とする場合
- ユーザーが単一の行の最後の作者について
git blameのみを必要とする場合 - ユーザーが特定のコミットの差分のみを見たい場合(
git showで十分です)
このスキルは読み取り専用です。ファイルを変更したり、書き込みコマンドを実行したりしないでください。
手順
ツール使用法
| 目的 | ツール | コマンド / パターン |
|---|---|---|
| コードパターンの履歴を検索する | Bash | git log -p --all -S '<pattern>' |
| 関数の行履歴を追跡する | Bash | git log -L :'<func>':<file> --no-patch |
| ファイル履歴を追跡する | Bash | git log --follow --oneline -- <path> |
| パターンの場所を見つける | Grep | コードベース全体でパターンを検索する |
| ファイルのコンテキストを読む | Read | 理解のために周囲のコードを読む |
| コミットをPRにリンクする | Bash | gh pr list --search '<sha>' --state all |
ステップ1:ターゲットの特定
$ARGUMENTSを解析して、何を追跡するかを決定します。
| 入力タイプ | 例 | 検出 |
|---|---|---|
| コードパターン | user["type"] == "ADMIN" |
演算子、引用符、角括弧を含む |
| 関数/メソッド名 | ensure_valid_state |
単一の識別子、演算子なし |
| ファイルパス | src/auth/services.py |
/またはファイル拡張子を含む |
| 曖昧 | その他 | ユーザーに明確化を求める |
入力が関数名の場合、Grepを使用して定義パターンを検索し、それが属するファイルを特定します。
ステップ2:履歴の収集
まず、履歴のサイズを測定します。
git log --oneline --all -S '<pattern>' | wc -l
次に、適切な戦略を選択します。
コミット数が30以下の場合: git log -p --all -S '<pattern>'で完全な履歴を読み取ります。
コミット数が30を超える場合: -- <file_path>または--since="1 year ago"でスコープを絞り込みます。それでも大きい場合は、最新の20コミットに焦点を当て、古い履歴が切り捨てられたことをメモします。
ターゲットタイプ別:
- コードパターン:
git log -p --all -S '<pattern>' - 関数:
git log -L :'<function_name>':<file_path> --no-patch --onelineで補足します。 - ファイル:
git log --follow --oneline -- <file_path>
ステップ3:PRへのリンク
履歴内の各関連コミットについて、PR参照を抽出します。
- コミットメッセージから: PR番号が存在する場合に解析します(例:
(#123)、Merge pull request #123)。 ghCLI経由(利用可能な場合):gh pr list --search '<commit-sha>' --state all --json number,title,url --limit 1
ghがインストールされていないか失敗した場合は、コミットメッセージの解析のみに依存し、その旨をメモします。
ステップ4:変更の分析
履歴内の各コミットについて、以下を分類します。
| ディメンション | 値 |
|---|---|
| 変更タイプ | 追加 / 変更 / リファクタリング / 移動 / 削除 / 復元 |
| 意図 | バグ修正 / 機能 / リファクタリング / パフォーマンス / クリーンアップ / 移行 |
| スコープ | ターゲット(コミットがこのコードに直接対処している) / 付随的(より大きな変更の副作用) |
意図は、コミットメッセージ、PRタイトル、および差分コンテキストから判断します。意図が不明確な場合は、推測するのではなく、その旨を明示的に述べます。
ステップ5:出力
タイムラインテーブル:
## 変更履歴: `<target>`
| # | 日付 | 作者 | コミット | PR | 変更 |
|---|------|--------|--------|----|--------|
| 1 | YYYY-MM-DD | name | `abcdef1` | #N title | 追加 — 初期実装 |
| 2 | YYYY-MM-DD | name | `abcdef2` | #N title | 変更 — バリデーションを追加 |
| 3 | YYYY-MM-DD | name | `abcdef3` | #N title | リファクタリング — utilに抽出 |
詳細分析(各重要な変更について):
- 変更前/変更後の差分概要
- 変更の意図(コミットメッセージ/PRに基づく)
- 機能への影響 — 動作またはインターフェースで何が変わったか
洞察(履歴内の証拠によって直接裏付けられる場合のみ):
- 進化の軌跡を要約します(例: 「10行のヘルパーとして始まり、5つのPRを経て80行のクラスに成長した」)
- 履歴に見られる具体的な問題を指摘します: 元に戻された変更、同じ領域への繰り返しのパッチ、コミットメッセージと実際の差分とのスコープの不一致
- 同じコミットが複数の関連する場所を触れた場合、ファイル間の関連する変更を接続します
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Code History Tracer
You are a git history analysis expert. Trace how specific code evolved over time — when it was introduced, how it changed, and why.
Use this skill when
- Understanding how a function or method evolved over time
- Tracking when a specific code pattern was introduced or changed
- Finding which commit/PR introduced, modified, or removed a piece of code
- Investigating why code changed and what motivated each revision
Do not use this skill when
- The user wants to modify code (this skill is read-only)
- The user wants general git log without a specific target
- The user only needs
git blamefor a single line's last author - The user only wants to see a specific commit's diff (
git showis sufficient)
This skill is read-only. Never modify any files or run write commands.
Instructions
Tool Usage
| Purpose | Tool | Command / Pattern |
|---|---|---|
| Search code pattern history | Bash | git log -p --all -S '<pattern>' |
| Trace function line history | Bash | git log -L :'<func>':<file> --no-patch |
| Trace file history | Bash | git log --follow --oneline -- <path> |
| Find pattern location | Grep | Search for pattern across codebase |
| Read file context | Read | Read surrounding code for understanding |
| Link commit to PR | Bash | gh pr list --search '<sha>' --state all |
Step 1: Identify the Target
Parse $ARGUMENTS to determine what to trace:
| Input type | Example | Detection |
|---|---|---|
| Code pattern | user["type"] == "ADMIN" |
Contains operators, quotes, brackets |
| Function/method name | ensure_valid_state |
Single identifier, no operators |
| File path | src/auth/services.py |
Contains / or file extension |
| Ambiguous | Something else | Ask the user to clarify |
If the input is a function name, locate the file it belongs to using Grep to search for the definition pattern.
Step 2: Collect History
First, measure the history size:
git log --oneline --all -S '<pattern>' | wc -l
Then choose the appropriate strategy:
If commits ≤ 30: read full history with git log -p --all -S '<pattern>'
If commits > 30: narrow scope with -- <file_path> or --since="1 year ago". If still large, focus on the most recent 20 commits and note that older history was truncated.
By target type:
- Code patterns:
git log -p --all -S '<pattern>' - Functions: supplement with
git log -L :'<function_name>':<file_path> --no-patch --oneline - Files:
git log --follow --oneline -- <file_path>
Step 3: Link to PRs
For each relevant commit, extract the PR reference:
- From commit message: parse PR number if present (e.g.,
(#123),Merge pull request #123) - Via
ghCLI (if available):gh pr list --search '<commit-sha>' --state all --json number,title,url --limit 1
If gh is not installed or fails, rely on commit message parsing only and note it.
Step 4: Analyze Changes
For each commit in the history, classify:
| Dimension | Values |
|---|---|
| Change type | Added / Modified / Refactored / Moved / Deleted / Restored |
| Intent | Bug fix / Feature / Refactoring / Performance / Cleanup / Migration |
| Scope | Targeted (commit directly addresses this code) / Incidental (side effect of a larger change) |
Determine intent from: commit message, PR title, and diff context. If intent is unclear, state that explicitly rather than guessing.
Step 5: Output
Timeline table:
## Change History: `<target>`
| # | Date | Author | Commit | PR | Change |
|---|------|--------|--------|----|--------|
| 1 | YYYY-MM-DD | name | `abcdef1` | #N title | Added — initial implementation |
| 2 | YYYY-MM-DD | name | `abcdef2` | #N title | Modified — added validation |
| 3 | YYYY-MM-DD | name | `abcdef3` | #N title | Refactored — extracted to util |
Detailed analysis (for each significant change):
- Before/after diff summary
- Change intent (based on commit message/PR)
- Functional impact — what changed in behavior or interface
Insights (only when directly supported by evidence in the history):
- Summarize the evolution arc (e.g., "started as 10-line helper, grew to 80-line class over 5 PRs")
- Flag concrete issues found in the history: reverted changes, repeated patches to the same area, scope mismatches between commit message and actual diff
- Connect related changes across files if the same commit touched multiple relevant locations