Skip to content

Prompts

Ralph uses a built-in-first layered prompt architecture. All prompt content lives in ralph’s package code and is assembled at runtime. Users extend the built-in content through optional files in docs/prompts/ — these are appended to (not replacements for) the built-in content.

The prompt is split into layers to maximize API cache hits and reduce token waste. Each layer has a built-in component from ralph’s code and an optional user extension:

LayerBuilt-in ContentUser Extension FileStability
SystemTDD methodology, tool usage rules, roles, quality gatesdocs/prompts/system.mdStable across all iterations (cacheable)
MethodologyRalph Methodology referencedocs/prompts/methodology.mdStable across all iterations (cacheable)
Roles9 built-in role definitions and participation rulesdocs/prompts/roles.mdStable across all iterations (cacheable)
ProjectConfig values, file naming, quality commandsStable across iterations (cacheable)
Rulesdocs/prompts/rules.mdStable across iterations (cacheable)
CodebaseAuto-generated file/export indexChanges only when files are added/removed
TaskTask description, PRD section content, touches, hintsChanges per task
RetryPrevious failure contextOnly present on retries

For agents that support --system-prompt (or equivalent), the System, Methodology, Roles, Project, and Rules layers are passed as the system prompt. The remaining layers are passed as the user prompt. This maximizes prompt caching at the API level.

For each prompt layer, ralph assembles the effective content as:

effective_content = built_in_content() + user_extension_content()

If a user extension file does not exist, the built-in content is used alone. Extension content is appended after the built-in content, separated by a --- Project Extensions --- marker.

This means ralph works with zero user-authored prompt files — docs/prompts/rules.md (created by ralph init) is the only prompt file that exists by default.

Ralph replaces {{variable}} placeholders before sending the prompt. Template variables work in both built-in templates and user extension files:

VariableValue
{{task.id}}Task ID (e.g., T-005)
{{task.title}}Task title
{{task.description}}Task description
{{task.prdReference}}PRD section reference (e.g., §3.2)
{{task.prdContent}}Extracted PRD section content
{{task.touches}}Comma-separated file paths from Touches field
{{task.hints}}Content of the task’s Hints section
{{config.language}}Project language
{{config.packageManager}}Package manager
{{config.testingFramework}}Testing framework
{{config.qualityCheck}}Quality check command
{{config.testCommand}}Test command
{{config.fileNaming}}File naming convention
{{project.rules}}Contents of docs/prompts/rules.md
{{codebaseIndex}}Auto-generated file/export index
{{retryContext}}Context from a previous failed attempt

Use ralph show to inspect effective prompt content:

Terminal window
ralph show system-prompt # Built-in + extensions
ralph show boot-prompt # Built-in + extensions
ralph show methodology # Built-in + extensions
ralph show rules # Project rules
ralph show task T-042 # Effective task content
# See only built-in content
ralph show system-prompt --built-in-only

See the Customizing Prompts guide for details on creating extension files, adding custom roles, and overriding built-in content.