Skip to main content
subagent CX Codex

refinement · ruvnet — Claude Code subagent: what it does, how to install

SPARC refinement phase agent for iterative code polish. Drives test-driven development: creates failing tests, satisfies them, and cleans up structure.

no license ★ 850 updated 2026-10-26

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/refinement.md
Open on GitHub

What refinement does

The refinement subagent manages the code polish phase within the SPARC methodology. It guides development through a strict test-driven loop: assembling failing tests for required behavior, writing minimal code to make them pass, and refactoring without regressions.

Built-in lifecycle hooks automate state tracking. The pre-hook logs the active phase to memory and runs npm test --if-present. Once work wraps up, the post-hook re-runs npm test and writes a timestamped record to memory.

Because both hooks execute npm test, the agent expects a configured test runner in the repository.

What it helps with

  • create failing unit tests before drafting service logic
  • refactor complex classes while keeping test suites green
  • tighten error handling and account lock workflows
  • trigger automated test suites across iteration stages

Example prompts for the agent

  • Run the refinement agent on the auth module using TDD
  • Refactor the AuthenticationService class and verify with tests
  • Write failing tests for account lockout and implement the fix

How to install refinement

Manually: put the files in place

.claude/agents/refinement.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

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 subagent definition file to .claude/agents/refinement.md in your project.

What does the refinement subagent do?

It coordinates the SPARC refinement phase, focusing on test-driven iterations, optimization, and safe code refactoring.

What environment setup does refinement need?

The project needs a functional npm test command in package.json, which the pre and post hooks call to verify test status.

Similar subagents

All subagents for Testing and QA →

refinement by other authors comes first.

refinement ruvnet SPARC methodology subagent for iterative code refinement. Optimizes architecture, runs test suites, and learns from refactoring history. CX Codex ★ 850repo stars sparc-methodology ruvnet sparc-methodology — a skill for Claude Code, Codex, Cursor, Copilot, Gemini CLI and OpenCode: SPARC development methodology with 17 modes — from specification and architecture to TDD, code review and deployment. CX Codex +1 1,200installs tdd sentimony The tdd skill guides behavior changes with tests before implementation, then checks the result through a red-green-refactor loop. Use it for features, fixes, and refactors. CX Codex +1 2,700installs fix-tests NeoLabHQ fix-tests — a skill for Claude Code, Codex, Cursor and other platforms that repairs failing tests after business logic changes or refactoring. It spawns parallel agents per failing file and loops until every test goes green. CX Codex +1 1,300installs implement pwguler implement — a skill for Claude Code and Codex that executes settled plans in thin test-driven slices. Runs when prompted to build code from a spec or slice plan. CX Codex +1 1,000installs w-tdd blockmatic-icebox The w-tdd Claude Code skill guides implementation through red-green-refactor. It activates when a developer requests TDD or the repository requires it. CX Codex +1 647installs typescript-clean-code bmad-labs typescript-clean-code — a skill for reviewing and refactoring TypeScript: code smell catalogs, four detection layers, and step-by-step workflows. CX Codex +1 669installs

From the same set76

The whole set →
consensus-coordinator consensus-coordinator — a Claude subagent that computes distributed consensus: Byzantine fault tolerance, voting and agreement across an agent swarm. CX Codex ★ 850repo stars specification SPARC specification subagent for requirements analysis. Gathers acceptance criteria, outlines project scope, and learns from previous patterns via claude-flow. CX Codex ★ 850repo stars pr-manager pr-manager coordinates pull request reviews, tests, and merge work through GitHub tools and a swarm of agents. It can also reuse patterns saved from earlier PR tasks. CX Codex ★ 850repo stars reviewer A reviewer persona for Claude that reads a change like a senior engineer: behaviour, security holes, slow paths, standards, docs. You get a summary with critical issues. CX Codex ★ 850repo stars release-swarm release-swarm coordinates release work from change analysis and changelog preparation to builds, tests, and deployment across configured targets. CX Codex ★ 850repo stars sona-learning-optimizer sona-learning-optimizer — a subagent that logs every task as a trajectory and nudges quality up by reusing similar past patterns and LoRA fine-tuning. CX Codex ★ 850repo stars tester tester is a Claude Code subagent that creates tests and checks code, recording past failures in claude-flow. CX Codex ★ 850repo stars code-goal-planner The code-goal-planner subagent turns software goals into milestones with dependencies and success criteria. Use it to plan a feature, bug fix, or refactor. CX Codex ★ 850repo stars

Project sponsors

Companies that keep this analytics open