Skip to content

OneSpiral/code-autopsy

Repository files navigation

code-autopsy

code-autopsy

Forensic codebase analysis. Find what's really wrong.

MIT License Install Compatibility


code-autopsy demo

Point code-autopsy at any codebase and get a full diagnostic report — architecture map, tech debt score, complexity heatmap, security risks, and 12 more diagnostics. The output is an interactive HTML report you can share with your team, attach to a PR, or use in a technical review.

Like getting a full-body MRI for your code. It finds what you knew was wrong, what you suspected was wrong, and what you had no idea was wrong.

The Report

Health Score and Category Rings

Each codebase gets a health score (0–100) broken into four categories, each scored independently:

Category What it measures
🏗️ Architecture Dependency graph, circular deps, layer violations, module cohesion
🔬 Code Quality Complexity heatmap, dead code, naming consistency, error handling
🔧 Maintenance Dependency health, test coverage, documentation, git health
⚠️ Risk Security surface, performance red flags, scalability bottlenecks, migration difficulty

What's In the Report

Architecture Map

Visual dependency graph showing module relationships, circular dependencies, and "god modules" that everything imports.

Complexity Heatmap

Complexity Heatmap

Every file colored by composite complexity: nesting depth × function length × cyclomatic complexity × parameter count. Red = needs attention. Green = clean.

16 Diagnostics

Each diagnostic produces a score (0–100), concrete evidence, and a specific recommendation. No vague warnings — every finding is backed by file names, line numbers, and counts.

# Diagnostic What it catches
D1 Dependency Graph Circular deps, god modules, coupling score
D2 Layer Violations UI importing data layer, reverse dependencies
D3 Module Cohesion Directories with unrelated files
D4 Entry Points Duplicated initialization, spaghetti startup
D5 Complexity Functions with 12 nesting levels, 200-line methods
D6 Dead Code Unused exports, unreachable files, stale TODOs
D7 Naming snake_case in a camelCase codebase
D8 Error Handling Empty catch blocks, unprotected API endpoints
D9 Dependencies Deprecated packages, dependency bloat
D10 Test Coverage Untested controllers, missing integration tests
D11 Documentation README quality, JSDoc coverage, architecture docs
D12 Git Health Commit frequency, bus factor, contributor spread
D13 Security Hardcoded secrets, SQL injection, XSS vectors
D14 Performance N+1 queries, missing pagination, bundle bloat
D15 Scalability Missing connection pools, synchronous I/O in async
D16 Migration Framework coupling, version lock-in, upgrade effort

Risk Matrix

2×2 grid plotting each risk by likelihood × impact. Instantly shows where the real danger is.

Top 10 Actions

Prioritized Actions

Prioritized by impact ÷ effort — not severity alone. A critical fix that takes 15 minutes ranks above a medium fix that takes a week.

Activity Timeline

Commit frequency chart showing team velocity over the last 6 months.

Install

One-line install (auto-detects your agent)

curl -fsSL https://raw.githubusercontent.com/OneSpiral/code-autopsy/main/install.sh | bash

Claude Code (Marketplace)

/plugin marketplace add OneSpiral/code-autopsy

Manual install

# Claude Code
git clone https://github.com/OneSpiral/code-autopsy.git ~/.claude/skills/code-autopsy

# Codex CLI
git clone https://github.com/OneSpiral/code-autopsy.git ~/.codex/skills/code-autopsy

# Pi
git clone https://github.com/OneSpiral/code-autopsy.git ~/.pi/agent/skills/code-autopsy

# OpenCode
git clone https://github.com/OneSpiral/code-autopsy.git ~/.opencode/skills/code-autopsy

Any other agent

Copy SKILL.md into your agent's skills directory. Single file, no dependencies.

Usage

Full autopsy

> Run a code autopsy on this project

or

> /code-autopsy

Output:

  • autopsy-report.html — interactive visual report
  • autopsy-summary.json — machine-readable summary

Targeted scans

> /code-autopsy architecture    # Architecture diagnostics only (D1–D4)
> /code-autopsy risks           # Risk diagnostics only (D13–D16)
> /code-autopsy src/api/        # Analyze a specific directory

Compare over time

Run autopsies periodically and compare the JSON summaries:

> Compare autopsy-summary-jan.json vs autopsy-summary-mar.json

Example Report

A complete example report is included:

Open it in your browser to see what the output looks like.

How It Works

Codebase
   │
   ▼
┌──────────────────────┐
│  PHASE 1: RECON      │  Automated file scan, git history,
│  (silent, no prompts)│  dependency tree, test inventory
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  PHASE 2: ANALYSIS   │  16 diagnostics across 4 categories
│  (strategic sampling)│  Read key files, not everything
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  PHASE 3: SCORING    │  0–100 per diagnostic, weighted
│  (quantified)        │  into category and overall scores
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│  PHASE 4: REPORT     │  Interactive HTML + JSON summary
│  (visual, shareable) │  Dark/light theme, responsive
└──────────────────────┘

The agent doesn't read every file. It uses file sizes, import graphs, git blame, and naming patterns to strategically sample the most important files — typically 15–30% of the codebase for 95% of the signal.

Scoring Philosophy

  • Measure, don't moralize. "You have 3 circular dependencies" — not "circular dependencies are bad."
  • Quantify everything. Every diagnostic produces a number.
  • Prioritize by ROI. Actions sorted by impact ÷ effort.
  • No false positives. If uncertain, don't flag it.
  • Context matters. A prototype scores differently than a production system.

Compatibility

Agent Status Install Location
Claude Code ~/.claude/skills/code-autopsy/
Codex CLI ~/.codex/skills/code-autopsy/
Pi ~/.pi/skills/code-autopsy/
OpenCode ~/.opencode/skills/code-autopsy/
Gemini CLI Copy SKILL.md to skills directory
Any agent Single SKILL.md file, universal

FAQ

How long does a full autopsy take? 2–5 minutes for a typical project (< 100K lines). The agent reads strategically, not exhaustively.

Does it work on monorepos? Yes. Point it at a specific package: /code-autopsy packages/api/

What languages are supported? Best results with TypeScript, JavaScript, Python, Go, Rust, Java. The framework (file structure analysis, git health, dependency scanning) works with any language.

Can I run it on someone else's project? Absolutely. Clone the repo, point code-autopsy at it, share the report.

How is this different from SonarQube / CodeClimate / etc.? Those are CI tools that run on every commit. code-autopsy is a one-shot forensic analysis for when you need to deeply understand a codebase — inheriting a project, evaluating a codebase, or making a refactor/rewrite decision. It produces a single shareable report, not a dashboard.

Contributing

See CONTRIBUTING.md. High-value contributions:

  • New diagnostics
  • Language-specific detection improvements
  • Report visual enhancements
  • Example reports from real open-source projects

Also By OneSpiral

  • ghost-writer — Reverse-engineer any author's writing style, then write in their voice. 24-dimension forensic style analysis.

License

MIT — do whatever you want with it.

About

Forensic codebase analysis. 16 diagnostics, health score, architecture map, complexity heatmap, risk matrix — all in one interactive HTML report.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages