This skill should be used when the user asks to "analyze commits", "identify fix patterns", "detect code issues from commits", "git commit analysis", "parse commit history", or needs guidance on analyzing git commits to extract problem patterns and generate postmortem insights.
This skill provides techniques for analyzing git commits to identify bug fix patterns, extract root causes, and detect similar issues in code changes.
Commit analysis transforms raw git history into actionable insights by:
Use a two-stage approach to identify fix-related commits:
Stage 1: Shell-based filtering
Stage 2: AI analysis
Parse conventional commit format: type(scope): subject
Common fix types:
fix: - Bug fixesbugfix: - Explicit bug fixeshotfix: - Urgent production fixespatch: - Small fixesrevert: - Reverting broken changessecurity: - Security fixesExclude types (not fixes):
feat: - New featuresdocs: - Documentationchore: - Maintenance tasksstyle: - Formatting, no logic changerefactor: - Code restructuring, no behavior changetest: - Test additionsbuild: - Build system changesci: - CI/CD configurationperf: - Performance improvements (not fixes)When commit messages don't follow conventional format, look for keywords:
Strong fix indicators:
Context-dependent indicators:
AI analysis needed: When keywords are ambiguous, examine the diff to determine if it's fixing existing broken behavior or adding new functionality.
For each commit identified as potential fix, analyze:
Pattern: New if statements, assertions, or checks added
+ if (index < 0 || index >= array.length) {
+ throw new Error("Index out of bounds");
+ }
return array[index];
Root cause: Missing input validation or boundary check
Pattern: Added null checks, optional chaining, or default values
- const name = user.profile.name;
+ const name = user?.profile?.name ?? "Unknown";
Root cause: Null pointer/undefined access
Pattern: Changed comparison operators, loop conditions, or calculations
- if (count > threshold) {
+ if (count >= threshold) {
Root cause: Logic error, off-by-one error
Pattern: Added mutexes, locks, or atomic operations
+ mutex.lock();
shared_resource.update();
+ mutex.unlock();
Root cause: Race condition or concurrency issue
Pattern: Added try-catch, error checking, or improved error propagation
try {
perform_operation();
+ } catch (SpecificError e) {
+ handle_error(e);
+ throw new UserFriendlyError("Operation failed");
}
Root cause: Missing or inadequate error handling
Pattern: Changed function calls, parameter order, or API contracts
- api.call(data, callback, options);
+ api.call(data, options, callback);
Root cause: API misuse or misunderstanding
Pattern: Added resource cleanup, close operations, or lifecycle management
const file = open(path);
process(file);
+ file.close();
Root cause: Resource leak
Identify recurring patterns across fix commits:
Symptoms:
Pattern signature:
# Check for additions like:
if not validate_input(x):
raise ValueError()
Symptoms:
Pattern signature:
# Check for changes like:
obj?.property # Optional chaining
value ?? default # Nullish coalescing
Symptoms:
Pattern signature:
# Check for additions like:
with lock:
shared_state.update()
Symptoms:
< to <= or vice versa+1 to +0 or vice versaPattern signature:
- for i in range(len(array)):
+ for i in range(len(array) - 1):
Symptoms:
Pattern signature:
# Check for additions like:
try:
operation()
except Exception as e:
handle_error(e)
Merge commits require special handling to identify conflict resolutions.
Indicators of conflict resolution issues:
Use git tools to examine merge conflict resolution:
# Show what was changed in merge compared to parents
git show <merge-commit> --cc
# See which files had conflicts
git show <merge-commit> --name-only
Look for:
To detect if new changes match known problem patterns:
Analyze AST (Abstract Syntax Tree) or code patterns:
Extract keywords from postmortem and compare with new changes:
Combine similarity metrics:
risk_score = (
file_similarity * 0.4 +
pattern_similarity * 0.3 +
keyword_similarity * 0.3
)
if risk_score > 0.8:
risk_level = "critical"
elif risk_score > 0.6:
risk_level = "high"
elif risk_score > 0.4:
risk_level = "medium"
else:
risk_level = "low"
For analyzing many commits (during initialization):
commit-filter.sh to get candidate commitsFor ongoing updates:
Use provided scripts for common operations:
${CLAUDE_PLUGIN_ROOT}/scripts/git-helpers.sh get_commit_info <commit-hash>
Returns JSON with commit metadata.
${CLAUDE_PLUGIN_ROOT}/scripts/git-helpers.sh get_commit_diff <commit-hash> --full
Options: --stat, --name-only, --full
${CLAUDE_PLUGIN_ROOT}/scripts/commit-filter.sh \
--include-keywords "fix,bug,hotfix" \
--since 6.months.ago \
--format json
Returns filtered commit list.
info=$(git-helpers.sh get_commit_info $commit)
diff=$(git-helpers.sh get_commit_diff $commit --full)
git diff # For uncommitted changes
git show <commit> # For specific commit
Not every code change is a fix. Refactoring improves structure without changing behavior.
Fix indicators:
Refactoring indicators:
Don't stop at surface symptom.
Surface: "Added null check" Root cause: "Function assumed input was always non-null because it was only called from one location, but new caller can pass null"
Not every change to authentication code is the same issue.
Be specific: Match specific patterns, not just file paths.
Test additions reveal what edge cases were missed.
Analyze tests: They document the bug better than the fix sometimes.
For detailed pattern detection techniques:
references/pattern-detection.md - Comprehensive pattern libraryreferences/diff-analysis.md - Advanced diff analysis techniquesUtility scripts for commit analysis:
${CLAUDE_PLUGIN_ROOT}/scripts/commit-filter.sh - Universal commit filtering${CLAUDE_PLUGIN_ROOT}/scripts/git-helpers.sh - Git operation utilitiesApply these techniques to transform git history into actionable knowledge for preventing code regression.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer