Token导航 LogoToken导航TokenDH.com
研究检索执行命令clawhub未标认证来源可访问clear审计提醒

lean-context精益环境

Agent Skill

lean-context 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

950

周安装

40

GitHub Stars

公开资料未说明

下载量

333
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:lean-context(精益环境)
来源仓库:https://github.com/awalesagar/lean-context
安装命令:
openclaw skills install lean-context
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install lean-context

简介

减少 AI 代理系统中令牌使用量的上下文压缩方案。

  • 支持选择性加载与多平台兼容(如 Windsurf、Cursor)。
  • 适用于降低大模型推理成本与提升响应速度场景。lean-context 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 安装命令:openclaw skills install lean-context。
  • 请核实是否修改全局上下文加载策略影响其他技能。

SKILL.md

name
token-optimizer
description
|

Token Optimizer

Cut token usage without cutting quality. Every technique below is battle-tested in production Claude Code, OpenClaw, and agentic systems.

The 3 Token Drains (fix these first)

  1. Tool output accumulation — Every file read, shell command, and MCP response appends *full output* to context permanently. A 10K-line log file stays in context for every subsequent message. This is the #1 silent drain.
  2. Context compounding — The model re-reads the entire conversation on every turn. Message 50 costs more than message 5 because it re-reads 49 prior messages. Long sessions become token furnaces.
  3. System prompt baseline — CLAUDE.md / AGENTS.md / system prompts load before every single request. A 5,000-token config file costs 5,000 tokens per turn, forever.

Strategy 1: Slash System Prompt Size

Target: under 500 tokens for primary config files.

# CLAUDE.md / AGENTS.md template (good — ~150 tokens)
## Rules
- TypeScript strict mode
- Test every new function
- Follow existing patterns

## Key Files
- API routes: src/api/README.md
- DB schema: docs/schema.md
- Style guide: docs/style-guide.md

Principles:

  • Give the *shape* of the project, not the full docs
  • Use file pointers instead of inline documentation
  • Link to reference files — the model reads them only when needed
  • 3-5 rules + 3-5 file pointers is the sweet spot

Strategy 2: Selective Loading (Progressive Disclosure)

Never load everything upfront. Use a three-tier system:

TierWhen loadedToken cost
Metadata (name+description)Always~100 words
Core instructions (SKILL.md body)On trigger<5K words
Reference filesOn demandUnlimited

Implementation patterns:

File pointers over inline content:

# Bad: inline everything
## API Reference
[2000 lines of API docs]

# Good: pointer + on-demand load
## API Reference
See docs/api.md — load only when working on API endpoints.

Domain-split references:

skill/
├── SKILL.md (core workflow only)
└── references/
    ├── aws.md      # load only for AWS tasks
    ├── gcp.md      # load only for GCP tasks
    └── azure.md    # load only for Azure tasks

Conditional loading via grep patterns: For large reference files, include search patterns in SKILL.md:

# BigQuery Metrics
See references/metrics.md. Search patterns:
- Revenue queries: grep "revenue|billing" references/metrics.md
- User analytics: grep "cohort|retention|churn" references/metrics.md

Strategy 3: Compaction & Session Hygiene

When to compact vs clear:

  • /compact — Context is long but thread is still relevant. Summarizes and restarts from summary.
  • /clear — Switching tasks entirely. Wipes everything. Clean slate.

Rules:

  • New topic = new session. No exceptions.
  • Point at specific files, never "read the codebase"
  • Batch related tasks in one prompt: "Fix bug, refactor, add tests" > three separate prompts
  • Use scripts for data you'll read yourself — keep the agent out of the loop

Strategy 4: Efficient Tool Definitions

Tools are context too. Every tool definition loads on every request.

Principles:

  • Minimal viable tool set — if a human can't tell which tool to use, the model can't either
  • CLI > MCP when possible: head -20 file.log (10 tokens) vs MCP JSON response (1000+ tokens)
  • Tools should return summaries, not raw dumps
  • Disconnect unused MCP servers — per-request overhead is real

Tool output compression:

# Bad: full JSON dump
{"status":"success","data":{"items":[...500 lines...],"meta":{"page":1,"total":847}}}

# Good: structured summary
"847 items found. First 5: [names]. See full results in .cache/search.json"

Strategy 5: Prompt Compression Techniques

Extractive Compression (low effort, good ROI)

Select relevant sentences, discard the rest. Best for narrative documents.

# Before: 500 tokens
Customer John reported unstable internet for 3 days with video call disruptions.
Support ticket #4521 opened on 2026-04-15. Multiple attempts to reset router failed.

# After (extractive): 30 tokens
John: unstable internet 3 days, video call disruptions, router reset failed.

Selection-Based Compression (chunk-level filter)

