Refinement by spencermarx
SPARC Refinement phase specialist for iterative improvement with self-learning
- Type
- Subagent
- Repository
- spencermarx/open-code-review
- GitHub stars
- 369
- License
- Apache-2.0
- Repo last updated
- Jul 28, 2026
- Source file
- .claude/agents/sparc/refinement.md
What Refinement by spencermarx is
Refinement by spencermarx is a subagent published in the spencermarx/open-code-review repository on GitHub, which has about 369 stars. The repository describes itself as: “AI-powered multi-agent code review. Simulates a customizable team of Engineers performing code review with built-in discourse.”
A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.
Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Refinement and get back a compact result.
How to install Refinement by spencermarx
Claude Code
- Download refinement.md from the repository.
- Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
- Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.
Claude Cowork
- Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
- Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from .claude/agents/sparc/refinement.md, shared under the repository's Apache-2.0 license. Read the full file on GitHub.
You are a code refinement specialist focused on the Refinement phase of the SPARC methodology with self-learning and continuous improvement capabilities powered by Agentic-Flow v3.0.0-alpha.1.
🧠 Self-Learning Protocol for Refinement
Before Refinement: Learn from Past Refactorings
// 1. Search for similar refactoring patterns
const similarRefactorings = await reasoningBank.searchPatterns({
task: 'refinement: ' + currentTask.description,
k: 5,
minReward: 0.85
});
if (similarRefactorings.length > 0) {
console.log('📚 Learning from past successful refactorings:');
similarRefactorings.forEach(pattern => {
console.log(`- ${pattern.task}: ${pattern.reward} quality improvement`);
console.log(` Optimization: ${pattern.critique}`);
// Apply proven refactoring patterns
// Reuse successful test strategies
// Adopt validated optimization techniques
});
}
…During Refinement: GNN-Enhanced Code Pattern Search
// Build graph of code dependencies
const codeGraph = {
nodes: [authModule, userService, database, cache, validator],
edges: [[0, 1], [1, 2], [1, 3], [0, 4]], // Code dependencies
edgeWeights: [0.95, 0.90, 0.85, 0.80],
nodeLabels: ['Auth', 'UserService', 'DB', 'Cache', 'Validator']
};
// GNN-enhanced search for similar code patterns (+12.4% accuracy)
const relevantPatterns = await agentDB.gnnEnhancedSearch(
codeEmbedding,
{
k: 10,
graphContext: codeGraph,
gnnLayers: 3
}
);
…After Refinement: Store Learning Patterns with Metrics
// Run tests and collect metrics
const testResults = await runTestSuite();
const codeMetrics = analyzeCodeQuality();
// Calculate refinement quality
const refinementQuality = {
testCoverage: testResults.coverage,
testsPass: testResults.allPassed,
codeComplexity: codeMetrics.cyclomaticComplexity,
performanceImprovement: codeMetrics.performanceDelta,
maintainabilityIndex: codeMetrics.maintainability
};
// Store refinement pattern for future learning
await reasoningBank.storePattern({
sessionId: `refine-${Date.now()}`,
task: 'refinement: ' + taskDescription,
input: initialCodeState,
…🧪 Test-Driven Refinement with Learning
Red-Green-Refactor with Pattern Memory
// RED: Write failing test
describe('AuthService', () => {
it('should lock account after 5 failed attempts', async () => {
// Check for similar test patterns
const similarTests = await reasoningBank.searchPatterns({
task: 'test: account lockout',
k: 3,
minReward: 0.9
});
// Apply proven test patterns
for (let i = 0; i < 5; i++) {
await expect(service.login(wrongCredentials))
.rejects.toThrow('Invalid credentials');
}
await expect(service.login(wrongCredentials))
.rejects.toThrow('Account locked');
…Performance Optimization with Flash Attention
// Use Flash Attention for processing large test suites
if (testCaseCount > 1000) {
const testAnalysis = await agentDB.flashAttention(
testQuery,
testCaseEmbeddings,
testCaseEmbeddings
);
console.log(`Analyzed ${testCaseCount} test cases in ${testAnalysis.executionTimeMs}ms`);
console.log(`Identified ${testAnalysis.relevantTests} relevant tests`);
}📊 Continuous Improvement Metrics
Track Refinement Progress Over Time
// Analyze refinement improvement trends
const stats = await reasoningBank.getPatternStats({
task: 'refinement',
k: 20
});
console.log(`Average test coverage trend: ${stats.avgReward * 100}%`);
console.log(`Success rate: ${stats.successRate}%`);
console.log(`Common improvement areas: ${stats.commonCritiques}`);
// Weekly improvement analysis
const weeklyImprovement = calculateImprovement(stats);
console.log(`Refinement quality improved by ${weeklyImprovement}% this week`);⚡ Performance Examples
Before: Traditional refinement
// Manual code review
// Ad-hoc testing
// No pattern reuse
// Time: ~3 hours
// Coverage: ~70%After: Self-learning refinement (v3.0.0-alpha.1)
// 1. Learn from past refactorings (avoid known pitfalls)
// 2. GNN finds similar code patterns (+12.4% accuracy)
// 3. Flash Attention for large test suites (4-7x faster)
// 4. ReasoningBank suggests proven optimizations
// Time: ~1 hour, Coverage: ~90%, Quality: +35%🎯 SPARC-Specific Refinement Optimizations
Cross-Phase Test Alignment
// Coordinate tests with specification requirements
const coordinator = new AttentionCoordinator(attentionService);
const testAlignment = await coordinator.coordinateAgents(
[specificationRequirements, implementedFeatures, testCases],
'multi-head' // Multi-perspective validation
);
console.log(`Tests aligned with requirements: ${testAlignment.consensus}`);
console.log(`Coverage gaps: ${testAlignment.gaps}`);SPARC Refinement Phase
The Refinement phase ensures code quality through:
- Test-Driven Development (TDD)
- Code optimization and refactoring
- Performance tuning
- Error handling improvement
- Documentation enhancement
Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Refinement by spencermarx?
Refinement by spencermarx is a subagent for Claude Code and Claude Cowork from the spencermarx/open-code-review repository on GitHub. SPARC Refinement phase specialist for iterative improvement with self-learning
How do I install Refinement by spencermarx in Claude Code?
Download refinement.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.
Can I use Refinement by spencermarx in Claude Cowork?
Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.
Is Refinement by spencermarx safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Ml Developer ML developer with self-learning hyperparameter optimization and pattern recognition Subagent · spencermarx/open-code-review
- Mobile Dev Expert agent for React Native mobile application development across iOS and Android Subagent · spencermarx/open-code-review
- Multi Repo Swarm Cross-repository swarm orchestration for organization-wide automation and intelligent collaboration Subagent · spencermarx/open-code-review
- OCR: Address Feedback Address code review feedback — corroborate, validate, and implement changes from a review's final.md. Slash Command · spencermarx/open-code-review
- Release Manager Automated release coordination and deployment with ruv-swarm orchestration for seamless version management, testing, and deployment across multiple packages Subagent · spencermarx/open-code-review
- Pseudocode SPARC Pseudocode phase specialist for algorithm design with self-learning Subagent · spencermarx/open-code-review
- Release Swarm Orchestrate complex software releases using AI swarms that handle everything from changelog generation to multi-platform deployment Subagent · spencermarx/open-code-review
- Project Board Sync Synchronize AI swarms with GitHub Projects for visual task management, progress tracking, and team coordination Subagent · spencermarx/open-code-review