Clawlens - OpenClaw Usage Insights
Generate a comprehensive usage insights report by analyzing conversation history.
When to Use
| User Says | Action |
|---|
| "show me my usage report" | Run full report |
| "analyze my conversations" |
Run full report |
| "how am I using Claw" | Run full report |
| "clawlens" / "claw lens" | Run full report |
| "usage insights" / "usage analysis" | Run full report |
How to Run
Execute the analysis script:
CODEBLOCK0
Options
| Flag | Default | Description |
|---|
| INLINECODE0 | INLINECODE1 | Agent ID to analyze |
| INLINECODE2 |
180 | Analysis time window in days |
|
--model | auto-detect | LLM model in litellm format (e.g.
deepseek/deepseek-chat). If omitted, auto-detected from OpenClaw config. |
|
--lang |
zh | Report language:
zh or
en |
|
--format |
md | Output format:
md (Markdown) or
html (self-contained dark-themed HTML) |
|
--no-cache | false | Ignore cached facet extraction results |
|
--max-sessions |
2000 | Maximum sessions to process |
|
--concurrency |
10 | Max parallel LLM calls |
|
--verbose | false | Print progress to stderr |
|
-o /
--output | stdout | Output file path |
Model Selection (Agent Interaction)
When the user requests a clawlens report without specifying a model, you must ask the user before running:
是否使用 OpenClaw 当前配置的模型来生成报告?如果不使用,请告诉我你想用的模型(litellm 格式,如 deepseek/deepseek-chat)。
- - User agrees to use OpenClaw model: Run without
--model (the script auto-detects from ~/.openclaw/openclaw.json). - User specifies a different model: Run with
--model <user-choice>. The user must also set the corresponding API key env var (e.g. DEEPSEEK_API_KEY).
Note: Each user's OpenClaw model configuration may differ — some use API-key-based providers (e.g. openai-completions), others use OAuth-based providers (e.g. anthropic-messages). The script handles both transparently.
Examples
CODEBLOCK1
Output
The script outputs a report to stdout (or to the file specified by -o). Progress messages go to stderr when --verbose is set.
- - Markdown (
--format md, default): Plain Markdown report. Present it directly to the user. - HTML (
--format html): Self-contained dark-themed HTML file with glassmorphism styling, animated stat cards, CSS bar charts, and interactive navigation. Opens directly in any browser — no external dependencies. Requires the markdown Python package for Markdown-to-HTML conversion.
The report includes all dimensions: usage overview, task classification, friction analysis, skills ecosystem, autonomous behavior audit, and multi-channel analysis.
Present the output directly to the user. Do not summarize or truncate it.
Model Configuration
INLINECODE34 is optional. If omitted, the model is automatically resolved from OpenClaw configuration:
- 1. Reads primary model from
~/.openclaw/openclaw.json (agents.defaults.model.primary, e.g. kimi-code/kimi-for-coding) - Looks up the provider's
baseUrl and api type (e.g. openai-completions, anthropic-messages) - Retrieves API key/token from INLINECODE42
- Maps to litellm format automatically (e.g.
openai/kimi-for-coding with custom api_base)
If you prefer to specify a model manually, use --model with litellm's provider format:
| Provider | INLINECODE46 value | Required env var |
|---|
| DeepSeek | INLINECODE47 | INLINECODE48 |
| OpenAI |
openai/gpt-4o |
OPENAI_API_KEY |
| Anthropic |
anthropic/claude-sonnet-4-20250514 |
ANTHROPIC_API_KEY |
| OpenAI-compatible |
openai/<model-id> + set
OPENAI_API_BASE |
OPENAI_API_KEY |
The format is always <provider>/<model-id>. Refer to litellm docs for the full list of supported providers and their env var naming conventions.
Data Source
The script reads conversation data from:
- -
~/.openclaw/agents/{agentId}/sessions/sessions.json (session index) - INLINECODE58 (per-session logs, including unindexed historical files)
- INLINECODE59 (installed skills directory for ecosystem analysis)
Cache is written to ~/.openclaw/agents/{agentId}/sessions/.clawlens-cache/facets/ to avoid re-analyzing the same sessions.
Privacy Notice
This skill sends conversation transcript data to an external LLM provider (specified by --model) for analysis. Specifically:
- - Stage 2 (Facet Extraction): Each session's conversation transcript (truncated to ~80K chars) is sent to the LLM to extract structured analysis (task categories, friction points, etc.). Results are cached locally so each session is only sent once.
- Stage 4 (Report Generation): Aggregated statistics and session summaries (not raw transcripts) are sent to the LLM to generate the report sections.
API key handling: When --model is omitted, this skill reads openclaw.json and auth-profiles.json to auto-detect the model and retrieve the API key. The API key is used only for LLM calls during report generation and is not stored or transmitted elsewhere. When --model is specified explicitly, the user must provide the API key via environment variables — no OpenClaw config files are accessed for credentials.
Clawlens - OpenClaw 使用洞察
通过分析对话历史生成全面的使用洞察报告。
何时使用
| 用户输入 | 操作 |
|---|
| 显示我的使用报告 | 运行完整报告 |
| 分析我的对话 |
运行完整报告 |
| 我如何使用 Claw | 运行完整报告 |
| clawlens / claw lens | 运行完整报告 |
| 使用洞察 / 使用分析 | 运行完整报告 |
如何运行
执行分析脚本:
bash
python3 scripts/clawlens.py [选项]
选项
| 标志 | 默认值 | 描述 |
|---|
| --agent-id | main | 要分析的 Agent ID |
| --days |
180 | 分析时间窗口(天) |
| --model | 自动检测 | 使用 litellm 格式的 LLM 模型(例如 deepseek/deepseek-chat)。如果省略,则从 OpenClaw 配置自动检测。 |
| --lang | zh | 报告语言:zh 或 en |
| --format | md | 输出格式:md(Markdown)或 html(自包含深色主题 HTML) |
| --no-cache | false | 忽略缓存的方面提取结果 |
| --max-sessions | 2000 | 最大处理会话数 |
| --concurrency | 10 | 最大并行 LLM 调用数 |
| --verbose | false | 向 stderr 打印进度 |
| -o / --output | stdout | 输出文件路径 |
模型选择(Agent 交互)
当用户请求 clawlens 报告但未指定模型时,你必须在运行前询问用户:
是否使用 OpenClaw 当前配置的模型来生成报告?如果不使用,请告诉我你想用的模型(litellm 格式,如 deepseek/deepseek-chat)。
- - 用户同意使用 OpenClaw 模型:运行时不加 --model(脚本从 ~/.openclaw/openclaw.json 自动检测)。
- 用户指定其他模型:使用 --model <用户选择> 运行。用户还必须设置相应的 API 密钥环境变量(例如 DEEPSEEKAPIKEY)。
注意:每个用户的 OpenClaw 模型配置可能不同——有些使用基于 API 密钥的提供商(例如 openai-completions),有些使用基于 OAuth 的提供商(例如 anthropic-messages)。脚本透明地处理这两种情况。
示例
bash
从 OpenClaw 配置自动检测模型(最简单)
python3 scripts/clawlens.py --verbose
自动检测,英文,最近 7 天
python3 scripts/clawlens.py --lang en --days 7
手动指定模型(DeepSeek)
DEEPSEEK
APIKEY=sk-xxx python3 scripts/clawlens.py --model deepseek/deepseek-chat
OpenAI,英文,最近 7 天
OPENAI
APIKEY=sk-xxx python3 scripts/clawlens.py --model openai/gpt-4o --lang en --days 7
详细模式,保存到文件
ANTHROPIC
APIKEY=sk-xxx python3 scripts/clawlens.py --model anthropic/claude-sonnet-4-20250514 --verbose -o /tmp/clawlens-report.md
HTML 报告(深色主题,自包含)
DEEPSEEK
APIKEY=sk-xxx python3 scripts/clawlens.py --model deepseek/deepseek-chat --format html -o /tmp/clawlens-report.html
输出
脚本将报告输出到 stdout(或 -o 指定的文件)。当设置 --verbose 时,进度消息输出到 stderr。
- - Markdown(--format md,默认):纯 Markdown 报告。直接呈现给用户。
- HTML(--format html):自包含的深色主题 HTML 文件,具有玻璃态样式、动画统计卡片、CSS 条形图和交互式导航。可直接在任何浏览器中打开——无需外部依赖。需要 markdown Python 包进行 Markdown 到 HTML 的转换。
报告包含所有维度:使用概览、任务分类、摩擦分析、技能生态、自主行为审计和多渠道分析。
直接将输出呈现给用户。 不要总结或截断。
模型配置
--model 是可选的。如果省略,模型将从 OpenClaw 配置自动解析:
- 1. 从 ~/.openclaw/openclaw.json 读取主模型(agents.defaults.model.primary,例如 kimi-code/kimi-for-coding)
- 查找提供商的 baseUrl 和 api 类型(例如 openai-completions、anthropic-messages)
- 从 ~/.openclaw/agents/{agentId}/agent/auth-profiles.json 检索 API 密钥/令牌
- 自动映射到 litellm 格式(例如带有自定义 api_base 的 openai/kimi-for-coding)
如果你更喜欢手动指定模型,请使用 --model 配合 litellm 的提供商格式:
| 提供商 | --model 值 | 必需的环境变量 |
|---|
| DeepSeek | deepseek/deepseek-chat | DEEPSEEKAPIKEY |
| OpenAI |
openai/gpt-4o | OPENAI
APIKEY |
| Anthropic | anthropic/claude-sonnet-4-20250514 | ANTHROPIC
APIKEY |
| OpenAI 兼容 | openai/
+ 设置 OPENAIAPIBASE | OPENAIAPIKEY |
格式始终是 /。有关支持的提供商及其环境变量命名约定的完整列表,请参阅 litellm 文档。
数据源
脚本从以下位置读取对话数据:
- - ~/.openclaw/agents/{agentId}/sessions/sessions.json(会话索引)
- ~/.openclaw/agents/{agentId}/sessions/*.jsonl(每个会话的日志,包括未索引的历史文件)
- ~/.openclaw/skills/(已安装的技能目录,用于生态分析)
缓存写入 ~/.openclaw/agents/{agentId}/sessions/.clawlens-cache/facets/,以避免重复分析相同的会话。
隐私声明
此技能将对话记录数据发送到外部 LLM 提供商(由 --model 指定)进行分析。具体来说:
- - 阶段 2(方面提取):每个会话的对话记录(截断至约 80K 字符)被发送到 LLM 以提取结构化分析(任务类别、摩擦点等)。结果被本地缓存,因此每个会话只发送一次。
- 阶段 4(报告生成):汇总统计数据和会话摘要(而非原始记录)被发送到 LLM 以生成报告部分。
API 密钥处理: 当省略 --model 时,此技能读取 openclaw.json 和 auth-profiles.json 以自动检测模型并检索 API 密钥。该 API 密钥仅用于报告生成期间的 LLM 调用,不会存储或传输到其他地方。当明确指定 --model 时,用户必须通过环境变量提供 API 密钥——不会访问 OpenClaw 配置文件获取凭据。