> For the complete documentation index, see [llms.txt](https://docs.meganova.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.meganova.ai/character-studio/advanced/prompt-engineering.md).

# Prompt Engineering

> **Note:** Learn techniques for writing effective character prompts. Improve character quality through better prompt design.

## Overview

Prompt engineering is the art of:

* **Writing** clear instructions for AI
* **Structuring** information effectively
* **Balancing** detail and brevity
* **Testing** and iterating

## Core Principles

### 1. Show, Don't Tell

**Less effective:**

```
Elena is sarcastic.
```

**More effective:**

```
Elena responds to compliments with dry wit, often rolling her eyes
before offering a self-deprecating counter-observation.

Example:
User: "You're so smart!"
Elena: *raises eyebrow* "Smart enough to know that flattery will
get you absolutely nowhere with me. Try again."
```

### 2. Be Specific

**Vague:**

```
Elena is nice to people.
```

**Specific:**

```
Elena shows kindness through actions rather than words—offering help
before it's asked for, remembering small details about people, and
fiercely defending those she cares about.
```

### 3. Use Concrete Examples

Include dialogue examples that demonstrate:

* Speech patterns
* Emotional responses
* Relationship dynamics
* Unique behaviors

### 4. Structure Information

Organize logically:

1. Core identity
2. Personality traits
3. Background
4. Behaviors
5. Speech patterns
6. Relationships

## System Prompt Writing

### Basic Structure

```
You are {{char}}, [brief identity].

Personality:
- [Trait 1]
- [Trait 2]
- [Trait 3]

Background:
[2-3 sentences of relevant history]

Speech:
[How they communicate]

Rules:
- [Behavioral guideline 1]
- [Behavioral guideline 2]
```

### Advanced Structure

```
# Character: {{char}}

## Identity
[Core who they are]

## Personality
[Detailed traits with examples]

## Background
[Relevant history]

## Behavior
### Do:
- [Positive behaviors]

### Don't:
- [Behaviors to avoid]

## Speech Patterns
[How they talk]

## Scenario
[Current context]

## Rules
[Critical instructions]
```

## Effective Techniques

### Positive Framing

**Instead of:**

```
Don't be boring.
```

**Use:**

```
Keep responses engaging with vivid descriptions,
emotional depth, and natural dialogue flow.
```

### Specific Constraints

**Instead of:**

```
Act in character.
```

**Use:**

```
Always respond as {{char}}. Never acknowledge being an AI.
If asked directly, deflect with confusion or humor appropriate
to the character.
```

### Layered Personality

```
Surface: Appears cold and distant to strangers
Beneath: Deeply caring but afraid of vulnerability
Secret: Desperately wants connection but fears rejection

Show surface with strangers, reveal depth over time.
```

### Contextual Reactions

```
Emotional triggers:
- Mentions of family: becomes quiet and changes subject
- Discussions of magic: lights up with enthusiasm
- Perceived insults: responds with sharp wit
- Genuine compliments: deflects but secretly pleased
```

## Example Dialogue Patterns

### Format

```
{{user}}: [User input]
{{char}}: [Character response with actions]
```

### Include Variety

```
# Casual conversation
{{user}}: How's your day going?
{{char}}: *stretches* Could be worse. [continues naturally]

# Emotional moment
{{user}}: I'm feeling really down today.
{{char}}: *expression softens* [empathetic response]

# Challenged/tested
{{user}}: Are you even real?
{{char}}: *tilts head* [in-character deflection]

# Sharing knowledge
{{user}}: Tell me about magic.
{{char}}: *eyes light up* [enthusiastic explanation]
```

## Token Efficiency

### Concise Writing

**Verbose:**

```
Elena is a very wise and intelligent wizard who has lived for many
hundreds of years and has accumulated a vast amount of knowledge
about magical arts and arcane sciences.
```

**Efficient:**

```
Elena is a centuries-old elven wizard whose vast magical knowledge
comes from ages of study and experience.
```

### Priority Information

Put most important info first:

1. Essential personality
2. Core behaviors
3. Speech patterns
4. Background (brief)
5. Edge cases (if room)

## Testing Prompts

### Test Scenarios

1. **First impression**: Does greeting match personality?
2. **Consistency**: Same personality across 10+ exchanges?
3. **Edge cases**: Handles weird inputs well?
4. **Immersion**: Stays in character under pressure?

### Iteration Process

1. Write initial prompt
2. Test with varied inputs
3. Note failures
4. Adjust prompt
5. Repeat until satisfied

## Common Mistakes

### Over-Explanation

❌ Too much:

```
Elena always speaks in a measured tone because she is wise and
has seen many things in her long life and therefore doesn't get
excited easily except when discussing magic which she loves...
```

✅ Better:

```
Elena speaks in measured tones, showing excitement only when
discussing magic.
```

### Contradictions

❌ Contradictory:

```
Elena is very friendly and welcoming.
Elena is cold and distant to everyone.
```

✅ Nuanced:

```
Elena appears cold to strangers but warms considerably to those
who earn her trust.
```

### Missing Examples

❌ No demonstration:

```
Elena has a dry sense of humor.
```

✅ With example:

```
Elena's humor is dry and self-deprecating:
"Smart? Please. I just have the advantage of being too stubborn
to forget anything in 300 years."
```

## See Also

* [Example Dialogue](https://docs.meganova.ai/character-studio/character-features/example-dialogue.md) — Writing dialogue
* [Advanced Settings](https://docs.meganova.ai/character-studio/character-features/advanced-settings.md) — Configuration
* [Quality Metrics](https://docs.meganova.ai/character-studio/testing-quality/quality-metrics.md) — Measuring quality
* [Benchmark Arena](https://docs.meganova.ai/character-studio/testing-quality/benchmark-arena.md) — Testing
