Skip to content

Conversation

@DannylSyph3r
Copy link

@DannylSyph3r DannylSyph3r commented Oct 16, 2025

User description

The Dead Code Undertaker

The Undertaker is a dead code detection agent that identifies unused functions, classes, variables, imports, methods and unreachable code across your entire repository using static analysis.

What It Does

  • Scans all source files and detects unused code elements
  • Provides deterministic confidence scoring (50-100%) for safe removal decisions
  • Outputs clean JSON results for CI/CD integration

Use Case

Dead code accumulates naturally as features are refactored or deprecated. The Undertaker gives teams reliable, data-driven insights to make informed cleanup decisions.

Files Added

  • agent.toml - Complete agent configuration
  • agent.yaml - YAML format variant
  • README.md - Full documentation with examples and best practices

Testing

Tested with a sample project to validate dead code detection accuracy across multiple file types and code patterns. Full testing walkthrough available in the demo video.

Documentation

Complete documentation included in README.md with usage examples, configuration options, confidence scoring rules, and integration guidance.

Breaking Changes

None. This is a new agent with no impact on existing functionality.

Demo

See the walkthrough: https://x.com/Slethware/status/1978785991314780402?t=hLnTNGKCapBhVRaxQqnaaQ&s=19


PR Type

Enhancement


Description

  • Add new "Undertaker" agent for dead code detection with confidence scoring

  • Implement comprehensive static analysis for unused functions, classes, variables, imports, and unreachable code

  • Provide dual configuration formats (TOML and YAML) with identical functionality

  • Include detailed documentation with usage examples, confidence scoring rules, and integration guidance


Diagram Walkthrough

flowchart LR
  config["Agent Configuration<br/>(TOML/YAML)"] --> analysis["Static Code Analysis"]
  analysis --> detection["Dead Code Detection"]
  detection --> scoring["Confidence Scoring<br/>(50-100%)"]
  scoring --> output["JSON Output<br/>(dead_code_analysis.json)"]
Loading

File Walkthrough

Relevant files
Documentation
README.md
Complete documentation for Undertaker agent                           

agents/undertaker/README.md

  • Add comprehensive documentation for the Undertaker dead code detection
    agent
  • Document confidence scoring rules, analysis process, and output format
  • Provide usage examples, integration guidance, and best practices
  • Include technical details, limitations, and error handling information
+189/-0 
Configuration changes
agent.toml
Agent configuration in TOML format                                             

agents/undertaker/agent.toml

  • Define agent configuration in TOML format with version 1.0
  • Implement detailed instructions for dead code detection using static
    analysis
  • Configure arguments for min_confidence threshold and include_tests
    option
  • Define comprehensive JSON output schema with summary statistics and
    dead code items
  • Specify tools (git, filesystem, ripgrep) and execution strategy (plan)
+164/-0 
agent.yaml
Agent configuration in YAML format                                             

agents/undertaker/agent.yaml

  • Define agent configuration in YAML format with identical functionality
    to TOML
  • Implement same instructions, arguments, tools, and execution strategy
  • Provide equivalent JSON output schema for dead code analysis results
  • Mirror confidence scoring rules and analysis process from TOML version
+178/-0 

@qodo-merge-for-open-source
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@DannylSyph3r DannylSyph3r changed the title Feat: Code Undertaker Agent - New Agent Implementation - Qodo Feat: Code Undertaker Agent - New Agent Implementation - #QodoAgentChallenge (Clean Code Category) Oct 16, 2025
@qodo-merge-for-open-source
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Use dedicated static analysis tools

Replace the current unreliable static analysis method, which uses an LLM with
ripgrep, with dedicated static analysis tools like ts-prune or vulture. These
tools use Abstract Syntax Trees (ASTs) for more accurate and robust dead code
detection.

Examples:

agents/undertaker/agent.toml [7-61]
instructions = """
You are a dead code detection agent. Find unused code elements in the repository using static analysis.

CORE MISSION:
Identify unused functions, classes, variables, imports, types, enums, methods, and unreachable code.
Provide confidence scoring based on reference counts and export status.
Be reliable and dependable within reasonable limits.
Output clean JSON results for integration.

ANALYSIS PROCESS:

 ... (clipped 45 lines)
agents/undertaker/agent.yaml [7-61]
    instructions: |
      You are a dead code detection agent. Find unused code elements in the repository using static analysis.

      CORE MISSION:
      Identify unused functions, classes, variables, imports, types, enums, methods, and unreachable code.
      Provide confidence scoring based on reference counts and export status.
      Be reliable and dependable within reasonable limits.
      Output clean JSON results for integration.

      ANALYSIS PROCESS:

 ... (clipped 45 lines)

Solution Walkthrough:

Before:

# agent.toml (instructions for LLM)

# 1. Discover all source files using filesystem tool.
# 2. For each language, use ripgrep with regex patterns
#    to find all function/class definitions.
# 3. For each definition found:
#    a. Use ripgrep again to count references in the codebase.
#    b. Use ripgrep to check for export keywords.
# 4. Apply confidence rules based on reference count and export status.
# 5. Format results into JSON.

After:

# agent.toml (instructions for LLM)

# 1. Detect project languages (e.g., TypeScript, Python).
# 2. Based on language, execute the appropriate static analysis tool:
#    - If TypeScript, run 'ts-prune' tool.
#    - If Python, run 'vulture' tool.
#    - ... other languages
# 3. Capture the structured output from the tool.
# 4. Transform the tool's output into the required JSON schema.
# 5. Apply confidence scoring and filtering based on the parsed results.
Suggestion importance[1-10]: 10

__

Why: This suggestion correctly identifies a fundamental architectural flaw in using ripgrep for static analysis and proposes a robust, industry-standard alternative that would dramatically improve the agent's reliability and correctness.

High
  • More

@DannylSyph3r DannylSyph3r changed the title Feat: Code Undertaker Agent - New Agent Implementation - #QodoAgentChallenge (Clean Code Category) Feat: Code Undertaker Agent - New Agent Implementation Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant