Prompt Cache for Openclaw

A lightweight caching layer that uses SHA-256 hashing to eliminate redundant LLM and TTS API calls and reduce operational costs.

nissan
v1.0.0
Mar 2, 2026
0
1.2k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install prompt-cache

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install prompt-cache using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Prompt Cache?

Prompt Cache is a specialized efficiency tool designed for developers working with LLM and TTS APIs. By implementing a SHA-256 deduplication layer, it ensures that identical prompts are caught before they incur unnecessary API costs. This skill is a vital addition to any Openclaw Skills collection, particularly for high-volume production environments where repeating similar prompts or identical context is common.

The skill provides a robust, backend-agnostic caching mechanism that supports SQLite, Turso, and Postgres. It helps developers maximize their API quotas while significantly improving response times through instant replays of previously generated content. By normalizing input and hashing the result, it creates a deterministic way to manage expensive external calls.

Prompt Cache Use Cases

  • Prevent redundant spending on expensive LLM calls for identical user queries or system instructions.
  • Cache Text-to-Speech (TTS) outputs to avoid re-generating the same audio clips for recurring phrases.
  • Deduplicate prompts in chat completion workflows using system prompts and model versions as unique keys.
  • Optimize image generation workflows by storing results based on prompt, seed, and model parameters.

How Prompt Cache Works

  1. The skill normalizes the input prompt by converting it to lowercase and collapsing all redundant whitespace.
  2. It combines the normalized prompt with specific context keys such as user identifiers, model names, or language settings.
  3. A unique SHA-256 hash is generated from the combined string to act as a fingerprint.
  4. The system queries the configured database (SQLite, Postgres, or Turso) to find an existing record matching the hash.
  5. On a cache hit, the skill returns the stored result instantly, bypassing the external API entirely.
  6. On a cache miss, the API call is executed, the result is stored in the database for future use, and the data is returned to the user.

Prompt Cache Setup

To integrate this skill into your workflow, ensure your environment has access to your preferred database backend. The logic is contained within a compact script for easy portability among Openclaw Skills.

# Ensure your database environment variables are set (for Turso or Postgres)
# The script uses standard SQL logic compatible with most backends

# Typical usage involves importing the module into your generation pipeline:
# python scripts/prompt_cache.py

Prompt Cache Data Schema & Taxonomy

The skill organizes its data using a relational schema designed for fast lookups. You can adapt the keys to match your specific domain requirements.

Column Type Description
prompt_hash TEXT Primary Key; SHA-256 fingerprint of the normalized prompt and context.
child_name TEXT Secondary key identifying the user or entity (customizable).
language TEXT Contextual key for the language of the prompt.
story_json TEXT The cached payload or result from the API.
created_at DATETIME Automatic timestamp of when the cache entry was created.

Prompt Cache Advanced Features

  • Backend flexibility supporting everything from local SQLite files to distributed Turso or Postgres instances.
  • Support for multi-key deduplication (e.g., combining system prompt, user message, and model version).
  • Highly efficient implementation with approximately 35 lines of code for minimal overhead.
  • Capable of reducing production API quota usage by an estimated 60% by catching repeat requests.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*