AGENT SKILL

stats

Displays memory usage statistics for the current session and project including counts by category, age distribution, and API latency. Use when checking how many memories exist, reviewing session activity, or auditing memory distribution across categories.

License 许可
Apache-2.0
最近更新
2026-08-12
Stars
★ 2
Forks
0

01 前言 Front Matter

name
stats
description
Displays memory usage statistics for the current session and project including counts by category, age distribution, and API latency. Use when checking how many memories exist, reviewing session activity, or auditing memory distribution across categories.

03 SKILL.md 正文

Mem0 Stats

Show session and lifetime memory statistics.

Execution

Step 1: Gather session stats

Run the session stats reporter:

SCRIPT_DIR="${CLAUDE_PLUGIN_ROOT:-${CODEX_PLUGIN_ROOT:-${CURSOR_PLUGIN_ROOT:-}}}/scripts"
python3 "$SCRIPT_DIR/session_stats.py" peek 2>/dev/null || echo "{}"

The peek command returns JSON without clearing the stats file (unlike report).

If the script returns empty or errors, note "No session data available" and continue.

Step 2: Fetch lifetime and session stats from API

Lifetime stats: Call get_memories to fetch all memories for this project:

filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}, page_size=100

Group by:

  1. categories[0] (platform-assigned) — primary grouping
  2. metadata.type (agent-assigned) — secondary if no categories
  3. created_at date — for age analysis

Category normalization: Merge auto_capture and uncategorized into a single uncategorized row. These are memories where the platform didn't assign a meaningful content category. Do NOT show auto_capture as its own row in the table.

Session stats (local only): Session stats come from the local stats file read in Step 1. Do NOT query the API with run_id or metadata.session_id filters — these return unreliable results because memories are stored without run_id and metadata filters on session_id are inconsistent.

The local stats file tracks adds and searches for the current session accurately.

Also run a search_memories MCP tool call with query="project", filters={"AND": [{"user_id": "<active_user_id>"}, {"app_id": "<active_project_id>"}]}, top_k=1 to measure round-trip latency. Note the time before and after the MCP call — do NOT attempt raw HTTP calls to the API.

Step 3: Display

Print a minimal dashboard. No ASCII bar charts — use a clean table layout:

## mem0 stats

**Session** (<session_id, first 12 chars>) — 3 written, 5 searches, categories: decision, convention

**Project: my-project** — 55 memories, API: 84ms

| Category             | Count |
|----------------------|-------|
| decision             |    24 |
| convention           |    15 |
| anti_pattern         |     6 |
| task_learning        |     5 |
| user_preference      |     3 |
| session_state        |     2 |

**Age** — oldest: 2026-02-15, newest: 2026-05-23
  < 7 days: 5 · 7–30d: 12 · 30–90d: 10 · > 90d: 8

**Identity** — user: kartik · project: my-project · branch: main

Display rules:

  • Category table: sort by count descending, omit categories with 0 memories
  • Age: single line with dot-separated buckets, computed from created_at
  • Session line: skip if no session data available
  • If only 1-2 total memories, skip the category table — just show the count
  • Keep everything compact — no decorative borders or filler

Weekly digest mode

When invoked with --weekly (e.g., /mem0:stats --weekly), append a weekly activity digest after the standard stats dashboard:

W1: Fetch recent memories

Call search_memories in parallel with time-scoped queries:

  1. query="decisions made this week", filters={"AND": [{"user_id": "<id>"}, {"app_id": "<pid>"}, {"created_at": {"gte": "<7 days ago YYYY-MM-DD>"}}]}, top_k=20
  2. query="bugs errors fixes", same time filter, top_k=20
  3. query="patterns conventions learnings", same time filter, top_k=20

W2: Analyze

Merge by ID. Group into "New this week" by categories[0] or metadata.type. Calculate: memories added last 7 days, most active categories, most active day.

W3: Display

Append after the standard stats:

### This week (May 16 – May 23)

+12 memories — most active: Wednesday (5)

| Category      | New |
|---------------|-----|
| decision      |   5 |
| task_learning |   4 |
| bug_fix       |   3 |

**Highlights**
- <2-3 sentence summary of most important decisions/learnings this week>

W4: Write digest file

Write to ~/.mem0/weekly-digest.md (overwrite). Append one-line to ~/.mem0/digest-history.log:

<YYYY-MM-DD> | <project_id> | +<new_count> memories | top: <top_category>

W5: Empty state

If no new memories in 7 days:

No new memories in the past week. Total: <N> memories in <project_id>.

04 同仓库更多 Skills

zhangmask
zhangmask/C_AnimeCompanion

mem0

