Dead Code Hunter
An AI-powered GitLab Duo Agent that automatically scans your repository, detects unused code, and opens a clean merge request with fixes.

What Inspired Me

Every developer knows the feeling — you open a codebase and find functions nobody calls, imports nobody uses, variables that just sit there doing nothing. Dead code is everywhere and cleaning it manually is boring, time consuming and easy to mess up. I wanted to build something that does that work automatically

What I Built

Dead Code Hunter is a GitLab Duo Agent powered by Claude AI that:

  • Scans your entire repository end-to-end
  • Detects unused functions, variables, imports, and classes
  • Assigns a confidence score (0–100%) to every finding
  • Only removes code it's 80%+ confident about (safe by default)
  • Opens a Merge Request with a detailed report—no manual work required

How I Built It

I used the GitLab Duo Agent Platform with a YAML-defined workflow. Claude AI serves as the intelligent core:

  1. It reads every file in the repo
  2. Scores findings and generates precise removal patches
  3. Commits changes and opens a MR with a human-readable report

Challenges I faced

  • First-time automation building: Steep learning curve on instructing agents to read, analyze, and commit safely.
  • Safety first: Implementing confidence thresholds to prevent accidental deletions—dead code hunting without breaking code.
  • Cross-file dependency: as for now, it only works well for the individual files. But in case of medium projects, it doesn't work well because different files are related each other ( api calls and stuff).

Key Learnings

  • Building action-oriented AI agents (not just chatbots) that integrate into dev workflows
  • learning GitLab Duo Agent Platform and YAML flows

Future Plans

  • Cross language dependency detection — smart enough to not delete a Python backend function that your React frontend is calling via an API
  • Skip list — a .deadcodeignore file so you can tell the agent to never touch certain functions I

Built With

  • ci/cd
  • claude
  • gitlab
  • gitlabduoagent
  • yaml
Share this project:

Updates