DEV Community

Cover image for LLM Prompts I Run to Continuously Improve My Codebase
Michael Calkins
Michael Calkins

Posted on

LLM Prompts I Run to Continuously Improve My Codebase

Instead of asking LLMs to generate large chunks of code, I use them as codebase janitors. Small, focused tasks. Run often. Compound over time.

Below are copy-pasteable prompts I regularly use.


1. Remove Dead Code

Find unused files, functions, exports, imports, and variables.  
Explain why each is safe to remove and note any risk.
Enter fullscreen mode Exit fullscreen mode

2. Improve Naming

Rename variables, functions, and classes to better reflect intent.  
Optimize for clarity and readability, not brevity.
Enter fullscreen mode Exit fullscreen mode

3. Reduce Cyclomatic Complexity

Identify overly complex functions and simplify logic.  
Prefer early returns, smaller functions, and clearer control flow.
Enter fullscreen mode Exit fullscreen mode

4. Close Coverage Gaps

Scan test coverage output.  
Find uncovered lines and write focused unit tests that validate behavior.
Enter fullscreen mode Exit fullscreen mode

5. Document the Why

Add documentation explaining *why* this code exists and what tradeoffs were made.  
Do not describe what the code does line-by-line.
Enter fullscreen mode Exit fullscreen mode

6. Identify Responsibility Leaks

Find functions or components doing more than one job.  
Suggest how to split responsibilities cleanly.
Enter fullscreen mode Exit fullscreen mode

7. Improve Error Handling

Review error handling paths.  
Ensure errors are meaningful, actionable, and consistently handled.
Enter fullscreen mode Exit fullscreen mode

8. Normalize Patterns

Identify inconsistent patterns (naming, structure, async handling).  
Recommend a single, consistent approach.
Enter fullscreen mode Exit fullscreen mode

9. Flag Hidden Coupling

Detect tight coupling between modules or layers.  
Suggest abstractions or boundaries to reduce blast radius.
Enter fullscreen mode Exit fullscreen mode

10. Improve Readability Without Refactors

Improve formatting, ordering, and small structure changes only.  
No architectural rewrites.
Enter fullscreen mode Exit fullscreen mode

Why This Works

These prompts are:

  • Small
  • Repeatable
  • Low risk
  • High leverage

This turns LLMs into continuous improvement agents, not code generators.


A Note on Code Review

When generating changes like this, commit frequently and keep each change small. This makes reviews easier, limits blast radius, and ensures you can always roll back to a known-good state if something goes wrong.


Agents with Github

Notably, GitHub is moving in this exact direction—surfacing agent-based workflows directly from their homepage and integrating them across issues, PRs, and code review.


Code Acceleration

The pace of development is accelerating. To keep up, we need to reduce friction wherever possible. As the volume of code we write and review skyrockets, readability becomes non-negotiable—and these prompts help reinforce it.

Top comments (0)