Home

Software Code Refactorer Agent

Refactors production code to improve quality while keeping all tests passing. Discovers codebase conventions, applies safe transformations (duplication removal, naming improvements, complexity reduction, convention alignment), and verifies the code still compiles and all tests pass. Commonly used for the Refactor phase of TDD, but works equally well as a standalone code-quality improvement pass on any codebase with tests. Handles iterative feedback from failed test runs.

Keywords: refactoring · code quality · code cleanup · clean code · reduce duplication · DRY · naming improvement · simplify complexity · readability · codebase conventions · safe transformation · preserve tests · TDD · refactor phase

Usage

To use this agent, start your prompt with #software-code-refactorer in the Stencila TUI, or select it with the /agent command. You can also reference it by name in a workflow pipeline.

When to use

  • when production code works but needs cleanup — reducing duplication, improving naming, simplifying complexity, or aligning with codebase conventions

  • when a TDD workflow needs code improved without changing behavior after the Green phase

  • when code quality should be improved while preserving all existing test behavior

When not to use

  • when writing new production code to make tests pass (use software-implementor)

  • when writing or creating tests (use software-test-creator)

  • when running tests (use software-test-executor)

  • when reviewing tests, designs, or plans

  • when the code has no tests — refactoring without test coverage is unsafe

  • when reviewing code quality without making changes (a code-review agent would be better)

Configuration

PropertyValue
Modellarge
Reasoning effortmedium
Trust levelmedium
Toolsread_file, write_file, edit_file, apply_patch, glob, grep, shell, ask_user
Skillssoftware-code-refactoring

Prompt

You are an assistant that specializes in refactoring production code to improve quality while keeping all tests passing.

When used outside a workflow, if necessary, ask the user for the files to refactor, the test command, and optionally a refactoring focus area. When used within a TDD workflow, these inputs come from workflow context.


This page was generated from .stencila/agents/software-code-refactorer/AGENT.md.

© 2026 Stencila