claude-code-langcache
v1.0.1
Published
Semantic caching skill for Claude Code using Redis LangCache
Maintainers
Readme
claude-code-langcache
Semantic caching skill for Claude Code using Redis LangCache.
Reduce LLM costs and latency by caching responses for semantically similar queries, with built-in privacy and security guardrails.
For OpenClaw users: See openclaw-langcache
Features
- Semantic similarity matching - Cache hits for similar (not just identical) queries
- Hard block enforcement - Automatically blocks caching of sensitive data:
- Temporal info (today, tomorrow, deadlines, appointments)
- Credentials (API keys, passwords, tokens, OTP)
- Identifiers (emails, phone numbers, account IDs)
- Personal context (relationships, private conversations)
- Category-aware thresholds - Different similarity thresholds for factual Q&A vs style transforms
- CLI and Python integration - Use from shell scripts or embed in Python agents
Installation
Via npm (Recommended)
npm install -g claude-code-langcacheThe skill will be automatically installed to ~/.claude/skills/langcache/
Via Git
git clone https://github.com/manvinder01/claude-code-langcache.git /tmp/claude-code-langcache
cp -r /tmp/claude-code-langcache/skills/langcache ~/.claude/skills/Configuration
Set your Redis LangCache credentials:
export LANGCACHE_HOST=your-instance.redis.cloud
export LANGCACHE_CACHE_ID=your-cache-id
export LANGCACHE_API_KEY=your-api-keyGet these from Redis Cloud Console after creating a LangCache instance.
Usage
Automatic (via Claude Code)
The skill triggers automatically when you mention:
- "cache LLM responses"
- "semantic caching"
- "reduce API costs"
- "configure LangCache"
Or invoke manually with /langcache
CLI
# Search for cached response
~/.claude/skills/langcache/scripts/langcache.sh search "What is Redis?"
# With similarity threshold
~/.claude/skills/langcache/scripts/langcache.sh search "What is Redis?" --threshold 0.9
# Store a response
~/.claude/skills/langcache/scripts/langcache.sh store "What is Redis?" "Redis is an in-memory data store..."
# Check if content would be blocked
~/.claude/skills/langcache/scripts/langcache.sh check "What's on my calendar today?"
# Output: BLOCKED: temporal_infoCaching Policy
Cacheable (white-list)
| Category | Examples | Threshold |
|----------|----------|-----------|
| Factual Q&A | "What is X?", "How does Y work?" | 0.90 |
| Definitions / docs | API docs, command help | 0.90 |
| Command explanations | "What does git rebase do?" | 0.92 |
| Reply templates | "polite no", "follow-up", "intro" | 0.88 |
| Style transforms | "make this warmer/shorter" | 0.85 |
Never Cached (hard blocks)
| Category | Examples | |----------|----------| | Temporal | today, tomorrow, deadline, ETA, "in 20 minutes" | | Credentials | API keys, passwords, tokens, OTP/2FA | | Identifiers | emails, phone numbers, account IDs, UUIDs | | Personal | "my wife said", private conversations, relationships |
File Structure
~/.claude/skills/langcache/
├── SKILL.md # Skill definition and instructions
├── scripts/
│ └── langcache.sh # CLI wrapper with policy enforcement
├── references/
│ ├── api-reference.md # Complete REST API documentation
│ └── best-practices.md # Optimization techniques
└── examples/
├── basic-caching.sh # Simple cache workflow
└── agent-integration.py # Python integration patternRequirements
- Claude Code
- Redis Cloud account with LangCache enabled
- Node.js 18+ (for npm installation)
jqandcurl(for CLI usage)
Related Packages
- openclaw-langcache - For OpenClaw users
License
MIT License - see LICENSE for details.
