Coding agents are fast, but they are messy. They leave behind helper functions that never get called, duplicate services that sit alongside the ones they replaced, and routes that have lost their handlers. Sid732 has released Loose Ends, a new CLI tool designed to catch this specific type of technical debt before it merges. Unlike generic linters, Loose Ends builds a Liveness Graph to determine if code added or touched in a change is actually reachable from a real entry point.

How the Liveness Graph Works

The tool analyzes TypeScript, JavaScript, Python, and Java code by mapping imports, exports, re-exports, and dynamic dependencies. It identifies roots by scanning package manifests, framework conventions like Next.js routes or Django apps, and server commands in Dockerfiles. When you run npx loose-ends check, it compares the base and head revisions to report only what the specific change did. This ensures that pre-existing dead code doesn't block your pull request, focusing strictly on the new mess created by the current diff.

Deterministic Evidence Over LLM Guesses

Loose Ends explicitly rejects the idea of using an LLM to guess if code looks unused. Instead, it relies on deterministic evidence. It flags errors for orphaned-addition when new code isn't reachable, newly-orphaned when a change breaks existing connections, and superseded when a replaced implementation wasn't removed. For example, if an agent adds a UserServiceV2 and wires it in but forgets to delete the original UserService, the tool detects the structural similarity and the broken edge, demanding deletion or an explicit dormant marker with a reason.

CI Integration and Agent Support

For teams running CI, Loose Ends offers a GitHub Action that adds inline annotations to diffs and keeps a PR comment up to date. It requires Node.js 20 or newer but works on Python and Java projects without needing a package.json. For AI coding agents themselves, there is an MCP server exposing read-only commands like check_changes and plan_cleanup. This allows agents to self-correct by understanding exactly why their code was flagged, turning vague linting warnings into actionable, graph-backed feedback.

Key Takeaways

  • Loose Ends builds a Liveness Graph to verify reachability from real entry points, not just syntax.
  • It specifically targets AI-generated debt like orphaned additions and superseded implementations.
  • The tool is deterministic, avoiding LLM guesses about whether code is 'actually' unused.
  • Supports TypeScript, JavaScript, Python, and Java with extensive framework awareness.
  • Includes CI actions and an MCP server for AI agents to self-correct during development.

The Bottom Line

Loose Ends provides the deterministic guardrails AI coding agents desperately need, ensuring that speed doesn't come at the cost of structural integrity.

Sources

https://github.com/sid732/loose-ends

> From The Wire