unused-code-cleanup

Remove unused imports, variables, and dead code from TypeScript/React projects.

4|1|Updated Sep 17, 2025
One-click install
npx skills add https://github.com/phamhung075/4genthub-hooks --skill unused-code-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unused-code-cleanup
Source: https://github.com/phamhung075/4genthub-hooks/tree/main/skills/unused-code-cleanup
Command: npx skills add https://github.com/phamhung075/4genthub-hooks --skill unused-code-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Systematically identify and remove unused imports, variables, and dead code in TypeScript/React projects to improve build health and runtime performance.

Core Features & Use Cases

  • Detection: use TypeScript's --noUnusedLocals/ --noUnusedParameters to surface unused code.
  • Patterns: remove unused imports, props, parameters, and debug snapshots.
  • Workflow: prioritize high-impact files, verify by building/tests, and track progress.

Quick Start

Detect unused code with npx tsc --noEmit --noUnusedLocals --noUnusedParameters 2>&1 | grep "error TS6133", then remove unused items and verify with a build.

Frequently Asked Questions about unused-code-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I remove unused code from a TypeScript project?

Remove unused code by enabling TypeScript's --noUnusedLocals and --noUnusedParameters compiler flags, then systematically delete unused imports, variables, and parameters flagged as TS6133 errors. Verify with a build to confirm zero warnings and a clean production bundle.

What's the best way to identify dead code in React components?

Identify dead code by running `npx tsc --noEmit --noUnusedLocals --noUnusedParameters` to surface unused imports, props, and local variables across components, hooks, and utilities. Prioritize high-impact files and verify changes with tests and builds.

Can I detect unused imports and variables in a large TypeScript codebase?

Yes. Systematically detect unused imports, variables, and parameters across large codebases using TypeScript compiler flags. Process files in priority order, verify each batch with builds and tests, and track progress toward eliminating all TS6133 warnings.

Why should I remove unused code before production?

Removing unused code reduces bundle size, eliminates compiler warnings, and improves build health. It's essential during refactors and pre-production cleanup to ensure runtime performance and a warning-free TypeScript configuration.

Do I need TypeScript configuration to clean up unused code?

Yes. You need a TypeScript configuration file with --noUnusedLocals and --noUnusedParameters enabled to detect unused code. Build verification is required afterward to confirm zero warnings and validate the clean production bundle.

What patterns of unused code does TypeScript flag?

TypeScript flags unused imports, unused local variables, unused function parameters, and unused props in components. The skill also handles removal of debug snapshots and other dead code patterns across components, hooks, utilities, and API layers.