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
1---2name: complexity-guardrails3description: Complexity Guardrails4---5# Complexity Guardrails67Design to keep complexity low from day one.89## Targets1011- Cyclomatic complexity per function ≤ 7 (start splitting at 5)12- Function length ≤ 80 lines (aim for ≤ 30)13- One responsibility per function; one axis of variation per module1415## Tactics1617- Use early returns and guard clauses; avoid deep nesting18- Extract branch bodies into named helpers19- Replace long if/else/switch with tables (maps) or strategies20- Separate phases: parse → validate → normalize → act2122## Signs to refactor now2324- Hard-to-test code paths25- Repeated conditionals with subtle differences26- Mixed concerns (IO, validation, transformation) in one method
Run npx skillmds@latest add comeonoliver/complexity-guardrails in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Complexity Guardrails It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.