feature-refactor

A guided workflow for refactoring an existing feature in stages. It first studies the current code, documentation, dependencies, execution paths, and tests before planning changes.

In plain words
What is it for?
Exploring a feature, mapping its architecture and integration points, breaking the refactor into small phases, making incremental changes, and reviewing the results with multiple agents.
Why use it?
It reduces the risk of duplicating existing behavior, missing edge cases, or making broad refactoring changes without understanding the feature.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/ronileor/specweaver/feature-refactor
Clone the repo
git clone --depth 1 https://github.com/RoniLeor/specWeaver
Per session 24 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 7,430 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00024 $0.07430
Opus 5 $0.00012 $0.03715
Sonnet 5 $0.00005 $0.01486
Haiku 4.5 $0.00002 $0.00743

Measured 2d ago against content hash 107281add14c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

feature-refactor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/specweaver/commands/feature-refactor.md · 1,079 lines

How it starts

The opening of the file, as written. The whole thing — 1,079 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are orchestrating a comprehensive feature refactoring workflow with multi-agent collaboration. Follow this structured process:

Core Principle

⚠️ CRITICAL: Read the code carefully before designing new solutions - the existing implementation often already handles edge cases. Understanding what's already there prevents duplicate solutions and unnecessary complexity.

Phase 0: Feature Understanding (Parallel Analysis)

IMPORTANT: Execute BOTH analyses in PARALLEL (single message with 2 Task tool calls) for maximum efficiency.

Step 0.1: Launch Parallel Understanding Agents

Execute in PARALLEL:

Analysis 1: Code Exploration (code-explorer)

Use the Task tool with subagent_type=code-explorer to deeply understand the existing feature: $ARGUMENTS

The code-explorer should:

  • Find ALL files related to this feature (entry points, core logic, utilities, tests)
  • Trace execution paths from entry to data storage
  • Map architecture layers (presentation, business logic, data)
  • Identify design patterns and abstractions currently in use
  • Document all dependencies (internal and external)
  • Find integration points with other features
  • Note any technical debt or improvement areas
  • List ALL essential files for understanding this feature

Analysis 2: Documentation Review (code-consolidator)

Use the Task tool with subagent_type=code-consolidator to find and analyze documentation for: $ARGUMENTS

The code-consolidator should:

  • Search /docs for any documentation about this feature
  • Identify documentation location(s) if exists
  • Read and summarize existing documentation
  • Note any gaps in documentation
  • Identify related documentation that might need updates
  • Check if documentation matches current implementation
  • Flag any outdated or incorrect documentation

Step 0.2: Create Understanding Report

After BOTH agents complete, synthesize findings:

Create: .claude/specs/refactor-{feature-name}/01-understanding.md

# Feature Understanding: {feature-name}

**Analysis Date**: {date}
**Refactor Request**: {$ARGUMENTS}

## Code Analysis (code-explorer findings)

### Feature Entry Points
- [Entry point 1: file:line]
- [Entry point 2: file:line]
- ...

### Core Implementation
- [Core file 1: purpose and responsibilities]
- [Core file 2: purpose and responsibilities]
- ...

### Architecture Layers
- **Presentation Layer**: [files and responsibilities]
- **Business Logic Layer**: [files and responsibilities]
- **Data Layer**: [files and responsibilities]

### Design Patterns Used
- [Pattern 1: where and how it's used]
- [Pattern 2: where and how it's used]
- ...

### Dependencies
- **Internal**: [other features this depends on]
- **External**: [libraries, frameworks, APIs]

### Integration Points
- [Feature 1: how they integrate]
- [Feature 2: how they integrate]
- ...

### Technical Debt / Issues
- [Issue 1: description and location]
- [Issue 2: description and location]
- ...

### Essential Files
[Complete list with brief descriptions]

## Documentation Analysis (code-consolidator findings)

### Existing Documentation
- **Location**: [file path(s) in /docs]
- **Content Summary**: [what's documented]
- **Last Updated**: [if available]

### Documentation Gaps
- [Gap 1: what's not documented]
- [Gap 2: what's missing]
- ...

### Outdated Information
- [Outdated 1: what needs updating]
- [Outdated 2: discrepancy with code]
- ...

### Related Documentation
- [Related doc 1: why it's relevant]
- [Related doc 2: connection to this feature]
- ...

## Understanding Summary

### What This Feature Does
[Clear description of feature's purpose and behavior]

### How It Works
[High-level explanation of implementation approach]

### Current State Assessment
- **Code Quality**: [assessment]
- **Documentation Quality**: [assessment]
- **Maintainability**: [assessment]
- **Technical Debt Level**: [assessment]

Read the full file on GitHub · 1,079 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 1,079 lines · 24 tokens per session scan A 107281add14c

Subscribe to this mod's changes

feature-refactor is a command published in the GitHub repository RoniLeor/specWeaver (3 stars, last pushed 10mo ago), licensed MIT. It adds 24 tokens to every session and 7,430 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.