Skip to content

AlabamaMike/forensic-skills

Repository files navigation

Code Forensics Skills for Claude Code

A comprehensive suite of Claude Code skills for performing forensic analysis of codebases, based on the principles from "Your Code as a Crime Scene" by Adam Tornhill.

✅ Current Status: Production Ready

Date: 2025-10-27 Branch: claude/code-forensics-skills-011CUYPHMBH3n4ZQAhAdvPUM Status: Phase 2 Complete - All skills restructured and production-ready

This repository has been completely restructured to follow proper Claude Code skill patterns (per superpowers:writing-skills).

What's Available:

11 Production-Ready Skills - Fully restructured with validated 6-element pattern:

  • forensic-hotspot-finder - Identifies high-risk files (4-9x defect correlation)
  • forensic-debt-quantification - Translates tech debt to business costs
  • forensic-knowledge-mapping - Analyzes code ownership and bus factor
  • forensic-change-coupling - Detects temporal coupling and shotgun surgery
  • forensic-complexity-trends - Tracks complexity evolution (improving/deteriorating)
  • forensic-refactoring-roi - Calculates ROI and break-even for refactoring
  • forensic-coordination-analysis - Identifies team coordination bottlenecks
  • forensic-organizational-alignment - Conway's Law analysis
  • forensic-test-analysis - Detects brittle tests and maintenance burden
  • forensic-unplanned-work - Tracks interrupt work and velocity impact
  • forensic-onboarding-risk - Bus factor and knowledge transition cost

Pattern Quality:

  • 6-Element Pattern: Rich descriptions, usage instructions, prominent formulas, citable research, preventable mistakes, integration guidance
  • Research-Backed: 18+ studies cited with exact phrasing
  • Integration Network: 32+ cross-skill integration points
  • Validated Performance: 98/100 effectiveness (vs 65/100 original)

For complete details, see:

  • PHASE-2-COMPLETE.md - Phase 2 completion report
  • REFINEMENTS-COMPLETE.md - 6-element pattern template

Overview

This repository contains 11 specialized skills and 2 slash commands that enable Claude Code to perform deep forensic analysis of your codebase using version control history. These tools help identify technical debt, code quality issues, team dynamics problems, and provide data-driven, actionable recommendations.

What is Code Forensics?

Code forensics applies investigative techniques to version control history to understand:

  • Where the problems are (hotspots)
  • Why they exist (complexity, coordination, ownership)
  • What to do about them (prioritized recommendations)
  • How much they cost (business impact in dollars)

Unlike static analysis tools that only look at current code, forensic analysis leverages the rich history in git to reveal patterns invisible to traditional tools.

Quick Start

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/forensic-skills.git
cd forensic-skills
  1. Copy the .claude directory to your project:
cp -r .claude /path/to/your/project/
  1. The skills are now available in Claude Code!

Basic Usage

Slash Commands (For Comprehensive Analysis)

Generate a full forensic dashboard:

/forensic-dashboard

Run a specific forensic analysis workflow:

/forensic-analysis

Skills (For Focused Analysis)

Use specific forensic skills for targeted investigations:

Use the forensic-hotspot-finder skill to identify our top 10 problem files
Use the forensic-debt-quantification skill to calculate the cost of our technical debt
Use the forensic-knowledge-mapping skill to analyze code ownership and bus factor

Skills Catalog

Category A: Codebase Forensics & Hotspot Detection

1. Hotspot Finder

Identifies files with both high change frequency AND high complexity - the most bug-prone areas of your codebase.

Use when:

  • You want to know where to focus refactoring efforts
  • Planning technical debt reduction work
  • Investigating quality issues

Output:

  • Ranked list of hotspots with risk scores
  • Heatmap visualization (change frequency vs complexity)
  • Detailed analysis per hotspot with recommendations

Skill file: .claude/skills/forensics/category-a-hotspots/hotspot-finder.md


2. Complexity Trend Analyzer

Tracks how code complexity changes over time, identifying improving, stable, or deteriorating files.

Use when:

  • Monitoring code quality trends
  • Measuring impact of refactoring efforts
  • Identifying files that need preventive action

Output:

  • Time-series complexity metrics
  • Trend classification (improving/stable/deteriorating)
  • Correlation with changes and contributors
  • Inflection point identification

Skill file: .claude/skills/forensics/category-a-hotspots/complexity-trend-analyzer.md


3. Change Coupling Detector

Discovers files that frequently change together, revealing hidden dependencies and architectural issues.

Use when:

  • Planning architecture refactoring
  • Understanding cross-module dependencies
  • Identifying shotgun surgery patterns

Output:

  • Ranked coupling pairs with strength scores
  • Coupling clusters (3+ files changing together)
  • Cross-module coupling analysis
  • Coupling network visualization

