Coding assistants like Cursor have brought us into a new era of programming. But there’s a class of programming tasks that remain outside their reach: large-scale, systematic modifications across large codebases. You wouldn’t ask an AI to delete all your dead code or reorganize your entire component hierarchy - the tooling just isn’t there.

That’s where codemods come in. A codemod is a program that operates on a codebase, and when you give an AI agent the ability to write and execute them, these platform-level tasks fall below the high-water mark of AI capabilities.

Here’s a real example: we asked Devin (an autonomous SWE agent) to “delete all dead code” from our codebase. Instead of trying to make hundreds of individual edits, Devin wrote and debugged a program that systematically removed unused code while handling edge cases like tests, decorators and indirect references.

Devin edits a codemod in response to linter errors

This modifies over 40 files and correctly removes old code, passes lint + tests, etc.

What made this work?

Devin operates like a state machine: write a codemod, run it through the linter, analyze failures, and refine. Each iteration adds handling for new edge cases until the codemod successfully transforms the entire codebase. This is the same cycle developers use for many large-scale refactors, just automated.

The nice part about this approach is that we don’t have to blindly trust the AI. There’s no magic - it’s just a program we can run and verify through linter/test output. The codemod is easy to review, and we can update it if we need to add exceptions or edge cases. Much better than trying to manually review hundreds of individual edits.

Try it yourself

Want to experience this with your own Devin instance? Install the Codegen CLI in your Devin box:

uv tool install codegen --python 3.13

Then use the following prompt:

Dead Code Deletion Prompt

Download System Prompt

Or try it with other platform-level modifications supported by Codegen:

We’d love to hear how it works for you! Let us know in our community and share your experience developing codemods with Devin or other code assistants.

Was this page helpful?