Skip to main content
Prompt injections are snippets of text that Rikka automatically inserts into a conversation’s context at a position you choose. They let you augment any assistant with additional instructions, reference material, or world-building lore — without cluttering the main system prompt. Lorebooks extend this idea by grouping multiple injection entries and activating each one only when specific keywords appear in the conversation.

Core concepts

Mode Injection

A manually toggled snippet. Enable it on an assistant and it is always injected whenever that assistant is active. Ideal for “modes” like a formal writing style or a step-by-step reasoning format.

Lorebook

A named collection of entries. Each entry carries keywords; when those keywords appear in recent messages, the entry’s content is automatically injected. Perfect for world-building reference material or project glossaries.

Injection positions

Every injection targets a specific location in the message list. Choose the position that best matches the intent of your content.
Inserts the content immediately before the existing system message. Use this for high-priority framing that should precede all other instructions.
Appends the content to the end of the system message. This is the most common position — it extends the system prompt without replacing it.
Places the content just before the first user message in the conversation history. Useful for setting scene context that appears once at the start.
Inserts the content immediately before the most recent user message. Good for reminders or dynamic context that should be fresh in the model’s attention.
Inserts at a specific depth from the end of the message list (e.g., depth 4 = four messages from the bottom). Use this for precise placement relative to recent conversation turns.

Creating a mode injection

1

Open Settings

Tap the settings icon from the main screen.
2

Navigate to Prompts

Select Prompts (also accessible from the Extensions tab of an assistant via the Go to Prompts button).
3

Add a mode injection

Tap + in the Mode Injections section. Give it a name, write the content, choose an injection position, set a role (User or Assistant), and assign a priority.
4

Save

Tap Save. The injection is now available to attach to any assistant.

Creating a lorebook

1

Open Settings → Prompts

Navigate to the Lorebooks section and tap + to create a new lorebook.
2

Name the lorebook

Give it a descriptive name such as “Fantasy World Lore” or “Project Glossary”.
3

Add entries

Inside the lorebook, tap + to create an entry. For each entry, configure:
  • Keywords — the words or patterns that trigger this entry.
  • Content — the text to inject when triggered.
  • Injection position and role.
  • Scan depth — how many recent messages to check for keyword matches.
  • Use regex — treat keywords as regular expressions instead of plain text.
  • Case sensitive — whether matching respects letter case.
  • Constant active — inject this entry unconditionally, regardless of keywords.
4

Save the lorebook

Tap Save. The lorebook and all its entries are now ready to attach to assistants.
Set Constant active on an entry if you want it to always inject, making it behave like a persistent mode injection that lives inside a lorebook for organisational purposes.

Attaching injections to an assistant

1

Open the assistant's Extensions tab

Go to Settings → Assistants, tap an assistant, and select the Extensions tab.
2

Enable mode injections

Switch to the Mode Injections sub-tab and toggle on any injections you want active for this assistant.
3

Enable lorebooks

Switch to the Lorebooks sub-tab and toggle on any lorebooks whose entries should be available in this assistant’s conversations.

Key assistant fields

modeInjectionIds
set
The set of mode injections that are active for this assistant. Any injection in this set is included in every conversation, regardless of message content.
lorebookIds
set
The set of lorebooks attached to this assistant. Entries within those lorebooks fire automatically when their keywords are detected in recent messages.
allowConversationSystemPrompt
boolean
default:"false"
When enabled, each individual conversation can override this assistant’s system prompt. Turn this on if you want to customise the system prompt on a per-chat basis without changing the assistant’s default.
allowConversationPromptInjection
boolean
default:"false"
When enabled, each conversation can bind its own set of mode injections and lorebooks, overriding the assistant-level selection. Enable this when you want to mix and match injections dynamically per conversation.

Message template

The message template wraps every user message before it is sent to the model. The default value is {{message}}, which sends the message as-is. You can add surrounding context, formatting, or persona hints around it.
messageTemplate
string
default:"{{message}}"
A template string applied to each outgoing user message. Must include {{message}} somewhere so the user’s actual text is passed through. Rikka will flag an error if this placeholder is missing.
If {{message}} is missing from the message template, the user’s actual message will not be included in the request. Rikka highlights this as an error in the editor — always verify the template before saving.

Placeholder variables

Placeholder variables can be used inside the message template, the system prompt, or any injection content. Rikka replaces them with live values at the time each message is sent. Both {{variable}} and {variable} syntax are accepted.
VariableDescription
{{cur_date}}Current date, formatted for your locale
{{cur_time}}Current time, formatted for your locale
{{cur_datetime}}Current date and time, formatted for your locale
{{model_id}}The model ID string of the active model
{{model_name}}The display name of the active model
{{locale}}Your device’s current locale (e.g. English (United States))
{{timezone}}Your device’s current time zone name
{{system_version}}Android version running on the device
{{device_info}}Device brand and model name
{{battery_level}}Current battery charge level as a percentage
{{nickname}}Your display nickname from Settings → Display
{{user}}Same as {{nickname}} — your display name
{{char}}The name of the current assistant
Tap any variable chip shown beneath the system prompt or template editor to insert it at the cursor position.

How injection priority works

When multiple injections target the same position, Rikka sorts them by their priority value in descending order — higher number means injected first. Injections with the same role at the same position are merged into a single message to keep the conversation structure clean.
Rikka is careful not to insert injected messages between a user message and an immediately following assistant message that contains tool calls, because some providers (such as DeepSeek) require those two messages to be adjacent for correct reasoning.