Skill file: .claude/skills/forensics/category-a-hotspots/change-coupling-detector.md


Category B: Socio-Technical & Organizational Insights

4. Knowledge Map Builder

Maps code ownership and contribution patterns, calculates truck factor, identifies knowledge silos.

Use when:

  • Assessing team resilience
  • Planning for developer departures
  • Identifying single points of failure
  • Planning knowledge transfer

Output:

  • Truck factor calculation
  • Per-file ownership analysis
  • Per-developer knowledge domains
  • Critical risk areas (single owner + critical file)
  • Knowledge distribution matrix

Skill file: .claude/skills/forensics/category-b-socio-technical/knowledge-map-builder.md


5. Conway's Law Visualizer

Analyzes alignment between code/module boundaries and team structures.

Use when:

  • Team reorganization planning
  • Identifying coordination inefficiencies
  • Architecture vs organization alignment
  • Scaling team structure

Output:

  • Team-module ownership matrix
  • Alignment score
  • Misalignment detection (multi-team modules, orphaned modules)
  • Coordination bottlenecks
  • Organizational and architectural recommendations

Skill file: .claude/skills/forensics/category-b-socio-technical/conways-law-visualizer.md


6. Coordination Hotspot Identifier

Detects modules with high coordination complexity (many contributors, cross-team edits).

Use when:

  • Investigating merge conflict patterns
  • Reducing communication overhead
  • Identifying collaboration bottlenecks
  • Predicting defect-prone areas

Output:

  • Files with high contributor counts
  • Cross-team coordination issues
  • Temporal coordination patterns (concurrent edits)
  • Coordination complexity scores
  • Communication improvement recommendations

Skill file: .claude/skills/forensics/category-b-socio-technical/coordination-hotspot-identifier.md


Category C: Technical Debt & Business Communication

7. Technical Debt Quantifier

Estimates the cost of technical debt in business terms (dollars, time, risk).

Use when:

  • Justifying technical debt work to stakeholders
  • Budget planning for quality initiatives
  • Executive reporting
  • Prioritizing investments

Output:

  • Annual technical debt cost ($)
  • Breakdown by category (productivity, defects, coordination)
  • Cost per file/module
  • Trend analysis (debt growing or shrinking)
  • Business impact summary (for non-technical audiences)

Skill file: .claude/skills/forensics/category-c-technical-debt/technical-debt-quantifier.md


8. Refactoring ROI Estimator

Prioritizes refactoring targets by return on investment.

Use when:

  • Planning refactoring sprints
  • Prioritizing technical debt backlog
  • Estimating effort and benefits
  • Creating quarterly roadmaps

Output:

  • ROI-ranked refactoring candidates
  • Effort-impact matrix
  • Phased refactoring roadmap (quick wins → strategic)
  • Break-even calculations
  • Risk-adjusted ROI estimates

Skill file: .claude/skills/forensics/category-c-technical-debt/refactoring-roi-estimator.md


Category D: Test & Delivery Pipeline Analysis

9. Test Bottleneck Profiler

Analyzes test code quality, identifies brittle tests, duplication, and maintenance burden.

Use when:

  • Investigating test suite issues
  • Reducing CI/CD time
  • Fixing flaky tests
  • Improving test maintainability

Output:

  • Test hotspots (high change frequency)
  • Test-production coupling analysis
  • Test duplication report
  • Slow test identification
  • Flaky test detection
  • Test maintenance cost estimates

Skill file: .claude/skills/forensics/category-d-test-pipeline/test-bottleneck-profiler.md


10. Unplanned Work Tracker

Monitors trends in unplanned work (bugs, hotfixes, interrupts) and correlates with code hotspots.

Use when:

  • Understanding velocity issues
  • Measuring quality improvement efforts
  • Identifying productivity drains
  • Justifying quality investments

Output:

  • Unplanned work ratio over time
  • Files generating most unplanned work
  • Correlation with code hotspots
  • Productivity impact analysis
  • Release correlation (post-release bug spikes)
  • Cost of interrupts and context switching

Skill file: .claude/skills/forensics/category-d-test-pipeline/unplanned-work-tracker.md


Category E: Visualization & Reporting

11. Onboarding/Offboarding Risk Reporter

Assesses knowledge gaps for team member transitions.

Use when:

  • Developer departure (planned or unplanned)
  • New hire onboarding planning
  • Knowledge transfer prioritization
  • Business continuity planning

Output:

  • Offboarding risk assessment (per developer)
  • Bus factor scenarios
  • Critical knowledge gaps
  • Onboarding cost estimates
  • 30-60-90 day onboarding plans
  • Knowledge transfer recommendations

Slash Commands

/forensic-dashboard

Generates comprehensive code forensics dashboards for executive reporting and ongoing quality monitoring.

