Skip to content
Dead Code

Clean Up With Confidence

Static analysis + telemetry-based detection. Find unused code and remove it safely.

Key Features

Static dead code detection from call graphs
Telemetry-based detection for production usage
Confidence-scored candidates with reasons
Safe removal recommendations
Export-aware analysis (public API protection)
Integration with CI for gradual cleanup

Dead Code Detection

$ ckb dead-code

Analyzing codebase...

Found 23 dead code candidates:

High confidence (safe to remove):
  internal/legacy/old_handler.go
    - func oldProcess() - 0 references
    - func deprecatedValidate() - 0 references
    Last modified: 8 months ago

  internal/utils/unused.go
    - func helperV1() - 0 references
    - type OldConfig - 0 references
    Entire file appears unused

Medium confidence (review first):
  internal/api/handlers.go
    - func legacyEndpoint() - exported, no internal refs
    Check: May be called externally

  pkg/client/v1.go
    - type ClientV1 - superseded by ClientV2
    Check: External packages may depend on this

Total: 15 high, 6 medium, 2 low
Estimated removable lines: 1,247

Confidence Scoring

Not all dead code is the same. CKB scores candidates so you know what's safe to delete immediately vs. what needs review.

High Confidence

No references found, not exported, no recent commits

Safe to remove
Medium Confidence

No static references, but exported or used via reflection

Review before removing
Low Confidence

Few references, possibly superseded by newer code

Investigate usage patterns

Production Usage Telemetry

Static analysis can't catch everything. Connect production telemetry to see what code is actually being executed.

$ ckb usage UserService.legacyExport --telemetry

Symbol: UserService.legacyExport
Static references: 0

Production telemetry (last 30 days):
  Invocations: 0
  Last called: Never recorded
  Confidence: High (safe to remove)

Note: Telemetry requires instrumentation.
See: ckb docs telemetry-setup

MCP Tools

findDeadCode

Find unreferenced symbols in your codebase

ckb dead-code
findDeadCodeCandidates

Get confidence-scored candidates with reasons

ckb dead-code --candidates
getObservedUsage

Check telemetry data for production usage

ckb usage UserService.legacyMethod

Delete with confidence

Stop accumulating technical debt. Clean up safely.