RECURSIVE PATTERNS
# Recursive Prompt Patterns for ProductionOS
**Research Foundation:** Recursive Language Models (Zhang et al. 2025), ReCAP (Li et al. 2025), Promptbreeder (Fernando et al. 2023), Self-Refine (Madaan et al. 2023), Chain-of-Verification (Dhuliawala et al. 2023), Chain of Density (Adams et al. 2023), Plan-and-Act (Wang et al. 2025)
**Purpose:** Six recursive prompt patterns that extend ProductionOS's existing 16 layers (00-15) and 9-layer composition stack. Each pattern uses self-reference, depth-bounded recursion, and convergence criteria to produce outputs that single-pass prompting cannot achieve.
**Integration:** These become Layers 16-21 in the `prompts/` directory and extend the composition function in `templates/PROMPT-COMPOSITION.md`.
---
## Table of Contents
1. [Pattern 1: Recursive Task Decomposition (Layer 16)](#pattern-1-recursive-task-decomposition)
2. [Pattern 2: Self-Referential Prompt Improvement (Layer 17)](#pattern-2-self-referential-prompt-improvement)
3. [Pattern 3: Recursive Summarization Chain (Layer 18)](#pattern-3-recursive-summarization-chain)
4. [Pattern 4: Recursive Verification Stack (Layer 19)](#pattern-4-recursive-verification-stack)
5. [Pattern 5: Recursive Plan-Execute-Evaluate-Replan (Layer 20)](#pattern-5-recursive-plan-execute-evaluate-replan)
6. [Pattern 6: Recursive Prompt Evolution (Layer 21)](#pattern-6-recursive-prompt-evolution)
7. [Integration with 9-Layer Composition](#integration-with-9-layer-composition)
8. [Updated Application Matrix](#updated-application-matrix)
9. [Cost and Depth Budgets](#cost-and-depth-budgets)
10. [Sources](#sources)
---
## Pattern 1: Recursive Task Decomposition
**Layer 16: RecDecomp**
**Research:** Recursive Language Models (MIT, 2025) — handles prompts 100x longer than base LLMs via recursive sub-invocation
**Impact:** Transforms unbounded tasks into bounded, independently solvable subtasks with guaranteed termination
### Core Idea
The LLM decomposes a task into subtasks, then applies itself recursively to each subtask. Subtasks that are still too complex get decomposed further. Recursion terminates when a subtask is "atomic" -- solvable in a single step without further breakdown.
### Prompt Templatewhen to use it
Community prompt sourced from the open-source GitHub repo ShaheerKhawaja/ProductionOS (MIT). A "RECURSIVE PATTERNS" 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
ShaheerKhawaja/ProductionOS · MIT