CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/dead-code-finder

Find dead Python code (unused imports, functions, classes, methods, variables, unreachable statements) with confidence scores. Use when the user asks to find, audit or clean up unused or dead code in a Python project.

Quality

97%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

rules.mdreferences/

Detection rules

Kinds and confidence

KindConfidenceMeaning
unused_import90Imported name never loaded in its own module and not listed in that module's __all__.
unused_function60Module-level function whose name is referenced nowhere in the scanned set.
unused_class60Class (module level or nested) whose name is referenced nowhere.
unused_method60Method whose name is referenced nowhere.
unused_variable60Module-level assignment target whose name is referenced nowhere.
unreachable_code100First statement after return, raise, continue or break in the same statement list; reported once per block.

Decorated functions and methods are exempt in the bundled scanner. The library function scan_sources(..., include_decorated=True) reports them at confidence 50; the command line and scan do not expose that option.

What counts as a reference

  • Any Name load, any attribute name (x.m references m), the name in from m import name, and any string constant that is a valid identifier (covers getattr(obj, "name") and __all__ entries).
  • Names listed in a module's __all__.
  • Imports are judged per module: an import is unused when its bound name is never loaded in that same module.

Exemptions (never reported)

  • Names in __all__, dunder names, and _ alone.
  • Names matching a --whitelist fnmatch pattern.
  • test_* functions and Test* classes in files named test_*.py or *_test.py.
  • Methods named setUp or tearDown.
  • Functions decorated with typing.overload.
  • Decorated functions and methods (route handlers, fixtures, registered callbacks).
  • Star imports and __future__ imports.
  • Nested functions inside function bodies are not collected.

Limits

  • Default scan limits: 5000 files, 1,000,000 bytes per file; directories .venv, .git, __pycache__ are skipped. More than 5000 files exits with code 2.
  • Per-file problems appear in the output errors list with codes syntax_error, file_too_large, decode_error, too_deep.
  • Findings are sorted by (module, line, name). Module names are paths relative to the scanned directory, or the file name for a single file.
  • Output is plain text; module names come from file names and are not sanitized.

SKILL.md

tile.json