home/roleplay/pure-functions-instructions

Pure Functions.instructions

GPTClaudeGemini··684 copies·updated 2026-07-14
pure-functions-instructions.prompt
# Pure Functions Instructions

## Overview

**Pure functions are the foundation of predictable, testable, and maintainable code.** This guide establishes patterns for writing pure functions throughout this application.

### What is a Pure Function?

A pure function is a function that:

1. **Deterministic**: Given the same input, always returns the same output
2. **No side effects**: Doesn't modify external state, perform I/O, or cause observable changes
3. **No external dependencies**: Doesn't read mutable external state

### Why Pure Functions?

- **Testability** - Easy to test without mocks, setup, or teardown
- **Predictability** - Behavior is guaranteed by inputs alone
- **Reusability** - Can be used anywhere without context dependencies
- **Composability** - Pure functions combine elegantly
- **Debugging** - Easier to reason about and trace issues
- **Parallelization** - Safe to run concurrently
- **Memoization** - Results can be cached reliably

### The Golden Rule

**Default to purity.** Make functions pure unless side effects are explicitly necessary.

## Core Principles

### The Three Rules

#### 1. Same Input → Same Output

when to use it

Community prompt sourced from the open-source GitHub repo sethdavis512/prompt-bucket (no explicit license). A "Pure Functions.instructions" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

sethdavis512/prompt-bucket · no explicit license