Keep or discard entire chunks. Best for factual/citation-heavy content. Zero rewrite cost.

# Approach: filter chunks by relevance score, only pass top-k to model
relevant_chunks = [c for c in retrieved if c.score > 0.75][:3]

LLMLingua-style Token-Level Compression

Uses a small model to remove low-information tokens. Up to 20x compression with <2% quality loss.

  • Use for: ICL examples, retrieved documents, long instructions
  • Don't use for: code, structured data, exact citations
  • Libraries: llmlingua (Python), LLMLingua2

Strategy 6: Deduplication Patterns

Across context:

  • Never repeat instructions already in system prompt
  • Reference previous context by turn number instead of re-stating: "as discussed in turn 3"
  • Deduplicate few-shot examples — 3 diverse examples > 10 similar ones

Across sessions:

  • Store shared context in files, not in conversation
  • Use memory files (memory/*.md) for cross-session continuity instead of re-explaining
  • Hash-check before loading: if a file hasn't changed, use cached summary

Across tools:

  • Don't read the same file twice — reference previous read
  • Use jq to extract specific fields instead of loading full JSON
  • Pipe commands: grep ERROR log.txt | head -5 instead of cat log.txt

Strategy 7: Caching & Architecture

Prompt caching (provider-level):

  • Anthropic: automatic prompt caching for repeated prefixes (system prompts, tools)
  • OpenAI: cached responses for identical prompts
  • Strategy: structure prompts so static content comes first, dynamic content last

Sub-agent architecture:

Main agent (clean context, ~2K tokens)
├── Sub-agent 1: deep research (uses 50K tokens, returns 1K summary)
├── Sub-agent 2: code generation (uses 30K tokens, returns diff)
└── Sub-agent 3: testing (uses 20K tokens, returns pass/fail + details)

Each sub-agent explores extensively but returns only distilled results. Main agent stays lean.

Model-tiering:

  • Haiku/fast models: formatting, lookups, mechanical edits
  • Mid-tier: implementation, tests, explanations
  • Top-tier: architecture decisions, complex reasoning, multi-file refactors

Strategy 8: Agent-Specific Optimizations

OpenClaw:

  • HEARTBEAT.md: Keep under 200 tokens. Reference external files for detailed checks.
  • MEMORY.md: Curated, not raw. Review monthly. Remove stale entries.
  • SOUL.md / USER.md: Load every session. Keep tight.
  • Skills: Only the SKILL.md body loads on trigger. Put details in references/.
  • Tool output: Use jq, head, tail, grep to scope output before it enters context.
  • Write to files instead of returning large outputs in chat.

Claude Code:

  • .claudeignore — Exclude node_modules, build artifacts, lock files, data files
  • context-mode MCP plugin — Automatically compresses MCP tool outputs
  • /compact after 20-30 messages or when switching sub-tasks
  • /model to switch tiers mid-session (Haiku for lookups, Sonnet for implementation, Opus for architecture)
  • MAX_THINKING_TOKENS=8000 env var to cap extended thinking budget
  • Skills load on-demand only — install freely, they don't add baseline cost

General (applies to all agents):

  • .gitignore pattern for AI: exclude binaries, media, large generated files
  • Structured output (JSON, YAML) > unstructured prose for tool responses
  • --no-ask-user / --allow-all flags reduce confirmation round-trips

Quick Audit Checklist

Run this against any AI project:

Token Audit:
□ System prompt / config files under 500 tokens?
□ Reference docs in separate files, not inline?
□ Tool outputs scoped (jq/head/grep), not raw dumps?
□ Sessions reset between topics?
□ MCP servers limited to active ones only?
□ Few-shot examples: 3 diverse > 10 similar?
□ Sub-agents used for deep exploration work?
□ Model tier matches task complexity?
□ Caching enabled for static prompt prefixes?
□ Deduplication: no repeated instructions across context layers?
□ .claudeignore / .gitignore excluding non-essential files?
□ Extended thinking budget capped for simple tasks?

Strategy ROI Matrix

StrategyEffortSavingsBest For
Slash system promptLow10-30% baselineEvery project
Selective loadingMedium40-70% per-queryMulti-domain agents
CompactionLow50-80% long sessionsCoding agents
Efficient toolsMedium50-90% MCP usageTool-heavy workflows
Prompt compressionHighUp to 20x on docsRAG, research agents
DeduplicationLow10-25% per sessionAll agents
Caching & sub-agentsHigh30-60% overallProduction systems
Model tieringLow3-5x per-query costAll multi-model setups

References

For deeper implementation details — LLMLingua integration code, LangChain compression pipelines, TikToken measurement, sub-agent architecture patterns, semantic deduplication, and dollar savings formulas — see references/compression-deep-dive.md.

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

95.28%
按下载量换算317

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 openclaw skills install lean-context 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills