✓ Verified 💻 Development ✓ Enhanced Data

Message Injector

OpenClaw plugin that prepends custom text to every user message before it reaches the agent.

Rating
4.8 (442 reviews)
Downloads
4,611 downloads
Version
1.0.0

Overview

OpenClaw plugin that prepends custom text to every user message before it reaches the agent.

Complete Documentation

View Source →

Message Injector

A lightweight OpenClaw workspace extension that uses the before_agent_start hook to inject custom text into every user message via prependContext.

Installation

1. Create the extension directory

bash
mkdir -p ~/.openclaw/workspace/.openclaw/extensions/message-injector

2. Copy the plugin files

Copy scripts/index.ts and scripts/openclaw.plugin.json to the extension directory:

bash
cp scripts/index.ts ~/.openclaw/workspace/.openclaw/extensions/message-injector/
cp scripts/openclaw.plugin.json ~/.openclaw/workspace/.openclaw/extensions/message-injector/

3. Add configuration

Add the following to ~/.openclaw/openclaw.json under plugins.entries:

json
"message-injector": {
  "enabled": true,
  "config": {
    "enabled": true,
    "prependText": "Your custom text here"
  }
}

4. Restart Gateway

bash
openclaw gateway restart

Configuration

FieldTypeDefaultDescription
enabledbooleantrueEnable or disable the injector
prependTextstring""Text to prepend before every user message

Example Use Cases

Force memory search:

json
"prependText": "[⚠️ 回答前必须先 memory_search 检索相关记忆,禁止凭印象回答]"

Add persistent context:

json
"prependText": "[当前项目:my-app | 技术栈:React + Node.js | 部署环境:AWS]"

Inject safety rules:

json
"prependText": "[RULE: Always verify file paths before deletion. Never run rm -rf without confirmation.]"

How It Works

The plugin registers a before_agent_start hook. When triggered, it returns { prependContext: prependText } which OpenClaw prepends to the user's message before the agent processes it. This is a hard injection at the Gateway level — the agent cannot skip or ignore it.

Source Code

GitHub: https://github.com/Harukaon/openclaw-message-injector

Installation

Terminal bash

openclaw install message-injector
    
Copied!

💻Code Examples

mkdir -p ~/.openclaw/workspace/.openclaw/extensions/message-injector

mkdir--p-openclawworkspaceopenclawextensionsmessage-injector.txt
### 2. Copy the plugin files

Copy `scripts/index.ts` and `scripts/openclaw.plugin.json` to the extension directory:

cp scripts/openclaw.plugin.json ~/.openclaw/workspace/.openclaw/extensions/message-injector/

cp-scriptsopenclawpluginjson-openclawworkspaceopenclawextensionsmessage-injector.txt
### 3. Add configuration

Add the following to `~/.openclaw/openclaw.json` under `plugins.entries`:

openclaw gateway restart

openclaw-gateway-restart.txt
## Configuration

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `enabled` | boolean | `true` | Enable or disable the injector |
| `prependText` | string | `""` | Text to prepend before every user message |

## Example Use Cases

**Force memory search:**
example.json
"message-injector": {
  "enabled": true,
  "config": {
    "enabled": true,
    "prependText": "Your custom text here"
  }
}

⚙️Configuration Options

Option Type Default Description
enabledstringboolean`true`
prependTextstringstring`""`

Tags

#web_and-frontend-development

Quick Info

Category Development
Model Claude 3.5
Complexity Multi-Agent
Author harukaon
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install message-injector