Automated Dead Code Cleanup Plan for Codex Repositories
Get a systematic plan to identify and safely remove unused exports and dead code from your codebase using characterization tests to prevent regressions.
Agent prompt for ChatGPT
Prompt
mkdir -p .agents/skills/automated-dead-code-cleanup-plan-for-codex-repositories && curl -sL "https://prompts-gpt.com/prompts/automated-dead-code-cleanup-plan-for-codex-repositories/raw" -o .agents/skills/automated-dead-code-cleanup-plan-for-codex-repositories/SKILL.md---
name: automated-dead-code-cleanup-plan-for-codex-repositories
description: "Get a systematic plan to identify and safely remove unused exports and dead code from your codebase using characterization tests to prevent regressions."
---
# Automated Dead Code Cleanup Plan for Codex Repositories
Get a systematic plan to identify and safely remove unused exports and dead code from your codebase using characterization tests to prevent regressions.
## Prompt
```
You are a Senior Software Engineer specializing in codebase maintenance and refactoring. Your task is to design a safe, automated cleanup plan for removing unused exports and dead code from a repository. Follow these rules: 1. Create an audit table mapping every exported symbol to its usage count across the directory. 2. Mandate the creation of a characterization test covering the current behavior of any module before modifications occur. 3. Define a three-phase removal process: Audit, Test, and Prune. 4. Prioritize internal-only utilities before public-facing APIs. 5. Include a specific step for verifying side effects in modules with no direct references. Output format: 1. Executive Summary of the cleanup strategy. 2. Audit Table: Symbol Name, File Path, Usage Count, Status. 3. Characterization Test Checklist. 4. Phased Execution Roadmap. This is not legal or professional advice; consult with your lead architect before executing destructive deletions in production codebases. Ask me these 3 questions first: 1. What is the primary programming language of the codebase? 2. Are there any known reflection-based calls or dynamic imports that static analysis might miss? 3. Do you currently have a CI pipeline that runs integration tests?
```
## Usage Notes
Use this prompt when preparing to refactor a large or legacy codebase to remove technical debt. Paste this into ChatGPT or Codex. Ensure you have your project directory structure accessible for reference.
You are a Senior Software Engineer specializing in codebase maintenance and refactoring. Your task is to design a safe, automated cleanup plan for removing unused exports and dead code from a repository. Follow these rules: 1. Create an audit table mapping every exported symbol to its usage count across the directory. 2. Mandate the creation of a characterization test covering the current behavior of any module before modifications occur. 3. Define a three-phase removal process: Audit, Test, and Prune. 4. Prioritize internal-only utilities before public-facing APIs. 5. Include a specific step for verifying side effects in modules with no direct references. Output format: 1. Executive Summary of the cleanup strategy. 2. Audit Table: Symbol Name, File Path, Usage Count, Status. 3. Characterization Test Checklist. 4. Phased Execution Roadmap. This is not legal or professional advice; consult with your lead architect before executing destructive deletions in production codebases. Ask me these 3 questions first: 1. What is the primary programming language of the codebase? 2. Are there any known reflection-based calls or dynamic imports that static analysis might miss? 3. Do you currently have a CI pipeline that runs integration tests?Example output
Tips and common edits
Why this works
- Forces a rigorous audit table before any code is deleted.
- Prioritizes safety by requiring characterization tests first.
- Structures the cleanup into clear, actionable phases.
Use this prompt when preparing to refactor a large or legacy codebase to remove technical debt. Paste this into ChatGPT or Codex. Ensure you have your project directory structure accessible for reference.
Common edits
- Adjust the characterization test requirements based on your specific testing framework.
- Add a specific phase for performance benchmarking if the codebase is latency-sensitive.
Reuse it: Use in a workflowAdapt in the builder
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
More like this
Sync Test Factories and Fixtures with Database Migrations
This prompt updates your test factories, JSON fixtures, and contract tests to match new database schema changes, ensuring your test suite remains consistent with production code.
Port a Function or Module to Another Language With Tests Proving Same Behavior
Lists the source code's behaviors and edge cases, writes tests in the target language first, ports the code idiomatically, and gives a table of library mappings and semantics that differ.
Refactor Monolithic God Classes into Clean Services
Get a step-by-step plan to break a large monolithic class into smaller, testable services while preserving the original public API behavior.
Cursor Characterization-Test-First Refactor of a Legacy Module
Has Cursor lock in current behavior with characterization tests before restructuring a legacy module in small steps, so you can decide whether the refactor preserved behavior and is safe to merge.
Generate API Client Patches from OpenAPI Schema Diffs
This prompt analyzes OpenAPI diffs to generate precise code patches and unit test assertions for your API client SDK.
Perform Static Call Graph Trace Before Modifying Code
Generate a clear visual map of function calls and file dependencies to identify exactly where your changes will ripple before you type a single line of code.
- Structured JSON Output Conformance Tester with Retry and Repair Across Providers
- Characterization Tests Before a Refactor
- Unit Test Plan and Test Code for an Existing Function
- Refactor nested legacy loops into flat readable helper functions
- Build a workflow test checklist with edge cases
- Plan an incremental refactor for legacy code