HeroPrompt
Back to docs
Prompts

Prompt Variables

Understanding and using dynamic variables in prompts.

Updated 2026-02-15

Prompt Variables

Variables make prompts reusable by acting as placeholders for dynamic content. This guide explains how they work and best practices for using them.

What Are Variables?

Variables use the {{variable_name}} syntax to mark sections you should customize before using the prompt.

Example prompt:

text
Create a {{language}} function that {{task_description}}.
The function should handle {{edge_cases}}.

After replacement:

text
Create a Python function that validates email addresses.
The function should handle empty strings, invalid formats, and internationalized domains.

Variable Types

While all variables use the same {{syntax}}, they typically fall into these categories:

1. Required Context

Essential information the AI needs to complete the task.

Examples:

  • {{programming_language}} — "Python", "JavaScript", "Rust"
  • {{component_name}} — "UserProfile", "PaymentModal"
  • {{database_type}} — "PostgreSQL", "MongoDB"

2. Optional Constraints

Additional requirements that shape the output.

Examples:

  • {{style_guide}} — "Google Style Guide", "Airbnb JavaScript"
  • {{max_length}} — "500 words", "10 lines"
  • {{target_audience}} — "beginners", "senior engineers"

3. Output Format

Specify the expected format of the response.

Examples:

  • {{output_format}} — "JSON", "Markdown table", "bullet points"
  • {{code_style}} — "functional", "object-oriented"
  • {{documentation_style}} — "JSDoc", "Google Docstrings"

Best Practices

Be Specific

Too vague:

text
{{design}} → "modern"

Specific:

text
{{design}} → "minimalist design with rounded corners, soft shadows, and a blue (#2563EB) accent color"

Provide Context

Give the AI enough information to make good decisions:

text
{{feature_list}} →
  - User authentication (OAuth2)
  - Real-time notifications (WebSocket)
  - File upload (max 10MB, images only)
  - Search with filters (by date, category)

Use Structured Inputs

For complex variables, use bullet points or JSON:

text
{{requirements}} →
  - Performance: Sub-100ms response time
  - Security: SQL injection prevention
  - Validation: Email format, password strength
  - Error handling: User-friendly messages

Preserve Original Variables

If copying a prompt into a script or automation tool, you might want to keep the {{variables}} intact for later substitution:

javascript
const promptTemplate = `
Create a {{language}} function that {{task}}.
`;

// Later:
const finalPrompt = promptTemplate
  .replace('{{language}}', 'TypeScript')
  .replace('{{task}}', 'validates user input');

Variable Discovery

Prompts show all variables in the UI:

  • Highlighted in the prompt text
  • Listed below the prompt with descriptions
  • Clickable to jump to that variable in the text

Common Variables

Here are frequent variables and example replacements:

VariableExample Replacement
{{language}}Python, JavaScript, Rust, Go
{{framework}}React, Vue, Django, FastAPI
{{task}}Validate user input, fetch API data
{{style}}Functional, object-oriented, procedural
{{constraints}}Max 100 lines, no external libraries
{{output}}JSON, Markdown, plain text, code
{{complexity}}Beginner-friendly, production-grade
{{best_practices}}SOLID principles, type safety, error handling

Automation with Variables

For repeated use, consider automating variable substitution:

Shell Script Example

bash
#!/bin/bash
prompt=$(cat prompt-template.txt)
prompt=${prompt//\{\{language\}\}/Python}
prompt=${prompt//\{\{task\}\}/validate email}
echo "$prompt" | pbcopy  # Copy to clipboard

Python Example

python
template = """
Create a {{language}} {{component_type}} that {{functionality}}.
"""

variables = {
    "language": "TypeScript",
    "component_type": "React hook",
    "functionality": "manages form state with validation"
}

for key, value in variables.items():
    template = template.replace(f"{{{{{key}}}}}", value)

print(template)

Tips

  • Don't skip variables — Even if optional, replacing them improves results
  • Use examples — Show the AI what you mean with concrete examples
  • Iterate — First pass can be generic, then refine based on output
  • Save common replacements — Keep a personal library of variable values you use often

Next Steps