collect

collect is a command for Claude Code from GengzeZhou/memex. It costs 16 tokens per session (569 once invoked), scanned A, original, MIT.

A command that reads local Claude session history, finds new or changed session files, and processes them.

In plain words
What is it for?
Use it to collect local session history and identify new or updated sessions.
Why use it?
It helps you spot sessions that still need processing or summaries that no longer match the latest session data.

Command for Claude Code

Written for Claude Code: dynamic context !`command`. Also seen: mentions subagents.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/gengzezhou/memex/collect
Clone the repo
git clone --depth 1 https://github.com/GengzeZhou/memex

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for collect

README.md
[![agentmods](https://agentmods.dev/badge/commands/gengzezhou/memex/collect.svg)](https://agentmods.dev/commands/gengzezhou/memex/collect)
Your own site
<a href="https://agentmods.dev/commands/gengzezhou/memex/collect"><img src="https://agentmods.dev/badge/commands/gengzezhou/memex/collect.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 569 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00016 $0.00569
Opus 5 $0.00008 $0.00284
Sonnet 5 $0.00003 $0.00114
Haiku 4.5 $0.00002 $0.00057

Measured 6d ago against content hash f8d78fcc8156, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

collect scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/collect.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Collect Local History

!./scripts/collect.sh

Session Manifest Status

!`python3 -c " import json from pathlib import Path

manifest_path = Path('projects/.manifest.json') manifest = json.loads(manifest_path.read_text()) if manifest_path.exists() else {}

history_dir = Path('history/local') new_sessions = [] updated_sessions = [] current_files = {}

for f in sorted(Path('history/local/projects').rglob('*.jsonl')): if 'subagents' in str(f): continue rel = str(f.relative_to('history/local')) lines = sum(1 for _ in open(f)) current_files[rel] = lines

if rel not in manifest:
    new_sessions.append((rel, lines))
elif manifest[rel]['status'] == 'summarized' and lines > manifest[rel]['lines']:
    updated_sessions.append((rel, manifest[rel]['lines'], lines, manifest[rel].get('summary', '?')))
elif manifest[rel]['status'] == 'pending':
    new_sessions.append((rel, lines))

if new_sessions: print('NEW SESSIONS (need summarizing):') for path, lines in new_sessions: print(f' {lines:5d} lines {path}') print()

if updated_sessions: print('UPDATED SESSIONS (summary needs refresh):') for path, old, new, summary in updated_sessions: print(f' {old} -> {new} lines {path}') print(f' summary: {summary}') print()

if not new_sessions and not updated_sessions: print('All sessions are up to date.') else: print(f'Total: {len(new_sessions)} new, {len(updated_sessions)} updated') " `

Process each session listed above:

For NEW sessions: Read the JSONL file, understand the conversation, create a markdown summary, and add an entry to the manifest.

For UPDATED sessions: Re-read the JSONL file, focusing on content AFTER the previously processed line count. Update the existing summary file to include the new work. Update the manifest with the new line count.

After processing, update projects/.manifest.json by running:

manifest[rel_path] = {
    "lines": current_line_count,
    "last_timestamp": last_message_timestamp,
    "summary": "projects/ProjectName/YYYY-MM-DD_description.md",
    "status": "summarized"
}

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 74 lines · 16 tokens per session scan A f8d78fcc8156

Subscribe to this mod's changes

collect is a command published in the GitHub repository GengzeZhou/memex (10 stars, last pushed 5mo ago), licensed MIT. It adds 16 tokens to every session and 569 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.