Expert-level Git repository investigation using Hug SCM tools for understanding code evolution, tracking down bugs, analyzing changes, and managing development workflows
This skill equips AI assistants with expert knowledge for investigating Git repositories using Hug SCM's humane interface. Hug transforms complex Git operations into intuitive, safe commands organized by semantic prefixes.
Hug provides four layers of value over raw Git:
hug a stages tracked only; hug aa stages everything)hug back 1 vs git reset --soft HEAD~1discard < wipe < purge < zap < rewindh* = HEAD, w* = working dir, etc.)--with-files = log + file listing in one command-t "3 days ago" instead of date math-- or -iThese features require Python-based data processing, graph algorithms, and statistical analysisβbeyond what Git's plumbing commands can provide.
--json flag on analyze, stats, and churn commandsUse this skill when the user asks to:
| Prefix | Category | Use For |
|---|---|---|
h* |
HEAD Operations | Undoing commits, squashing, reviewing recent changes |
w* |
Working Directory | Discarding changes, cleaning up, managing WIP |
s* |
Status & Staging | Checking state, staging changes, viewing diffs |
b* |
Branching | Creating, switching, listing, deleting branches |
c* |
Commits | Committing, amending, cherry-picking, moving commits |
l* |
Logging | Viewing history, searching commits, analyzing changes |
f* |
File Inspection | Blame, contributors, file history, churn analysis |
t* |
Tagging | Creating, managing, querying tags |
analyze |
Advanced Analysis | Co-changes, activity patterns, dependencies, expertise |
stats |
Statistics | File/author/branch metrics and insights |
Start every investigation with a status check:
# Quick overview
hug s
# Detailed status with untracked files
hug sla
# See what's staged vs unstaged
hug ss # staged only
hug su # unstaged only
hug sw # working dir summary
When you need to know "what happened recently":
# See files changed in last N commits
hug h files 5
# See files changed in last week (temporal!)
hug h files -t "1 week ago"
# See what hasn't been pushed yet
hug lol # log outgoing long
Understanding what changed:
# Show last commit with stats
hug sh
# Show last commit with full diff
hug shp
# Show files changed in specific commit
hug shc a1b2c3d
hug shc -n <commit-hash> # files changed, paths only
Three search tools for different needs:
# Simple message search
hug lf "keyword"
hug lf "fix bug" --with-files # Show files changed in each match
# HIDDEN FEATURE: Regex patterns work! (uses git --grep internally)
hug lf "fix\|bug\|resolve" -i --all # OR patterns (case-insensitive)
hug lf "feat.*auth" --all # Regex matching
hug lf "^Merge" --all # Pattern matching
Pro tip: lf supports extended regex via git --grep, though not advertised!
# Exact string matching in code diffs (Git's -S pickaxe)
hug lc "getUserById" # Find when this function changed
hug lc "import React" --with-files # Show files with React imports
# Regex matching in code diffs (Git's -G flag)
hug lcr "function.*User" # Function definitions
hug lcr "class \w+" -i # Case-insensitive class declarations
hug lcr "TODO|FIXME" --all # OR patterns in code
hug lcr "^import.*from" -p # Import statements with patches
Decision tree:
lf (supports regex via git --grep!)lc (faster, literal matching)lcr (explicit regex for complex patterns)Examples:
# Find commits mentioning multiple related terms
hug lf "refactor\|restructure\|reorganize" -i --all
# Find when specific function was modified
hug lc "getUserById" --with-files
# Find any import statement changes
hug lcr "^import.*from" --all
# Find file history
hug llf <file>
When debugging or understanding file evolution:
# Find when file was created (hidden gem!)
hug fborn <file>
# See who wrote each line
hug fblame <file>
# Analyze file churn (how frequently it changes)
hug fblame --churn <file>
hug fblame --churn --since="3 months ago" <file>
# Short blame (author + line only)
hug fb <file>
# List all contributors to a file
hug fcon <file>
# Count commits per author for a file
hug fa <file>
# Full file history
hug llf <file>
Powerful feature: Most commands support time-based queries:
# What changed in last 3 days?
hug h files -t "3 days ago"
# Commits from last week
hug l --since="1 week ago"
# Date range
hug ld "2024-01-01" "2024-01-31"
All destructive HEAD operations create automatic backups:
# These commands auto-create hug-backup-* branches
hug h back
hug h rollback
hug h rewind
hug h squash
# List backup branches
hug bl | grep backup
# Restore from backup if needed
hug b <backup-branch-name>
ALWAYS preview destructive operations first:
# Preview before executing
hug w zap-all --dry-run
hug h rollback --dry-run
hug w purge --dry-run
# Then execute with -f to skip confirmation
hug w zap-all -f # after reviewing dry-run output
Most commands support interactive file/branch/commit selection:
# Use -- for interactive selection with Gum
hug lc "import" -- # select file to search in
hug w discard -- # select files to discard
hug bdel -- # select branch to delete
# --browse-root for full repo scope (default: current dir)
hug lc "import" --browse-root
User reports: "Feature X broke recently"
Investigation flow:
# 1. Find file/files involved
hug lf "feature X" # search commit messages
hug lc "featureXFunction" # search code changes
# 2. Check when file last changed
hug fborn <file> # when was it created?
hug h steps <file> # how many commits since change?
# 3. View file history
hug llf <file> # see all commits
# 4. Examine suspect commits
hug shp <commit-hash> # full diff
hug shc <commit-hash> # files changed
hug shc -n <commit-hash> # files changed, paths only
# 5. Check related changes
hug h files <commit-hash> # what else changed with it?
User asks: "What am I about to push?"
# See local-only commits
hug lol
# Or shorter version
hug lo
# See files in local commits
hug h files -u # -u for upstream comparison
# Review before pushing
hug l @{u}..HEAD # commits ahead of upstream
User asks: "Which files change most often?"
# Recent activity
hug h files 50 # files in last 50 commits
# By time period
hug h files -t "1 month ago"
# For specific directory
cd src/
hug l --since="1 month ago" -- .
User asks: "Who works on this code?"
# Contributors to specific file
hug fcon <file>
# Commit counts per author
hug fa <file>
# Commits by specific author
hug lau "Author Name"
# Date range for author
hug lau "Author Name" --since="1 month ago"
# Current branch status
hug b
# List all branches with tracking info
hug bla
# Which branches contain a commit?
hug bwc <commit>
# Which branches point at HEAD?
hug bwp
# Which branches are merged?
hug bwm
# Which branches are NOT merged?
hug bwnm
# Tags/branches containing commit
hug bwc <commit> # branches which contain
hug twc <commit> # tags which contain
# Tags/branches pointing at commit
hug bwp <commit> # branches which point
hug twp <commit> # tags which point
# Find all commits in feature branch
hug l main..feature-branch
# See what would merge
hug m feature-branch --dry-run
# Compare branches
hug l branch1..branch2
Hug preserves Git aliases, so you can still use:
# These work through Hug
hug l --all # all branches log
hug ll --all # detailed all branches
hug la # shortcut for above
# Exact time specifications
hug h files -t "2024-01-15 14:30"
hug h files -t "yesterday"
hug h files -t "3 hours ago"
# Relative specifications work
hug ld "last monday" "friday"
These commands perform statistical analysis and graph algorithms impossible with raw Git alone. They require Python-based data processing and export to JSON for automation.
Problem: Which files change together? Reveals architectural coupling.
# Analyze files related to one target file
hug analyze co-changes src/problematic.ts
# Strong repo-wide coupling only (β₯50% correlation)
hug analyze co-changes --all --threshold 0.50
# Top 10 pairs
hug analyze co-changes --all --top 10
# Machine-readable export
hug analyze co-changes --all --json
Algorithm: Builds co-occurrence matrix from commit history, calculates Jaccard-like correlation coefficients.
Use cases:
Problem: Who owns this code? Who should review changes?
# Find experts for a file (recency-weighted)
hug analyze expert src/auth.js
# Find author's expertise areas
hug analyze expert --author "Alice"
# Custom recency decay (default: 180 days)
hug analyze expert src/auth.js --decay 90
# JSON export for dashboards
hug analyze expert src/auth.js --json
Algorithm: Recency-weighted commit analysis with exponential decay formula: weight = commits Γ exp(-days_ago / decay_days)
Output categories:
Problem: When does the team work? Are there sustainability issues?
# Hourly histogram
hug analyze activity --by-hour
# Day-of-week patterns
hug analyze activity --by-day
# Per-author breakdowns
hug analyze activity --by-author --by-hour
# Time-filtered analysis
hug analyze activity --since="3 months ago"
# Export for dashboards
hug analyze activity --json
Algorithm: Temporal aggregation with statistical summaries. Flags:
Insights:
Problem: Which commits are related through file overlap?
# Find commits related to specific commit
hug analyze deps abc1234
# Two-level dependency traversal
hug analyze deps abc1234 --depth 2
# Require strong coupling (3+ files overlap)
hug analyze deps abc1234 --threshold 3
# Repository-wide coupling analysis
hug analyze deps --all --threshold 5
# Export formats
hug analyze deps abc1234 --format graph # ASCII tree (default)
hug analyze deps abc1234 --format text # Simple list
hug analyze deps abc1234 --format json # Machine-readable
Algorithm: File-to-commits indexing + graph traversal (BFS) based on file overlap.
Use cases:
Repository-wide insights:
# File-level statistics
hug stats file src/app.js
hug stats file src/app.js --json # Export
# Author contributions
hug stats author "Alice"
hug stats author "Alice" --json
# Branch metrics
hug stats branch feature/auth
hug stats branch feature/auth --json
Metrics include:
Problem: Which code changes most frequently?
# Line-level change frequency
hug fblame --churn src/auth.js
# Time-filtered churn
hug fblame --churn --since="3 months ago" src/auth.js
# JSON export for hotspot visualization
hug fblame --churn --json src/auth.js
Algorithm: Counts modifications per line over time using git log -L.
Identifies:
Git provides data, Hug provides analysis:
| Git Capability | Hug Analysis |
|---|---|
git log --name-only |
β Co-change correlation (statistical) |
git log --follow |
β Ownership calculation (recency-weighted) |
git diff-tree |
β Dependency graphs (graph traversal) |
git log --format=%ai |
β Activity patterns (temporal histograms) |
git log -L |
β Churn analysis (frequency aggregation) |
These require:
All computational features support --json or --format=json:
# Build custom dashboards
hug analyze co-changes --all --json > coupling.json
hug analyze expert --author "Alice" --json > alice-expertise.json
hug analyze activity --json > team-health.json
hug analyze deps --all --format json > commit-graph.json
hug stats file src/app.js --json > file-metrics.json
Enable:
Hug doesn't cover every Git operation. Use raw Git for:
-f or HUG_FORCE=true for automationThese are always safe - no confirmations needed:
l* logging commandsf* file inspection commandss* status commandsh files and h steps commandsbl, bla, blr)When using the Hug SCM MCP server, these tools are available:
hug_status β hug s or hug slahug_log β hug l with filtershug_h_files β hug h files (supports temporal, upstream)hug_h_steps β hug h steps (for precise navigation)hug_show_diff β hug ss, hug su, hug swhug_branch_list β hug bl, hug blaThe MCP server exposes read-only operations for safe AI investigation.
For detailed command documentation:
For workflow examples:
# Investigation Starters
hug s # what's changed?
hug sla # full status
hug h files 10 # recent file changes
hug lol # what will push?
# Search Operations
hug lf "keyword" # search messages
hug lf "keyword" --with-files # search messages, show files
hug lc "code" # search code changes
hug lc "code" --with-files # search code changes, show files
hug lcr "regex" # regex code search
hug llf <file> # file history
# Deep Inspection
hug fborn <file> # when created
hug fblame <file> # who wrote what
hug fblame --churn <file> # churn analysis
hug fcon <file> # contributors
hug h steps <file> # commits since change
# Computational Analysis (with JSON export!)
hug analyze co-changes <file> # files related to a target file
hug analyze co-changes --all --json # repository-wide coupling data export
hug analyze expert <file> # code ownership
hug analyze expert <file> --json # ownership data export
hug analyze expert --author "Alice" # expertise areas
hug analyze activity --by-hour # team patterns
hug analyze activity --json # activity data export
hug analyze deps <commit> # commit dependencies
hug analyze deps --all --format json # dependency graph export
# Statistics (with JSON export!)
hug stats file <file> --json # file metrics
hug stats author "Alice" --json # author data
hug stats branch feature/x --json # branch metrics
hug fblame --churn --json <file> # hotspot data
# Time-Based
hug h files -t "3 days ago" # recent changes
hug ld "monday" "friday" # date range
hug lau "Author" --since="1 month ago"
# Branch Queries
hug bwc <commit> # which branches contain?
hug bwm # which merged?
hug bwnm # which not merged?
hug s or hug sla before any investigation-t "3 days ago")hug fborn is faster than manual log walking--dry-run before suggesting destructive operations-- for Gum selection when multiple optionsFor specific workflows, see the guide files: