return-early-pattern

Installation
SKILL.md

Use guard clauses to handle edge cases and failure conditions at the top of a function. Return immediately rather than nesting the happy path inside conditionals.

Good:

function process(data):
    if data is null: return
    if not data.is_valid(): return
    return do_work(data)

Bad:

function process(data):
    if data is not null:
        if data.is_valid():
            return do_work(data)

Apply this pattern where it genuinely makes the code cleaner — functions with clear precondition checks (null references, invalid parameters, boundary conditions) followed by main business logic as the happy path.

Installs
15
First Seen
Apr 8, 2026
return-early-pattern — gkwa/volcanicviper