All skills
simota avatar

/trail

@e307415
by shingo imotasimota/agent-skills85 stars
15

Investigating git history, analyzing regression root causes, and performing code archaeology. Time-travels through commits to uncover truth. Use for git history investigation.

Use this Skill: https://skilld.dev/gh/simota/agent-skills/trail

This session only. Nothing lands on disk.

referenceframework-templates.md

≈1.4k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Trail Framework Templates

SCOPE Phase Template

INVESTIGATION_SCOPE:
  symptom: "[What's broken - test failure, behavior change, etc.]"
  known_good: "[Last known working state - commit, tag, date, or 'unknown']"
  known_bad: "[Current broken state - usually HEAD]"
  search_type:
    - REGRESSION: "Worked before, broken now"
    - ARCHAEOLOGY: "Why is the code like this?"
    - IMPACT: "What did this change affect?"
  files_of_interest:
    - "[File or directory paths]"
  test_criteria: "[How to verify good/bad state]"

LOCATE Phase Commands

For Regression (git bisect)

# Step 1: Identify good and bad commits
git log --oneline -20  # Recent history
git tag -l             # Check for version tags

# Step 2: Automated bisect (with user confirmation)
git bisect start
git bisect bad HEAD
git bisect good <known_good_commit>
git bisect run <test_command>

# Step 3: Record the result
git bisect log > bisect_log.txt
git bisect reset

For Archaeology (history dive)

# Trace file evolution
git log --follow -p -- <file>

# Find when a line was introduced
git log -S "<search_string>" --oneline

# Understand a specific change
git show <commit> --stat
git show <commit> -- <file>

For Impact Analysis

# What files changed together
git log --name-only --pretty=format: <commit_range> | sort | uniq -c | sort -rn

# Who touched this code
git shortlog -sn -- <file>

# Change frequency
git log --since="6 months ago" --oneline -- <file> | wc -l

TRACE Phase Template (CHANGE_STORY)

CHANGE_STORY:
  breaking_commit:
    sha: "[Full SHA]"
    short: "[Short SHA]"
    date: "[YYYY-MM-DD HH:MM]"
    author: "[Author name]"
    message: "[Commit message]"

  context_before:
    - commit: "[Previous relevant commit]"
      summary: "[What it did]"

  the_change:
    files_modified:
      - path: "[File path]"
        type: "[modified/added/deleted]"
        summary: "[What changed]"
    lines_added: N
    lines_removed: N
    intent: "[Apparent purpose of the change]"

  context_after:
    - commit: "[Following relevant commit]"
      summary: "[What it did]"

  why_it_broke:
    hypothesis: "[Why this change caused the issue]"
    evidence:
      - "[Supporting evidence 1]"
      - "[Supporting evidence 2]"

REPORT Phase Template

## Trail Investigation Report

### Summary
- **Symptom:** [What's broken]
- **Root Cause Commit:** [SHA] by [Author] on [Date]
- **Confidence:** [High/Medium/Low]

### Timeline
[Good State]
    │
    ├── abc1234 (2024-01-10) - Refactored user service
    │
    ├── def5678 (2024-01-11) - Added caching layer  ← BREAKING COMMIT
    │
    ├── ghi9012 (2024-01-12) - Updated tests
    │
[Bad State - Current]

### The Breaking Change
**Commit:** def5678
**Message:** Added caching layer for improved performance
**Author:** developer@example.com

**What Changed:**
- Modified `src/services/user.ts` (+45, -12)
- Added `src/cache/redis.ts` (new file)

**Why It Broke:**
The caching layer introduced a race condition where...

### Evidence
1. Test `user.spec.ts:42` passes on abc1234, fails on def5678
2. The change modified the return type of `getUser()` from...
3. No tests covered the edge case where...

### Recommendations
1. **Quick Fix:** [Immediate mitigation]
2. **Proper Fix:** [Root cause resolution]
3. **Prevention:** [How to avoid in future]

RECOMMEND Phase Table

Finding Type Recommendation Handoff To
Clear regression Revert or fix PR Guardian → Builder
Design flaw Architecture review Atlas
Missing test Add test coverage Radar
Security issue Immediate patch Sentinel → Builder

Bisect Automation Script

#!/bin/bash
# trail_bisect.sh - Automated bisect runner

# Configuration (filled by Trail)
GOOD_COMMIT="$1"
BAD_COMMIT="$2"
TEST_COMMAND="$3"

# Safety checks
if [ -z "$GOOD_COMMIT" ] || [ -z "$BAD_COMMIT" ] || [ -z "$TEST_COMMAND" ]; then
    echo "Usage: trail_bisect.sh <good_commit> <bad_commit> <test_command>"
    exit 1
fi

# Verify commits exist
git rev-parse "$GOOD_COMMIT" > /dev/null 2>&1 || { echo "Good commit not found"; exit 1; }
git rev-parse "$BAD_COMMIT" > /dev/null 2>&1 || { echo "Bad commit not found"; exit 1; }

# Start bisect
echo "Starting bisect..."
echo "Good: $GOOD_COMMIT"
echo "Bad: $BAD_COMMIT"
echo "Test: $TEST_COMMAND"

git bisect start
git bisect bad "$BAD_COMMIT"
git bisect good "$GOOD_COMMIT"

# Run automated bisect
git bisect run sh -c "$TEST_COMMAND"

# Capture result
RESULT_COMMIT=$(git bisect view --oneline | head -1)
echo ""
echo "=== BISECT RESULT ==="
echo "First bad commit: $RESULT_COMMIT"
git show --stat $(echo $RESULT_COMMIT | cut -d' ' -f1)

# Clean up
git bisect reset
echo "Bisect complete. Working directory restored."

Bisect Edge Cases

BISECT_EDGE_CASES:
  flaky_test:
    detection: "Same commit gives different results"
    solution: "Run test 3 times, majority wins"
    script: |
      for i in 1 2 3; do
        $TEST_COMMAND && good=$((good+1)) || bad=$((bad+1))
      done
      [ $good -gt $bad ] && exit 0 || exit 1

  build_failure:
    detection: "Build fails on some commits"
    solution: "Skip unbuildable commits"
    command: "git bisect skip"

  large_range:
    detection: ">1000 commits to search"
    solution: "Use heuristics to narrow first"
    approach:
      - Check recent release tags first
      - Use git log -S to find relevant commits
      - Narrow to specific file changes

  merge_commits:
    detection: "Bisect lands on merge commit"
    solution: "Investigate both parents"
    command: "git log --first-parent"

Source: SKILL.md on GitHub

No alerts13d3 checks · Risk SAFE
  • Gen Agent Trust Hub13d

    The 'trail' skill is a comprehensive toolkit for git history investigation and regression analysis. It provides frameworks for automated bisecting, archaeology, and performance profiling. The skill demonstrates a strong security posture by identifying potential risks like credential exposure in history and arbitrary code execution in test scripts, and it correctly implements user-confirmation boundaries for sensitive operations. All analyzed features are consistent with its primary purpose as a developer productivity tool.

  • Socket13d

    No alerts

  • Snyk13d

    Risk: LOW · No issues

Signed by skilld at e307415. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 2 weeks ago

README badge

README badge for simota/agent-skills/trail