Use during REFACTOR phase of TDD or when code duplication is suspected. Defines search-first workflow and safe refactoring practices.
/plugin marketplace add craigtkhill/stdd-agents/plugin install stdd-agents@stdd-agentsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
FILE-ORGANIZATION.mdRUST.mdThis skill provides detailed guidance for the REFACTOR phase of the RED-GREEN-REFACTOR cycle in Test-Driven Development.
When to use this skill:
Before writing new code, always ask:
CRITICAL: Always search before implementing new functionality
Use code search tools to find:
Search strategies:
When similar code is found, evaluate:
Questions to ask:
Red flags for duplication:
Based on the duplication analysis, choose appropriate strategy:
1. Extract Function/Method
2. Parameterize Function
3. Extract Common Interface/Trait
4. Introduce Abstraction Layer
5. Use Existing Abstraction
6. Keep Duplication
Safety rules for refactoring:
All tests must be GREEN before starting
Make small, incremental changes
Run ALL tests after each change
If tests fail, revert immediately
Keep refactoring separate from feature work
After refactoring:
Verification checklist:
Documentation:
Problem: Creating abstractions before understanding the pattern Solution: Follow "rule of three" - wait until duplication appears 3 times
Problem: Creating overly complex abstractions for simple duplication Solution: Keep refactoring simple and focused
Problem: Exposing internals to reduce duplication Solution: Sometimes duplication is better than bad coupling
Problem: Changing too much at once Solution: Small, incremental changes with test verification
Problem: Changing code without safety net Solution: Write tests first if they don't exist
Skip refactoring when:
Refactoring is Step 4 in the RED-GREEN-REFACTOR cycle:
When implementing new features:
For guidance on splitting large files into modules: See FILE-ORGANIZATION.md for guidelines on when and how to split files.
Before writing new code:
During refactoring:
After refactoring:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.