Skip to main content
subagent CX Codex

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

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

What 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.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 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.

refinement ruvnet SPARC refinement phase agent for iterative code polish. Drives test-driven development: creates failing tests, satisfies them, and cleans up structure. 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 stream-chain ruvnet stream-chain chains sequential agent steps together using streaming JSON flow and provides ready-to-run pipelines. CX Codex +1 1,200installs iterative-refinement sammcj iterative-refinement structures measurable optimization loops against pass/fail checks, trims context consumption, and delegates subtasks. CX Codex +1 ★ 173repo stars qcsd-refinement-swarm proffesor-for-testing The qcsd-refinement-swarm skill checks user stories before sprint commitment, creates BDD scenarios, and returns a READY, CONDITIONAL, or NOT-READY decision. CX Codex +1 105installs dspy-output-refinement-constraints OmidZamani The dspy-output-refinement-constraints skill shows how to validate DSPy outputs, refine them with dspy.Refine, and choose among candidates with dspy.BestOfN. Use it when generated results must meet format or content rules. CX Codex +1 ★ 125repo stars quality-refinement-autoloop RobLe3 quality-refinement-autoloop turns a bad Blender result into a reusable skill fix. Diagnoses the gap, repairs either the artifact or the skill, then preps for release. CX Codex +1 1,400installs

From the same set76

The whole set →
Performance Monitor Performance Monitor collects system and agent metrics, hunts bottlenecks and watches SLA thresholds. Useful when several agents run at once and it is unclear which one is slow. CX Codex ★ 850repo stars Benchmark Suite Benchmark Suite runs throughput and latency benchmarks, measures resource consumption, and detects performance regressions in agent clusters. CX Codex ★ 850repo stars security-manager security-manager — a Claude Code subagent that embeds cryptographic security into distributed consensus protocols. Runs on critical operations, verifying threshold signatures, detecting attacks, and encrypting node communications. CX Codex ★ 850repo stars hierarchical-coordinator hierarchical-coordinator — a coordinator subagent that splits a job into sub-tasks and hands them to worker agents through the claude-flow MCP server. Fits work that runs top-down. CX Codex ★ 850repo stars workflow-automation workflow-automation is a Claude Code subagent that creates and updates GitHub Actions workflows. It handles CI/CD setup requests and workflow run analysis. CX Codex ★ 850repo stars Topology Optimizer Topology Optimizer — a subagent that scores swarm topologies — hierarchy, mesh, ring, star, hybrid — against your workload and says which one to switch to. CX Codex ★ 850repo stars crdt-synchronizer crdt-synchronizer — a Claude Code subagent for conflict-free state synchronization across nodes using CRDT structures and vector clocks. CX Codex ★ 850repo stars sublinear-goal-planner sublinear-goal-planner — a Claude subagent that breaks a big goal into actions with dependencies and looks for the cheapest route through the action graph. CX Codex ★ 850repo stars

Project sponsors

Companies that keep this analytics open