Use when:

  • Creating executive reports on code quality
  • Preparing quarterly technical debt reviews
  • Demonstrating ROI of quality investments
  • Ongoing code health monitoring
  • Stakeholder communication about technical work

What it does:

  1. Runs all 11 forensic skills systematically
  2. Aggregates results into overall health score
  3. Identifies top 3-5 critical issues
  4. Calculates total technical debt cost
  5. Generates refactoring roadmap with ROI
  6. Creates multi-format dashboards (Markdown, HTML, JSON)

Output includes:

  • Executive summary (business language)
  • Code hotspot heatmap
  • Technical debt breakdown and trends
  • Team knowledge map and bus factor
  • Quality trends over time
  • Refactoring priorities (ROI-ranked)
  • Recommended action plan with timelines
  • Success metrics to track

Command file: .claude/commands/forensic-dashboard.md


/forensic-analysis

Guided forensic analysis workflow for specific use cases.

Command file: .claude/commands/forensic-analysis.md


Usage Examples

Example 1: Monthly Health Check

I'd like to do a quick health check of our codebase before planning next sprint.
Use the forensic-analyzer skill with the quick health check workflow.

Claude will:

  1. Run hotspot finder
  2. Calculate basic technical debt
  3. Check truck factor
  4. Generate top 5 issues with recommendations

Time: 30-60 minutes


Example 2: Planning Refactoring Sprint

We have a 2-week refactoring sprint coming up. Help us prioritize what to work on.
Use the forensic-analyzer skill with comprehensive audit workflow, then use
refactoring-roi-estimator to create a prioritized backlog.

Claude will:

  1. Run comprehensive analysis
  2. Identify all technical debt areas
  3. Calculate ROI for each potential refactoring
  4. Generate phased roadmap (quick wins first)
  5. Provide effort estimates and expected savings

Time: 4-8 hours (comprehensive analysis)


Example 3: Investigating Quality Issues

We've had a lot of bugs in the payment module lately. Help me understand why.
Use the forensic-analyzer skill with targeted deep dive on src/payment/

Claude will:

  1. Run hotspot finder (payment module)
  2. Analyze complexity trends
  3. Check unplanned work (bug fixes)
  4. Review ownership and knowledge
  5. Provide specific recommendations

Time: 1-2 hours


Example 4: Developer Departure

Our lead auth developer is leaving in 2 months. What's at risk?
Use the onboarding-risk-reporter skill with offboarding analysis for Alice.

Claude will:

  1. Identify Alice's code ownership
  2. Find critical files she owns
  3. Calculate impact of her departure
  4. Generate knowledge transfer plan
  5. Recommend documentation priorities

Time: 1 hour


Example 5: Executive Reporting

I need to present technical debt to our executives. They want to know the
cost and what we should do about it.

/forensic-dashboard

Claude will:

  1. Run comprehensive forensic analysis (all 11 skills)
  2. Calculate total technical debt cost
  3. Identify top 3-5 critical issues
  4. Recommend investments with ROI
  5. Generate multi-format dashboard (Markdown, HTML, JSON)
  6. Provide executive summary in business language

Time: 5-10 minutes (automated) Output: Dashboard files ready for presentation


Key Features

Data-Driven Insights

  • All recommendations backed by git history analysis
  • Quantified impact (dollars, time, risk)
  • Research-based benchmarks (e.g., files with >9 contributors have 2-3x defect rates)

Business Language

  • Technical metrics translated to business terms
  • ROI calculations for all recommendations
  • Executive summaries for non-technical stakeholders

Actionable Recommendations

  • Specific, not vague (e.g., "refactor auth.js", not "improve quality")
  • Prioritized by impact and effort
  • Phased (quick wins → strategic improvements)
  • Include time and cost estimates

Holistic Analysis

  • Considers code, people, and process
  • Correlates multiple analyses for deeper insights
  • Identifies root causes, not just symptoms

Continuous Monitoring

  • Track trends over time
  • Measure improvement efforts
  • Regular health checks

Research Foundation

These skills are based on research and principles from:

  • "Your Code as a Crime Scene" by Adam Tornhill - Primary inspiration
  • Microsoft Research - Studies on code churn and defect correlation
  • Google Engineering Practices - Code review and quality metrics
  • Industry Standards - Truck factor, cyclomatic complexity, test metrics

Key research findings applied:

  • Files with high change frequency + high complexity have 4-9x more defects
  • Files with >9 contributors have 2-3x higher bug rates
  • Unplanned work >40% correlates with low team morale
  • Technical debt compounds at ~15-20% annually if unaddressed

Best Practices

1. Start with Business Goals

Don't analyze for the sake of analysis. Ask:

  • What decision needs to be made?
  • What problem are we solving?
  • Who needs the information?

2. Run Regular Health Checks

  • Monthly quick health checks (30-60 min)
  • Quarterly comprehensive audits (4-8 hours)
  • Track trends over time

