A smart plugin for OpenClaw that automatically injects the most relevant skills and protocols into your agent's context before each run. Uses Ollama embeddings — free, offline-capable, no separate embedding API key required.
When you run an agent, this plugin:
skills/ and memory/protocols/ directories for documentationnomic-embed-text (via Ollama)Result: Agents follow custom protocols and skills without burning tokens on irrelevant context.
http://localhost:11434nomic-embed-text (download with ollama pull nomic-embed-text)Download from ollama.com and install.
bash
ollama pull nomic-embed-text
bash
ollama serve
Leave this running in the background. It listens on http://localhost:11434 by default.
Add to your openclaw.json:
json
{
"plugins": {
"skill-preflight": {
"enabled": true,
"config": {
"minScore": 0.3,
"maxResults": 3,
"protocolDirs": ["memory/protocols"],
"skillsDirs": ["skills"]
}
}
}
}
Create your skills and protocols in:
skills/ — skill documentation (looks for SKILL.md in subdirs or loose .md files)memory/protocols/ — protocol docs ( .md files, 1 level deep)OptionDefaultDescriptionprotocolDirs``["memory/protocols"]Directories to scan for protocol docs (recursive, 1 level)skillsDirs``["skills"]Directories to scan for skill docstoolsFiles``["TOOLS.md"]Individual files to always include in the indexpinnedDocs``[]Docs always injected first, regardless of scoremaxResults``3Max ranked docs to inject per run (pinned docs don't count toward this)maxDocLines``100Truncate injected docs to N lines (0 = no limit)minScore``0.3Cosine similarity threshold (0–1). Lower = more permissive. Tune via debug logs.embedModel``nomic-embed-text:latestOllama embedding modelollamaBaseUrl``http://localhost:11434Ollama API base URL. For local-only privacy, keep this on localhost, 127.0.0.1, or ::1. If you point it at a remote host, prompt text and indexed doc content are sent to that host for embeddings.requestTimeoutMs``10000Timeout for embedding requests (ms)minPromptLength``20Minimum prompt length to trigger preflight. Short prompts skip embedding.
Pin specific docs so they're always injected first, regardless of relevance score:
json
{
"plugins": {
"skill-preflight": {
"config": {
"pinnedDocs": ["memory/protocols/house-rules.md", "skills/ethereum/SKILL.md"]
}
}
}
}
Pinned docs appear first and don't count toward maxResults.
Enable debug logging in OpenClaw to see similarity scores:
text
skill-preflight: scores — DebuggingProtocol(0.72), EthereumSkill(0.51), MemoryProtocol(0.34), ...
Use this to dial in minScore. If too many irrelevant docs are injected, raise it. If relevant docs are missing, lower it.
curl http://localhost:11434/api/tagsollama list (should show nomic-embed-text)requestTimeoutMs in configprotocolDirs or skillsDirsstatus: deprecated or status: archived are skippedminScore (lower threshold = more docs)maxResults (cap on how many ranked docs)pinnedDocs to always include critical docsnomic-embed-text takes ~100–300ms per document on typical hardwareminScore to reduce docs being embeddedDocs are standard Markdown with optional frontmatter:
markdown
---
name: My Custom Skill
description: A brief description of what this does
status: active
---
# My Custom Skill
Detailed instructions, examples, step-by-step procedures...
Frontmatter is optional. If not provided, the first heading or filename is used as the title, and the first few lines become the description.
No separate embedding API required — embeddings go through your configured Ollama endpoint
Local-only when Ollama is local — keep ollamaBaseUrl on localhost, 127.0.0.1, or ::1 if you want docs and prompts to stay on the same machine
Remote Ollama changes the trust boundary — if ollamaBaseUrl points to another host, the following are sent to that host for embedding:
Offline capable — once the Ollama model is downloaded and running locally, no internet is required
Caching: Docs cached for 1 hour, embeddings cached in memory per session
Session-aware: Same doc won't be re-injected in a single conversation
MIT
Questions? Check the OpenClaw docs at openclaw.ai or report issues on GitHub.