Mem0 Platform SDK for adding persistent memory to AI applications. TRIGGER when: user mentions "mem0", "MemoryClient", "memory layer", "remember user preferences", "persistent context", "personalization", or needs to add long-term memory to chatbots, agents, or AI apps. Covers Python SDK (mem0ai), TypeScript SDK (mem0ai), and framework integrations (LangChain, CrewAI, OpenAI Agents SDK, Pipecat, LlamaIndex, AutoGen, LangGraph). Also covers the open-source self-hosted Memory class. This is the DEFAULT mem0 skill for ambiguous queries. DO NOT TRIGGER when: user asks about CLI commands, terminal usage, or shell scripts (use mem0-cli), or Vercel AI SDK / @mem0/vercel-ai-provider / createMem0 (use mem0-vercel-ai-sdk).

★ 2
zhangmask
zhangmask/C_AnimeCompanion

mem0-vercel-ai-sdk

Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider). TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider", "createMem0", "retrieveMemories", "addMemories", "getMemories", "searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory", or is using generateText/streamText with mem0. Also triggers for Next.js apps needing memory-augmented AI. DO NOT TRIGGER when: user asks about direct Python/TS SDK calls without Vercel (use mem0 skill), or CLI terminal commands (use mem0-cli skill).

★ 2
zhangmask
zhangmask/C_AnimeCompanion

mem0-test-integration

Verify a Mem0 integration produced by /mem0-integrate. Runs in the same workspace on the same branch (loose coupling) — installs dependencies, runs the repo's native test suite, then exercises a real end-to-end smoke flow against the user's API key. Produces a scorecard. TRIGGER when: user has just run /mem0-integrate and says "verify", "test the integration", "run /mem0-test-integration", or when a .mem0-integration/ directory exists and tests have not been run yet on the current branch. DO NOT TRIGGER when: the user wants to run general project tests (defer to the repo's native test command), or when no prior /mem0-integrate run exists in the current branch (ask them to run /mem0-integrate first). This skill ONLY catches compile and runtime bugs by design. Logical integration errors — wrong data stored, wrong time retrieved, wrong user scoping — are on the human reviewer.

★ 2
zhangmask
zhangmask/C_AnimeCompanion

mem0-oss-to-platform

Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local `Memory` class) to the mem0 Platform / hosted / managed SDK (the `MemoryClient` class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g. "migrate my mem0 setup to the platform", "switch from self-hosted mem0 to MemoryClient", "use my mem0 API key instead of a local Qdrant", "move mem0 to the cloud/hosted/managed service", or "replace my local mem0 vector store + embedder config with the platform". Applies to Python (`from mem0 import Memory` → `from mem0 import MemoryClient`) and TypeScript/JavaScript (`import { Memory } from "mem0ai/oss"` → `import MemoryClient from "mem0ai"`). Trigger even when the user doesn't say the word "migrate" but clearly wants their existing mem0 integration to run against the hosted platform. It first produces a reviewable migration plan, then executes it after the developer approves. Strictly scoped to the mem0 integration — it does not refactor, restructure, or "improve" any unrelated code.

★ 2
zhangmask
zhangmask/C_AnimeCompanion

mem0-integrate

Integrate Mem0 into an existing repository using a goal-driven, TDD pipeline. Detects the repo's language automatically and asks the user to pick between Mem0 Platform (managed) and Mem0 Open Source (self-hosted). Writes failing tests before any implementation. Produces a local feature branch plus `.mem0-integration/` artifacts consumed by the paired verification skill. TRIGGER when: user says "integrate mem0", "add mem0 to this repo", "wire mem0 into <repo>", or asks how to add memory to an existing project. DO NOT TRIGGER when: the user wants general SDK usage (use skill:mem0), CLI usage (use skill:mem0-cli), or Vercel AI SDK (use skill:mem0-vercel-ai-sdk). After success, invoke skill:mem0-test-integration to verify in the same workspace (loose coupling).

★ 2
zhangmask
zhangmask/C_AnimeCompanion

mem0-cli

Mem0 CLI -- the command-line interface for mem0 memory operations. TRIGGER when: user mentions "mem0 cli", "mem0 command line", "@mem0/cli", "mem0-cli", "pip install mem0-cli", "npm install -g @mem0/cli", or is running mem0 commands in a terminal/shell (mem0 add, mem0 search, mem0 list, mem0 get, mem0 init, mem0 config, mem0 import). Also triggers when query includes CLI flags like --user-id, --output, --json, --agent, or describes bash/zsh/terminal/shell usage. DO NOT TRIGGER when: user asks about programmatic SDK integration in Python/TS code (use mem0 skill), or Vercel AI SDK provider (use mem0-vercel-ai-sdk skill).

★ 2