Agent skill
refactor-simplify-branching
[Code Quality] Simplifies complex conditionals: deep nesting, long if-else chains, switch sprawl. Use when control flow is hard to follow or has high cyclomatic complexity.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/refactor-simplify-branching
SKILL.md
Refactor: Simplify Branching
Reduce conditional complexity for better readability.
Techniques
1. Guard Clauses (Early Return)
Replace deep nesting with flat guards.
2. Replace Conditionals with Polymorphism
Use protocol dispatch instead of type checking.
3. Replace Nested Conditionals with Table
Use lookup tables for multi-dimensional conditions.
4. Decompose Compound Conditionals
Extract complex conditions to named variables or methods.
5. Replace Flag Arguments
Create separate methods instead of boolean flags.
Warning Signs
- Nesting > 3 levels deep
- More than 3 else-if branches
- Switch with > 5 cases
- Condition spans multiple lines
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?