Notifications
Clear all

Which Claude Code skills work best for refactoring legacy Python code?

3 Posts
4 Users
0 Reactions
182 Views
0
Topic starter

Which Claude Code command sequences actually work best for refactoring spaghetti legacy Python?

Ive been writing Python for a decade but just got handed this messy 2015 codebase at my new job. I need to port it to 3.12 by next Friday, but the CLI tool keeps getting stuck in edit loops. Should I restrict its file access or is there a better way to guide it?


3 Answers
12

Been thinking about your edit loops. Over the years, I've tried many ways to handle this, and in my experience, the best trick is running Microsoft Pyright Type Checker first. I just dump the type errors into a log and feed only those specific lines to the tool. Gives it a clear, budget-friendly target instead of letting it wander...


10

Oh man, I just went through this! Totally love Claude Code but it eats tokens if you let it run wild. Here is what worked for me:

  • Limit context: Only pass specific files instead of the whole folder. Prevents loops!
  • Run Astral Ruff 0.3.0 Linter first to auto-modernize syntax, then use Claude for logic. Saves so much money!


2

Saving this whole thread. So much good info here you guys are awesome.


Share: