refinement · ruvnet, agentic-flow — Claude Code subagent: what it does, how to install
SPARC methodology subagent for iterative code refinement. Optimizes architecture, runs test suites, and learns from refactoring history.
no license ★ 850 updated 2026-10-26
.claude/agents/refinement.mdWhat refinement does
This agent handles the refinement phase in the SPARC workflow. It focuses on code tuning, unit test creation, and structural cleanup. Before touching the code, the pre-hook queries ReasoningBank to retrieve prior refactoring patterns and review previous test failures on similar tasks.
Execution relies on lifecycle hooks. A baseline check runs through npm test, while a post-hook calculates test coverage alongside overall test success. When tests pass, the hook triggers neural pattern training via claude-flow@alpha to preserve verified optimizations.
Because the hooks depend directly on npx claude-flow@alpha and npm, running this subagent without Node.js tooling causes memory queries and quality tracking to fail silently.
What it helps with
- refactor complex modules using historical pattern memory
- generate unit tests to increase test suite coverage
- store refactoring benchmarks and test metrics across sessions
- detect bottlenecks across interdependent code modules
Example prompts for the agent
- Run refinement on the user service and improve test coverage
- Refactor database cache calls using patterns from previous sessions
- Inspect recent test failures and optimize error handling in the auth module
How to install refinement
Manually: put the files in place
.claude/agents/refinement.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/refinement.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/refinement.mdCursor also reads .claude/agents/
Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean
Questions about refinement
How to install refinement in Claude Code?
Add the agent definition to .claude/agents/refinement.md inside your project directory.
What does refinement do?
It manages the SPARC refinement phase by refactoring application code, expanding test suites, and tracking performance metrics.
Which external tools does the refinement agent call?
Its hooks execute npm test and run CLI commands through npx claude-flow@alpha to query and save pattern records.
Similar subagents
All subagents for Code review and refactoring →refinement by other authors comes first.