PR Refactoring Agent¶
The PR Refactoring Agent lets reviewers trigger Code Health-guided refactoring directly from pull requests. It keeps refactoring inside the normal review flow while giving teams a consistent way to improve maintainability and prevent regressions.
Beta: The PR Refactoring Agent is currently in beta. Contact your CodeScene account executive to request access.
Why Use It?¶
Use Code Health as a shared bar for refactoring instead of relying on ad hoc review preferences.
Fix maintainability degradations introduced by a pull request or uplift existing code toward a higher Code Health target.
Keep the workflow centralized in CI so reviewers can use the agent without every developer installing local AI tooling.
Push changes back to the pull request branch so the result still goes through normal review and approval.
How It Works¶
A reviewer triggers the agent from a pull request or merge request.
The workflow validates the requested action and model.
The agent analyzes the pull request branch with CodeScene data and performs the requested refactoring workflow.
Progress is reported back to the pull request, and any generated changes can be committed back to the same branch.
The agent supports two common workflows out of the box:
Fix Code Health degradations introduced by the current pull request.
Uplift existing code toward a higher Code Health target.
Fig. 24 The PR Refactoring Agent applies Code Health-guided refactorings directly in a pull request workflow.¶
Setup¶
This page is intentionally high level. Detailed installation, workflow configuration, and secret management are maintained in the platform-specific agent repositories:
GitHub: pr-refactoring-agent
GitLab: pr-refactoring-agent-gitlab
Follow those repositories for the exact setup steps in your CI environment.
Privacy and Security¶
From an information security perspective, the PR Refactoring Agent keeps the existing pull request review process intact while giving administrators control over the execution environment.
Administrators control which models the agent is allowed to use.
Credentials are managed as CI secrets.
Source code is processed only as part of the pull request workflow run, using the selected model provider configured for that environment. The CodeScene agent does not send source code to any other third party.
Any code changes made by the agent are pushed back to the pull request branch and remain subject to normal review and approval.
Repository content is processed by the selected model provider and by CodeScene during the run, so teams should choose providers that match their security and compliance requirements.
For stricter data residency and governance requirements, the agent can be run with self-hosted model providers and a self-hosted CodeScene instance.
For complete details, please see CodeScene’s full privacy and security documentation .