🕸️ Cobweb — Git-Based Dead Code Detector
Cobweb is a VS Code extension that sits quietly in your editor and flags stale, possibly dead functions by combining two signals:
Everything runs 100% locally against the repo already open in your editor — no servers, no accounts, no telemetry. Table of Contents
Why CobwebEvery codebase accumulates functions that used to matter and quietly stopped being called. Cobweb answers three questions right where you're already reading code, with no dashboards to check:
Features
CompatibilityCobweb is fully supported in VS Code, Cursor, Windsurf, and Remote / SSH / Dev Container environments. See the full Editor Compatibility Guide for details, including minor clipboard caveats in Windsurf. How It WorksFor every function or method in the open file, Cobweb:
InstallationFrom a packaged extension:
Cobweb activates automatically on supported file types in any folder that is a git repository — no setup required. Reading the CodeLens LabelsCobweb shows one of the following labels above each flagged function.
|
| Language | Analysis Type | What's Detected |
|---|---|---|
| TypeScript / TSX | ✅ AST (ts-morph) | Functions, arrow functions, methods, class properties |
| JavaScript / JSX | ✅ AST (ts-morph) | Functions, arrow functions, methods, class properties |
| Python | 🔤 Regex | def and async def functions |
| Go | 🔤 Regex | func declarations and methods |
| Rust | 🔤 Regex | fn and pub fn functions |
| Java | 🔤 Regex | Public/private/protected methods |
| C# | 🔤 Regex | Methods with access modifiers |
| PHP | 🔤 Regex | function and class methods |
| Ruby | 🔤 Regex | def and def self. methods |
| C / C++ | 🔤 Regex | Function definitions |
| Swift | 🔤 Regex | func declarations |
| Kotlin | 🔤 Regex | fun declarations |
| SQL | 🔤 Regex | CREATE FUNCTION, CREATE PROCEDURE, CREATE VIEW |
| Vue | 🔤 Regex | Methods inside <script> blocks |
| Shell / Bash | 🔤 Regex | function_name() { } declarations |
| Dart | 🔤 Regex | Function declarations |
| Scala | 🔤 Regex | def methods |
AST = accurate, project-wide reference count. Regex = in-file reference count only (approximate — shown as
0 in-file refs).
Configuration
Set these in your VS Code settings.json:
| Setting | Default | Description |
|---|---|---|
cobweb.staleAfterDays |
180 |
Days of inactivity before a symbol is marked stale |
cobweb.ignoreGlobs |
["**/node_modules/**", "**/dist/**", "**/*.test.*", "**/*.spec.*"] |
File patterns to skip |
cobweb.respectExports |
true |
Show 📦 Exported label instead of ⚠️ for exported symbols |
cobweb.maxFilesPerScan |
2000 |
Safety cap on files analyzed per scan (protects monorepos) |
cobweb.detectDuplicates |
true |
Enable/disable structural duplicate detection (TS/JS only) |
cobweb.duplicateBodyLengthTolerance |
0.15 |
Allowed difference ratio between duplicate bodies (e.g. 0.15 = 15% difference) |
Commands
Run these from the Command Palette (Cmd/Ctrl+Shift+P):
| Command | Description |
|---|---|
Cobweb: Refresh Analysis |
Clears all caches and re-runs analysis on open files |
Cobweb: Show Details for Symbol |
Opens a detail popup with full git + reference info for a symbol |
Cobweb: Show Project Dashboard |
Opens a project-wide webview panel listing every zero-ref function, sortable and filterable by name, file, age, author, and duplicate status |
Cobweb: Copy AI Cleanup Prompt for Symbol |
Triggered via the inline 📋 Copy AI cleanup prompt CodeLens; copies a ready-to-paste Markdown prompt to the clipboard |
Cobweb: Check File for Whole-File Orphan |
Checks the active TS/JS file: if every function has zero callers, reports it as a whole-file orphan and optionally copies an AI review prompt |
What Cobweb Does NOT Claim
Zero refs ≠ definitely dead. Cobweb surfaces a signal — you make the call. It cannot see:
- Dynamic calls —
obj[methodName](), string-based dispatch,eval - External consumers — if your function ships in a published npm package or is used by another repo
- Framework conventions — lifecycle methods invoked by React, Angular, Vue, NestJS, etc. (a common list is pre-excluded; extend
ignoreGlobsfor your framework) - Test-only usage — if test files are excluded via
ignoreGlobs(the default) - Cross-file references in non-TS languages — regex-based languages only count in-file references
- Whole-file orphan detection is function-scoped only — a file whose exports are entirely classes, constants, types, interfaces, or barrel re-exports (
export { x } from './x') produces zero function candidates and is therefore invisible to the whole-file orphan check. It will not be falsely flagged, but it also cannot be detected as orphaned by this feature. Use your bundler's tree-shaking output or an import-graph tool for that.
Use Cobweb's flags as a starting point for a code review, not as an automatic delete instruction.
Building From Source
git clone https://github.com/susheepks/cobweb.git
cd cobweb
npm install
npm run compile # TypeScript + esbuild → dist/extension.js
npm run package # produces cobweb-x.x.x.vsix
To install locally without publishing: Extensions panel → ··· menu → Install from VSIX... → select the .vsix.
Running Tests
npm test # Unit tests (mocha + chai) — no VS Code needed
npm run test:integration # Full integration tests inside a real VS Code instance
Tests cover: GitAnalyzer (against real git repos), StaticAnalyzer (AST candidates), and arrow function detection.
Privacy
Cobweb makes zero network requests. It runs entirely locally:
ts-morph— TypeScript/JavaScript AST analysis, in-processsimple-git— shells out to your localgitbinary only- No analytics, no crash reporting, no telemetry of any kind
License
MIT © susheepks