Back to Skills

codegen-refactor

Perform refactoring using TDD starting from README + Issue (following codegen-test), aligning with existing implementation conventions, and leveraging Serena MCP semantic search/editing to improve internal quality with high performance and race-safety in mind.

2starsUpdated 3/25/2026

Security Assessment

Safe(100/100)
Security Score100/100

About codegen-refactor

The codegen-refactor skill is designed to enhance the internal quality of codebases without altering their external behavior or specifications. It addresses the challenge of maintaining large or complex projects by providing a structured, test-driven approach to refactoring. By focusing on minimal, incremental changes and strictly adhering to existing implementation conventions, this skill ensures that code remains maintainable, performant, and free from race conditions. It integrates with Serena MCP tools to precisely locate and edit relevant symbols, allowing developers to improve code safely without needing to read entire files or disrupt ongoing work.

Key features of the codegen-refactor skill include a rigorous test-first workflow, alignment with existing project style, and careful handling of performance and concurrency concerns. It starts by analyzing the README and relevant Issue to define acceptance criteria and test perspectives. The skill leverages Serena MCP capabilities such as symbol overview, targeted edits, and call site analysis to streamline refactoring tasks. Tests are created before implementing changes, following a table-driven approach and using injectable dependencies or mocks where appropriate. All edits are performed in idiomatic Go, maintaining short and clear naming conventions while adhering to standard formatting and design principles.

This skill is particularly useful for developers tasked with improving the maintainability, testability, and performance of a codebase without introducing new features or fixing unrelated bugs. It is ideal for teams that rely on automated testing and code review processes and need to ensure safe, reviewable refactoring that aligns with existing project standards. By following a disciplined, test-driven approach, codegen-refactor helps maintain long-term code health and reduces the risk of regressions, making it valuable for software engineers, code reviewers, and maintainers working on Go projects with performance or concurrency considerations.

FAQ

When should I use the codegen-refactor skill?

Use this skill when refactoring is required based on an Issue, especially if performance improvements or race condition considerations are involved. It is not intended for feature development or general bug fixes.

Does this skill change external behavior or APIs?

No. The skill is designed to improve internal code quality while preserving external behavior, API contracts, inputs/outputs, and public struct meanings.

What testing approach does this skill follow?

It follows a test-driven methodology, creating failing tests first according to the codegen-test skill, then implementing minimal changes to make tests pass. Table-driven tests and dependency injection or mocks are used where applicable.

Which tools does codegen-refactor leverage for editing?

The skill uses Serena MCP tools for semantic search and precise edits, such as symbol overview, locating definitions, finding call sites, and performing pinpoint insertions or replacements.

Are there any limitations to what this skill can refactor?

Yes. It is limited to internal quality improvements, maintainability, performance, and design health. It does not implement new features or address unrelated bugs.

Install codegen-refactor

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

nihiyama/ffq