Leanctx Integration
/install leanctx-integration
LeanContext Integration
LeanContext integration for OpenClaw that automatically compresses tool outputs to reduce token usage by 60-99%.
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|---|---|
| None | N/A | This skill operates entirely locally |
No external API calls are made. All processing happens on your local machine.
Security & Privacy
- Local-only operation: All compression and caching happens locally
- No data leaves your machine: No files, commands, or content is sent to external services
- Cache location: Stored in memory (optional filesystem cache can be configured)
- No telemetry: No usage data, metrics, or analytics are transmitted
Model Invocation
This skill operates autonomously during OpenClaw's normal operation. It intercepts read and exec tool calls transparently without requiring explicit user approval for each invocation. This is standard behavior for OpenClaw skills.
To disable automatic invocation, set enabled: false in your OpenClaw config.
Trust Statement
By using this skill, your file contents and command outputs are processed locally for compression purposes. No data is sent to external services. Only install if you are comfortable with this local processing.
What it does
Intercepts OpenClaw's read and exec tool calls and applies intelligent compression:
- File reads: AST-aware compression removes comments, whitespace, collapses function bodies
- Shell exec: Pattern-matching compresses common commands (git, npm, docker, etc.)
- Session caching: Re-reads cost ~13 tokens instead of thousands
Installation
openclaw skills install leanctx-integration
Or manually:
cd ~/.openclaw/workspace/skills
git clone https://github.com/your-repo/leanctx-integration.git
cd leanctx-integration
npm install
npm run build
Configuration
Add to your openclaw.json:
{
"skills": {
"leanctx-integration": {
"enabled": true,
"config": {
"threshold": 100,
"cacheEnabled": true,
"excludedPaths": ["node_modules", ".git", "dist"],
"excludedCommands": ["cat", "echo"]
}
}
}
}
Usage
Once installed, LeanContext works automatically - no code changes required!
Check Metrics
Note: Metrics tracking has been temporarily disabled. The skill automatically compresses tool outputs, but session-level metrics reporting is not currently available. This feature may be revisited in a future update.
Clear Cache
Via your agent: Ask: "Clear the LeanCTX cache"
Direct CLI:
npx leanctx clear-cache
Compression Examples
TypeScript File (800 lines)
Before: ~2000 tokens
After: ~50 tokens
Savings: 97.5%
Git Log
Before: ~500 tokens (full commit info)
After: ~30 tokens (hashes + messages)
Savings: 94%
NPM Install
Before: ~200 tokens (all download messages)
After: ~10 tokens (summary only)
Savings: 95%
Supported Languages
- TypeScript / JavaScript
- Python
- Svelte
- Go
- Rust
- Java / Kotlin
- Generic (fallback)
Supported Commands
git log→ Commit hashes + first linegit status→ Changed files onlygit diff→ Diff markers + changesnpm install→ Package countnpm test→ Test results + summarycargo build→ Errors onlydocker ps→ Header + first 10 rowskubectl→ Header + first 15 rows
Performance
- Cache hit: \x3C5ms overhead
- First read: ~10ms (AST parse)
- Compression: 60-99% token reduction
Troubleshooting
Not working?
- Check if skill is enabled in config
- Verify threshold isn't too high
- Check excluded paths aren't matching
Want to disable for specific files?
Add to excludedPaths in config:
{
"excludedPaths": ["node_modules", ".git", "**/*.spec.ts"]
}
Cache too large?
Ask your agent: "Clear the LeanCTX cache"
Or via CLI:
npx leanctx clear-cache
How it works
- OpenClaw makes a tool call (read or exec)
- LeanContext intercepts the call
- Checks cache (instant return if hit)
- Compresses based on file type or command pattern
- Caches result
- Returns compressed output to OpenClaw
- Metrics updated
License
MIT
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install leanctx-integration - After installation, invoke the skill by name or use
/leanctx-integration - Provide required inputs per the skill's parameter spec and get structured output
What is Leanctx Integration?
Automatically compresses OpenClaw tool outputs to reduce token usage by 60-99%. It is an AI Agent Skill for Claude Code / OpenClaw, with 141 downloads so far.
How do I install Leanctx Integration?
Run "/install leanctx-integration" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Leanctx Integration free?
Yes, Leanctx Integration is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Leanctx Integration support?
Leanctx Integration is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Leanctx Integration?
It is built and maintained by Jack Keller (@jackkeller); the current version is v0.1.4.