Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
jimmc414 avatar

Validate Before Process

  • 1 installs
  • 4 repo stars
  • Updated August 3, 2026
  • jimmc414/claude-code-plugin-marketplace

Applies an input-validation pattern that checks format and constraints before processing and fails fast with clear errors.

About

Encodes a defensive validate-before-process pattern that checks input structure early and raises clear errors instead of allowing silent corruption. A developer uses it when accepting external input or building robust parsers.

  • Fail-fast validation with predicate helpers and clear messages
  • Python examples from grid/formula/lispy parsing

Validate Before Process by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #981 of 1,354 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/jimmc414/claude-code-plugin-marketplace --skill validate-before-process

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars4
Last updatedAugust 3, 2026
Repositoryjimmc414/claude-code-plugin-marketplace

What it does

Applies an input-validation pattern that checks format and constraints before processing and fails fast with clear errors.

Files

SKILL.mdMarkdownGitHub ↗

validate-before-process

When to Use

  • Accepting external/user input
  • File format must be exact
  • Early failure is better than silent corruption
  • Building robust parsers

When NOT to Use

  • Trusted internal data
  • Validation overhead too high
  • Best-effort processing is acceptable

The Pattern

Validate input structure before processing, with clear error messages.

def parse_grid(grid_string):
    """Parse and validate a grid."""
    lines = grid_string.strip().split('\n')

    # Validate structure
    if not lines:
        raise ValueError("Empty grid")

    width = len(lines[0])
    for i, line in enumerate(lines):
        if len(line) != width:
            raise ValueError(f"Line {i} has wrong width: {len(line)} != {width}")

    # Now safe to process
    return [[c for c in line] for line in lines]

def validate(data, predicate, message):
    """Validate data with predicate, raise with message if fails."""
    if not predicate(data):
        raise ValueError(f"{message}: {data}")
    return data

Example (from pytudes)

# Grid validation (sudoku.py)
def grid_values(grid):
    """Convert grid into a dict of {square: char}."""
    chars = [c for c in grid if c in digits or c in '0.']

    # Validate length
    if len(chars) != 81:
        print(grid, chars, len(chars))
    assert len(chars) == 81, f"Expected 81 chars, got {len(chars)}"

    return dict(zip(squares, chars))

# Formula validation (Cryptarithmetic.ipynb)
def valid(pformula):
    """A formula is valid iff it has no leading zero and evaluates to True."""
    try:
        return (not leading_zero(pformula)) and (eval(pformula) is True)
    except ArithmeticError:
        return False

leading_zero = re.compile(r'\b0[0-9]').search

# Number of letters check
def translate_formula(formula):
    letters = all_letters(formula)
    assert len(letters) <= 10, f'{len(letters)} letters is too many; only 10 allowed'
    ...

# Lispy require function (lispy.py)
def require(x, predicate, msg="wrong length"):
    """Signal a syntax error if predicate is false."""
    if not predicate:
        raise SyntaxError(to_string(x) + ': ' + msg)

# Usage in parsing
def expand(x):
    require(x, x != [])  # Empty list is error
    if x[0] is _quote:
        require(x, len(x) == 2)  # quote needs exactly 2 elements
        return x

Key Principles

1. Fail fast: Check early, before processing 2. Clear messages: Say what's wrong and show the data 3. Assert for invariants: Use assert for "should never happen" 4. Raise for input errors: Use exceptions for invalid input 5. Validate at boundaries: Check external input, trust internal data

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.