home/roleplay/prompt-element-system

PROMPT ELEMENT SYSTEM

GPTClaudeGemini··965 copies·updated 2026-07-14
prompt-element-system.prompt
# Prompt Element System Architecture

**Date:** 2025-10-07
**Status:** Implemented
**Related Files:** `src/langtree/templates/prompt_*.py`, `src/langtree/templates/element_resolution.py`

---

## Overview

The Prompt Element System is the core architecture for prompt generation in LangTree DSL. It represents prompts as structured lists of typed elements (titles, text, templates) that can be parsed from markdown, manipulated programmatically, and serialized back to markdown with proper heading level management.

This architecture replaced the previous string-based approach with a structured, type-safe system that enables:
- ✅ Automatic heading level alignment
- ✅ Template variable resolution with context awareness
- ✅ Hierarchical prompt assembly from leaf to root
- ✅ Proper nesting and hierarchy preservation

---

## Core Concepts

### PromptElement

Base class for all prompt components. Every piece of a prompt is represented as a `PromptElement`.

**Types of PromptElements:**
1. **PromptTitle** - Markdown headings (`#`, `##`, `###`, etc.)
2. **PromptText** - Plain text content
3. **PromptTemplate** - Template variables (`{PROMPT_SUBTREE}`, `{COLLECTED_CONTEXT}`)

**Common Attributes:**

fill the variables

This prompt has 2 variables. Pro fills them into a ready-to-paste prompt for you — no manual find-and-replace.

{PROMPT_SUBTREE}{COLLECTED_CONTEXT}
Unlock with Pro →

when to use it

Community prompt sourced from the open-source GitHub repo ac8ai/langtree (MIT). A "PROMPT ELEMENT SYSTEM" 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

ac8ai/langtree · MIT