> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runflow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompts Management

> Manage prompt templates with full CRUD operations using rf prompts

The `rf prompts` command provides complete CRUD (Create, Read, Update, Delete) operations for managing prompt templates. Supports both interactive mode with editor integration and non-interactive mode for automation.

## Commands Overview

| Command                           | Description                                 |
| --------------------------------- | ------------------------------------------- |
| `rf prompts list`                 | List all prompt templates                   |
| `rf prompts get <name>`           | View prompt content                         |
| `rf prompts create <name>`        | Create new prompt (interactive editor)      |
| `rf prompts update <name>`        | Update existing prompt (interactive editor) |
| `rf prompts delete <name>`        | Delete prompt                               |
| `rf prompts render <name> <vars>` | Render prompt with variables                |

## Listing Prompts

```bash theme={null}
# Interactive mode - shows menu
rf prompts

# List all prompts
rf prompts list

# Output:
# Available prompts:
# • system-prompt
# • customer-support
# • feedback-analyzer
# • onboarding-assistant
```

## Getting Prompt Content

```bash theme={null}
# View specific prompt
rf prompts get system-prompt

# Output:
# Prompt: system-prompt
# ---
# You are a helpful AI assistant.
# Your goal is to help users with their questions.
# Always be polite and professional.
```

## Creating Prompts

### Interactive Mode (Default)

Opens your default editor for content input:

```bash theme={null}
rf prompts create support-bot
# → Opens editor (vim, nano, vscode, etc.)
# → Enter your prompt content
# → Save and close
# ✓ Prompt 'support-bot' created
```

### Non-Interactive Mode

Perfect for scripts, CI/CD, and AI tools:

```bash theme={null}
# With inline content
rf prompts create support-bot --content "You are a helpful support assistant"

# From file
rf prompts create support-bot --file ./prompts/support.txt

# Multi-line content
rf prompts create support-bot --content "You are a support assistant.
Always be helpful and polite.
Provide clear and concise answers."
```

### Options

| Option             | Alias | Description                      |
| ------------------ | ----- | -------------------------------- |
| `--content <text>` | `-c`  | Prompt content (non-interactive) |
| `--file <path>`    | `-f`  | Read content from file           |

## Updating Prompts

### Interactive Mode (Default)

Opens editor with current content:

```bash theme={null}
rf prompts update support-bot
# → Opens editor with existing content
# → Make your changes
# → Save and close
# ✓ Prompt 'support-bot' updated
```

### Non-Interactive Mode

```bash theme={null}
# Update with new content
rf prompts update support-bot --content "Updated prompt content"

# Update from file
rf prompts update support-bot --file ./prompts/support-v2.txt
```

## Deleting Prompts

```bash theme={null}
# With confirmation
rf prompts delete support-bot
# ? Are you sure you want to delete prompt 'support-bot'? (y/N)

# Skip confirmation
rf prompts delete support-bot --yes
rf prompts delete support-bot -y

# Alternative alias
rf prompt delete old-prompt --yes
```

## Rendering Prompts with Variables

If your prompts use template variables, you can test rendering:

```bash theme={null}
# Render with variables (JSON format)
rf prompts render welcome-email '{"name": "John", "company": "ACME"}'

# Output:
# Welcome to ACME, John!
# We're excited to have you on board...
```

**Example prompt with variables:**

```
Hello {{name}},

Welcome to {{company}}! We're thrilled to have you join us.

Best regards,
The {{company}} Team
```

## Prompt Templates Examples

### System Prompt

```bash theme={null}
rf prompts create system --content "You are a helpful AI assistant powered by RunFlow.

Your capabilities:
- Answer questions accurately
- Provide code examples
- Explain complex concepts simply
- Always be professional and helpful

Guidelines:
- Be concise but thorough
- Ask clarifying questions when needed
- Admit when you don't know something"
```

### Customer Support

```bash theme={null}
rf prompts create support --content "You are a customer support assistant for {{company}}.

Your role:
- Help customers resolve issues
- Answer product questions
- Escalate complex issues to human agents

Tone:
- Friendly and empathetic
- Professional and clear
- Patient and understanding

Always:
1. Greet the customer warmly
2. Listen to their concern
3. Provide step-by-step solutions
4. Ask if they need further help"
```

### RAG (Knowledge Base) Prompt

```bash theme={null}
rf prompts create rag-assistant --content "You are a knowledge base assistant.

Context from knowledge base:
{{context}}

User question:
{{question}}

Instructions:
- Answer based ONLY on the provided context
- If the answer isn't in the context, say 'I don't have that information'
- Cite sources when possible
- Be accurate and concise"
```

### Code Review Assistant

```bash theme={null}
rf prompts create code-review --file ./prompts/code-review.txt
```

