Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component...
npx skills add noartem/skills --skill "complexity-guardrails"
Install specific skill from multi-skill repository
# Description
Keep cyclomatic complexity low; flatten control flow, extract helpers, and prefer table-driven/strategy patterns over large switches
# SKILL.md
name: complexity-guardrails
description: Keep cyclomatic complexity low; flatten control flow, extract helpers, and prefer table-driven/strategy patterns over large switches
Complexity Guardrails
Design to keep complexity low from day one.
Targets
- Cyclomatic complexity per function β€ 7 (start splitting at 5)
- Function length β€ 80 lines (aim for β€ 30)
- One responsibility per function; one axis of variation per module
Tactics
- Use early returns and guard clauses; avoid deep nesting
- Extract branch bodies into named helpers
- Replace long if/else/switch with tables (maps) or strategies
- Separate phases: parse β validate β normalize β act
Signs to refactor now
- Hard-to-test code paths
- Repeated conditionals with subtle differences
- Mixed concerns (IO, validation, transformation) in one method
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.