compact-guard-clauses
Installation
SKILL.md
Compact Guard Clauses (Early-Return Pattern)
Overview
Default AI code generation often falls into the "Pyramid of Doom" anti-pattern: nesting execution logic 4 to 6 levels deep inside cascading if/else checks ("if user exists $\rightarrow$ if authorized $\rightarrow$ if has active plan $\rightarrow$ if payment valid...").
Deeply nested code increases cyclomatic complexity, wastes 2 to 6 tokens per line on leading indentation whitespace, and creates cognitive fatigue during subsequent code reviews and diff patching.
The Compact Guard Clause Protocol (also known as the Bouncer Pattern) checks for failure conditions at the very top of the function and returns/raises immediately, allowing the primary "happy path" to execute unnested at root indentation.