How to Add Sourcery to CI and Enforce Refactor Rules
Running Sourcery only in your editor means half the team ignores it. This guide wires the CLI into GitHub Actions, sets a rule profile and…
Python-focused code review bot that suggests concrete refactors, not just warnings
Sourcery reviews your Python and JavaScript code and suggests refactors it can often apply automatically. It runs as an IDE extension, a CLI in CI, and a GitHub review bot. There is a free tier for open source and solo use, with paid team plans.
Actionable fixes. Most linters tell you a function is too complex. Sourcery shows a rewritten version — collapsing nested conditionals, converting a loop to a comprehension, replacing a manual counter with enumerate — and you accept it with one click in the IDE.
It started as a Python refactoring engine and later added LLM-based PR review. That history matters: the deterministic rules are its foundation, and the AI layer sits on top rather than replacing it.
The IDE experience is the strong suit. Suggestions appear as you type, before the code ever reaches a PR, which is where refactoring is cheapest. Python support is deeper than the JS support — Python is where the tool cut its teeth.
Be aware of the noise problem. On a legacy codebase, Sourcery can flag hundreds of items on day one. Teams usually need to phase adoption or they will tune it out entirely. Its AI PR summary is also thinner than dedicated reviewers like Graphite or CodeRabbit.
Pricing: free for open-source repositories, and paid plans around $10–15 per developer per month for private repos with team features. That is cheaper than most AI reviewers, which reflects its narrower scope.