**File: `prompts/code-review.txt`**

```
You are a senior software engineer reviewing code.

Review the following code and provide feedback on:
1. Code quality and best practices
2. Potential bugs or issues
3. Performance optimizations
4. Security concerns
5. Readability and maintainability

Be constructive and specific in your feedback.

Code to review:
{{code}}
```

## Using with AI Tools

Non-interactive mode is designed for AI coding assistants:

```bash theme={null}
# Cursor / Copilot can execute these directly
rf prompts create assistant --content "You are a helpful assistant"
rf prompts update assistant --content "Updated instructions"
rf prompts delete old-prompt --yes
```

## Automation & Scripts

Use in bash scripts or CI/CD:

```bash theme={null}
#!/bin/bash

# Deploy multiple prompts
prompts_dir="./prompts"

for file in "$prompts_dir"/*.txt; do
  name=$(basename "$file" .txt)
  rf prompts create "$name" --file "$file"
done

# Backup existing prompts
rf prompts list | while read -r prompt; do
  rf prompts get "$prompt" > "backups/$prompt.txt"
done
```

## Integration with Agents

Prompts are typically used in your agent code:

```typescript theme={null}
import { Agent } from '@runflow-ai/core';

const agent = new Agent({
  name: 'Support Bot',
  instructions: await getPrompt('customer-support'), // Load from prompts
  model: 'gpt-4',
  // ... other config
});
```

## Best Practices

### 1. Use Descriptive Names

```bash theme={null}
# ✅ Good - clear purpose
rf prompts create customer-support-v2
rf prompts create rag-retrieval-prompt
rf prompts create sales-qualification

# ❌ Avoid - unclear names
rf prompts create prompt1
rf prompts create test
rf prompts create x
```

### 2. Version Your Prompts

```bash theme={null}
rf prompts create support-bot-v1
rf prompts create support-bot-v2
rf prompts create support-bot-v3

# Keep old versions for rollback
rf prompts get support-bot-v1 > backup/support-v1.txt
```

### 3. Use Files for Complex Prompts

```bash theme={null}
# For long, complex prompts
rf prompts create complex-assistant --file ./prompts/complex.txt

# Easier to:
# - Edit in your IDE
# - Version control
# - Review changes
```

### 4. Template Variables

Use consistent variable naming:

```bash theme={null}
# Use lowercase with underscores
{{user_name}}
{{company_name}}
{{context}}

# Or camelCase
{{userName}}
{{companyName}}
{{contextData}}
```

## Common Patterns

### Environment-Specific Prompts

```bash theme={null}
# Development prompts
rf switch dev
rf prompts create system --content "Development mode prompt..."

# Production prompts
rf switch prod
rf prompts create system --content "Production mode prompt..."
```

### Prompt Library Management

```bash theme={null}
# Export all prompts
mkdir prompt-library
rf prompts list | while read name; do
  rf prompts get "$name" > "prompt-library/$name.txt"
done

# Import prompts to new environment
for file in prompt-library/*.txt; do
  name=$(basename "$file" .txt)
  rf prompts create "$name" --file "$file"
done
```

## Troubleshooting

### Prompt Already Exists

```bash theme={null}
rf prompts create existing-prompt --content "..."
# Error: Prompt 'existing-prompt' already exists
```

**Solution:** Use update instead or delete first:

```bash theme={null}
rf prompts update existing-prompt --content "..."
# OR
rf prompts delete existing-prompt --yes
rf prompts create existing-prompt --content "..."
```

### Editor Not Opening (Interactive Mode)

If the editor doesn't open:

```bash theme={null}
# Set your preferred editor
export EDITOR=nano
rf prompts create my-prompt

# Or use non-interactive mode
rf prompts create my-prompt --content "Your content here"
```

### File Not Found

```bash theme={null}
rf prompts create test --file ./prompts/missing.txt
# Error: File not found: ./prompts/missing.txt
```

**Solution:** Check the file path:

```bash theme={null}
ls -la ./prompts/missing.txt
# Use correct path
rf prompts create test --file ./correct-path/file.txt
```

## Aliases

You can use singular or plural form:

```bash theme={null}
rf prompt list      # Same as rf prompts list
rf prompt create    # Same as rf prompts create
rf prompt delete    # Same as rf prompts delete
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Agents" icon="robot" href="/cli/agents">
    Use prompts in your agents
  </Card>

  <Card title="Create Agent" icon="plus" href="/cli/create">
    Create agent with custom prompts
  </Card>

  <Card title="Knowledge Base" icon="database" href="/cli/kb">
    Combine prompts with RAG
  </Card>

  <Card title="Test" icon="flask" href="/cli/test">
    Test prompt changes locally
  </Card>
</CardGroup>
