function-design

Enforce Python function design conventions for signatures, parameters, return types, and async patterns.

Updated Nov 11, 2025
One-click install
npx skills add https://github.com/libertininick/chain-reaction --skill function-design
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: function-design
Source: https://github.com/libertininick/chain-reaction/tree/main/.claude/skills/function-design
Command: npx skills add https://github.com/libertininick/chain-reaction --skill function-design

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill codifies Python function design conventions for this codebase. Apply when writing or reviewing functions including signatures, parameters, return types, and async patterns.

Core Features & Use Cases

  • Explicit dependencies: Pass as parameters, no global state
  • Single Responsibility: One function = one task
  • Pure Functions When Possible: Return new values, don't mutate inputs
  • Guard Clauses: Validate early, return/raise immediately
  • Return Type Stability: Same type regardless of input
  • Exceptions Over None for Errors: Reserve None for "not found" only
  • Command-Query Separation: Action OR data, not both
  • Keep Functions Small and Focused: Composed of focused helpers

Quick Start

Use this skill to review Python functions for adherence to the conventions above. For example, ensure each function has a single responsibility, uses explicit dependencies, and returns a stable type.

Frequently Asked Questions about function-design

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

FAQPage Schema
What are the best practices for clean Python function design?

Clean Python function design requires explicit dependencies, single responsibility, pure functions, and stable return types. You must pass dependencies as parameters, avoid global state, and ensure each function performs one focused task without mutating inputs.

How do I enforce Python coding standards during a code review?

Enforce Python coding standards by validating function signatures, parameter handling, and async patterns. Check for guard clauses to validate early, ensure command-query separation, and confirm functions raise exceptions instead of returning None for errors.

Should I return None or raise an exception for Python function errors?

Raise exceptions for Python function errors and reserve None strictly for "not found" cases. This approach ensures return type stability, meaning your function returns the same type regardless of input, preventing unexpected type errors downstream.

When should I use async patterns in Python function design?

Use async patterns in Python function design when functions involve I/O operations or concurrent tasks. Apply async conventions consistently during code review to ensure clear interfaces and proper argument handling without blocking execution.

How do guard clauses improve Python function signatures?

Guard clauses improve Python functions by validating conditions early and returning or raising immediately. This keeps functions small and focused, preventing deep nesting and ensuring clear interfaces composed of focused helpers.

What is command-query separation in Python code?

Command-query separation in Python code means a function should either perform an action or return data, not both. Following this standard ensures single responsibility, making functions easier to test, review, and compose into larger workflows.