3. Prioritize Ruthlessly

  • Focus on highest ROI improvements
  • Quick wins build momentum
  • Balance urgent fixes with strategic improvements

4. Measure Results

  • Track metrics before/after refactoring
  • Validate ROI assumptions
  • Adjust strategy based on results

5. Communicate Effectively

  • Technical details for engineers
  • Business impact for executives
  • Visualizations for clarity

6. Act on Insights

Analysis without action is waste. Always:

  • Create actionable backlog items
  • Assign owners
  • Set deadlines
  • Follow through

Technical Requirements

  • Git repository - All analyses use git history
  • Claude Code - Designed as Claude Code skills
  • Git command line - Must be available in environment

Recommended:

  • 12+ months of git history (more is better)
  • Active development (regular commits)
  • Descriptive commit messages (improves analysis quality)

Optional but helpful:

  • Issue tracking system (for defect correlation)
  • CI/CD logs (for test performance analysis)
  • Code coverage reports

Limitations

What These Skills Can Do

✅ Identify problem areas using git history ✅ Quantify technical debt and impact ✅ Prioritize improvements by ROI ✅ Reveal organizational and coordination issues ✅ Track trends over time

What These Skills Cannot Do

❌ Automatically fix code issues ❌ Replace human judgment and expertise ❌ Detect all types of technical debt (e.g., API design issues) ❌ Guarantee specific outcomes ❌ Work without git history

Important Caveats

  • Analysis quality depends on git history quality
  • Metrics are indicators, not absolute truth
  • Context matters - interpret with domain knowledge
  • ROI estimates are projections, not guarantees
  • Requires follow-through to realize benefits

Repository Structure

forensic-skills/
├── .claude/
│   └── skills/
│       └── forensics/
│           ├── forensic-analyzer.md (main orchestrator)
│           ├── category-a-hotspots/
│           │   ├── hotspot-finder.md
│           │   ├── complexity-trend-analyzer.md
│           │   └── change-coupling-detector.md
│           ├── category-b-socio-technical/
│           │   ├── knowledge-map-builder.md
│           │   ├── conways-law-visualizer.md
│           │   └── coordination-hotspot-identifier.md
│           ├── category-c-technical-debt/
│           │   ├── technical-debt-quantifier.md
│           │   └── refactoring-roi-estimator.md
│           ├── category-d-test-pipeline/
│           │   ├── test-bottleneck-profiler.md
│           │   └── unplanned-work-tracker.md
│           └── category-e-visualization/
│               ├── forensic-dashboard-generator.md
│               └── onboarding-risk-reporter.md
└── README.md (this file)

Contributing

Contributions are welcome! Areas for improvement:

  • Additional analysis types
  • Enhanced visualizations
  • Integration with external tools (JIRA, GitHub Issues, etc.)
  • Language-specific complexity metrics
  • Performance optimizations
  • Documentation improvements

License

[Specify your license here]

Credits

  • Inspired by "Your Code as a Crime Scene" by Adam Tornhill
  • Built for Claude Code by Anthropic
  • Research references from Microsoft, Google, and academic publications

Support

For issues, questions, or discussions:

  • Open a GitHub issue
  • [Add contact information or discussion forum]

Changelog

Version 1.0.0 (Initial Release)

  • 12 comprehensive forensic analysis skills
  • Main orchestrator with guided workflows
  • Comprehensive documentation
  • Example use cases and templates

Roadmap

Future enhancements planned:

  • Integration with popular issue trackers
  • Automated scheduled analyses
  • Trend database for long-term tracking
  • Web-based dashboard UI
  • Language-specific analyzers (Java, Python, etc.)
  • Machine learning for prediction models
  • Team collaboration features
  • CI/CD integration (GitHub Actions, GitLab CI)

Getting Help

Common Questions

Q: How long does a comprehensive analysis take? A: 4-8 hours for a comprehensive audit, 30-60 minutes for quick health check.

Q: Can I run this on a private repository? A: Yes, all analysis is local using your git history. Nothing is sent externally.

Q: What if my repository is huge (10,000+ files)? A: You can focus analysis on specific directories or modules to reduce scope.

Q: How often should I run forensic analyses? A: Monthly quick checks, quarterly comprehensive audits.

Q: Can this replace code review? A: No, it complements code review by providing historical context and patterns.

Q: Do I need to share these reports with my team? A: Recommended! Transparency about technical debt helps prioritize work.


Acknowledgments

Special thanks to:

  • Adam Tornhill for pioneering code forensics techniques
  • Anthropic for creating Claude Code
  • The software engineering research community for foundational studies
  • Open source contributors who will help improve these skills

Happy Code Sleuthing! 🔍

Find the insights hidden in your version control history.

About

A set of code forensics skills for Claude

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •