code-philosophy

Apply guard clauses and boundary parsing to prevent illegal states in code.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/dmooney/Rundale --skill code-philosophy-dmooney
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-philosophy
Source: https://github.com/dmooney/Rundale/tree/main/.opencode/skills/code-philosophy
Command: npx skills add https://github.com/dmooney/Rundale --skill code-philosophy-dmooney

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps engineers write internal logic and data flow that avoids hidden edge cases, prevents illegal states from slipping into core algorithms, and produces clearer failures instead of ambiguous behavior.

Core Features & Use Cases

  • Early guard clauses: Handle invalid inputs and edge cases immediately to keep control flow shallow and readable (e.g., quickly rejecting missing or malformed request state).
  • Make illegal states unrepresentable: Parse and structure data at boundaries so internal logic can trust typed, validated state (e.g., converting raw payloads into a safe domain model once).
  • Atomic predictability: Design functions so they behave consistently for the same inputs, minimizing hidden mutations (e.g., returning new derived state instead of mutating globals).
  • Fail fast, fail loud: Throw descriptive errors when state is invalid rather than attempting to patch corrupted scenarios (e.g., stopping execution with clear diagnostics).
  • Intentional naming: Use expressive names so the code reads like an unambiguous English sentence (e.g., naming booleans and predicates clearly to reflect intent).

Quick Start

Ask an AI to review a specific function or module against the 5 laws by identifying where to add guard clauses, where to parse at boundaries, and what invalid states should trigger descriptive errors.

Frequently Asked Questions about code-philosophy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent illegal states from reaching core algorithms in my code?

Prevent illegal states by parsing raw payloads into trusted typed state at boundaries, applying early guard clauses to reject invalid inputs, and using predictable pure functions to keep core logic clean.

What is the best way to handle edge cases and invalid inputs in backend modules?

The best way to handle edge cases is using early guard clauses for shallow control flow and throwing descriptive fail-fast errors when state is invalid, ensuring backend modules produce clear failures instead of ambiguous behavior.

How can I make my code more readable and defensible using pure functions?

Make code readable and defensible by designing atomic predictable functions that return new derived state instead of mutating globals, and applying intent-revealing names so predicates read like unambiguous English sentences.

Why should I parse raw data payloads at the boundaries of frontend and backend modules?

Parse raw data payloads at boundaries to make illegal states unrepresentable, allowing internal logic to safely trust validated typed state without repeatedly checking for malformed request state.

Does this defensive programming approach work for both state management and business logic?

Yes, this defensive programming approach works across state management and business logic by requiring boundary parsing, shallow guard clauses, and fail-fast descriptive errors wherever correctness and clarity matter.