协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
code-history【开发与工程】Trace the git history of specific code — when a function, pattern, or file was added, modified, or removed, and the intent behind each change. Use when the user asks when or why a piece of code changed, wants the evolution of a function, or needs the commit or PR that introduced a behavior. Read-only; not for plain git log or a single line's last aut…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Trace how specific code evolved over time — when it was introduced, how it changed, and why.
git blame for a single line's last authorgit show is sufficient)This skill is read-only. Never modify any files or run write commands.
| 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 |
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.
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:
git log -p --all -S '<pattern>'git log -L :'<function_name>':<file_path> --no-patch --onelinegit log --follow --oneline -- <file_path>For each relevant commit, extract the PR reference:
(#123), Merge pull request #123)gh CLI (if available): gh pr list --search '<commit-sha>' --state all --json number,title,url --limit 1If gh is not installed or fails, rely on commit message parsing only and note it.
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.
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):
Insights (only when directly supported by evidence in the history):