Skip to content

Sample code for: How to Refactor Python Code With an AI Agent - #880

Open
lpozo wants to merge 20 commits into
masterfrom
ai-refactor-python
Open

lpozo wants to merge 20 commits into
masterfrom
ai-refactor-python

Conversation

@lpozo

@lpozo lpozo commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Where to put new files:

  • New files should go into a top-level subfolder, named after the article slug. For example: my-awesome-article

How to merge your changes:

  1. Make sure the CI code style tests all pass (+ run the automatic code formatter if necessary).
  2. Find an RP Team member on Slack and ask them to review & approve your PR.
  3. Once the PR has one positive ("approved") review, GitHub lets you merge the PR.
  4. 🎉

lpozo and others added 20 commits October 8, 2026 11:47
Add the refactor-plan skill, which was missing from the archive, with
agent-agnostic frontmatter. Remove the tool settings from pyproject.toml,
since the tutorial has readers add them in the setup step.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Reword the refactoring rules in AGENTS.md to match the tutorial
- Have the refactor-plan skill add one row per file for repeated smells
- Add ai-refactor-python-final.zip with the refactoring plan, the CLI
  characterization tests, and the code after every refactoring
- Mention the final archive in the README

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The tests ship with the starter project, so they predate the diagnosis
that finds the bugs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The two previous commits shipped the refactored rptodo/ package in the
starter archive by mistake.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The IntEnum adds more machinery than the unnamed error codes justify,
so the plan no longer includes it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Drop the error masking smell from the refactor-plan skill catalog
- Note that some refactoring names are additions to Fowler's catalog
- Add the init database-wipe bug to REFACTOR.md in the final project

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Let the agent move tests along with code it moves to another module
- Move test_get_database_path to test_config.py and drop the re-export
- Pin ID 0 behavior in test_set_done and test_remove
- Update REFACTOR.md notes 8, 9, and 13

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Update the note in the REFACTOR-template.md asset (starter and final)
and in the final project's REFACTOR.md to use the tutorial's wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant