cass Session Search

SkillAI & models

Mine past agent sessions for working prompts, decisions, and patterns. Use when "what did I ask?", "find that prompt", session archaeology, or agent history.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the cass Session Search skill

What this skill tells your AI

The instructions your AI receives, as published by dicklesworthstone/agent_flywheel_clawdbot_skills_and_integrations in skills/cass/SKILL.md and read by ahel’s review.

Table of Contents

  • The Goldmine Principle
  • THE EXACT PROMPT — Discovery Workflow
  • Version Pinning Caveat
  • Two-Step Bootstrap (Replaces "ALWAYS first")
  • Stuck-Index & Recovery Decision Tree
  • Quick Reference
  • When to Use What
  • Critical Rules
  • Agent Harness Exclusion
  • Search Modes
  • Cross-Machine Search (Multi-Workstation Corpus)
  • Anti-Patterns (Don't Do These)
  • Resume a Past Session in Its Native Harness
  • The Heuristics
  • jq Essentials
  • Hidden Power: Capabilities the Old Skill Missed
  • Token & Cost Analytics (Bonus Use Case)
  • Recovery Cheat Sheet (No-Permission Moves)
  • Reference Index
  • Quick Search (Grep Recipes for References)
  • Scripts
  • Validation

Core Insight: Your repeated prompts are your best prompts. If you typed it 10+ times, it works. Mine your history.

The Goldmine Principle

Your conversation history contains:

  • Refined prompts — Every rephrase that worked better was captured
  • Working rituals — Prompts repeated 10+ times ARE your methodology
  • Scope decisions — "When did we decide NOT to do X?"
  • Recovery moments — What you searched for after context loss = what mattered

The insight: Mining your past beats inventing new approaches.


THE EXACT PROMPT — Discovery Workflow

1. Bootstrap: Check health, refresh index, get project overview
   cass status --json && cass index --json
   cass search "*" --workspace /data/projects/PROJECT --aggregate agent,date --limit 1 --json

2. Find prompts: Search for keywords, filter to user prompts (lines 1-3)
   cass search "KEYWORD" --workspace /data/projects/PROJECT --json --fields minimal --limit 50 \
     | jq '[.hits[] | select(.line_number <= 3)]'

3. Follow hits: View the actual content
   cass view /path/from/source_path.jsonl -n LINE -C 20

4. Expand context: See the full conversation flow
   cass expand /path/from/source_path.jsonl --line LINE --context 3

5. Discover related: Find the whole work cluster
   cass context /path/from/source_path.jsonl --json

Why This Workflow Works

  • Aggregations first — Know the terrain before diving in
  • --fields minimal — 5x smaller output, preserves context window
  • line_number <= 3 — User prompts live at the top of sessions
  • Context clustering — Work happens in clusters; one good hit → many related sessions

Version Pinning Caveat

cass evolves quickly. The skill describes HEAD behavior (latest source in /dp/coding_agent_session_search). The released v0.3.6 binary lacks several features added since:

  • cass sources agents {list,exclude,include} — added 2026-04-20 (commit 82d8d70e)
  • Tail-end writer-race tolerance for full rebuilds — fixed 2026-04-22 (commit e06342f2, bead zz8ni)
  • Lexical generation manifests for federated installs (commits 2b7b86a1, 683ccd03, cf76fe15)
  • Rebuild producer stall telemetry (commit 73a86604)

When a flag/subcommand returns "unrecognized" or behaves differently than documented, run cass --version and check git log -- src/lib.rs for the relevant commit. Each affected section calls out which commit/version it depends on.

Probe what your installed binary actually supports:

cass capabilities --json | jq '{version: .crate_version, features, connectors}'
cass introspect --json   | jq '.commands[].name'

Two-Step Bootstrap (Replaces "ALWAYS first")

Three states matter — never conflate them.

StateWhat it meansWhat to do
cass health exit 0Sub-50ms preflight passedSearch immediately
cass health exit 1 + index.stale=trueIndex is usable but oldSearch now, refresh in background with a wall-clock cap: ( timeout 600 cass index --json &>/tmp/cass-bg.log </dev/null & ) (NEVER bare & — cass index can hang)
cass status returns database.exists=false OR documents=0Truly broken/uninitializedRun cass doctor --fix --json, then cass index --full --json

The trap: Treating a stale index as broken triggers an unneeded full rebuild (8–25s cost) when an incremental refresh (1–3s) or even a stale-but-correct query would have worked.

# Robust two-step bootstrap that never blocks the user.
# IMPORTANT: every cass index call gets a wall-clock cap. cass index has been
# observed to hang indefinitely under contention — without `timeout`, the
# bootstrap itself becomes the symptom.
cass status --json | jq '{healthy, fresh: .index.fresh, stale: .index.stale, db: .database.exists, sem: .semantic.available}'

# Refresh policy: stale → bg refresh (capped); never block search
if [ "$(cass status --json | jq -r '.index.stale')" = "true" ]; then
  ( timeout 600 cass index --json >"/tmp/cass-index.$$.log" 2>&1 </dev/null & ) 2>/dev/null
fi
# Search even with stale index — results are still useful
cass search "KEYWORD" --workspace /path --json --fields minimal --limit 10

For the production-quality version of this logic (cap-on-every-call, broken-state escalation, exit-code semantics for hooks), use scripts/recover.sh — it implements the full decision tree with timeouts and per-PID logs.

cass health returning exit 1 on stale is a deliberate preflight signal for cron/CI. In an interactive agent loop, prefer cass status --json and decide.


Stuck-Index & Recovery Decision Tree

Real-world bugs we've hit (all observed in mined sessions). Walk top-down — first match wins.

SymptomLikely causeAutonomous fix (no user prompt needed)
cass index --json streams phase: indexing, current: 0, total: N for >2 minOPEN issue #196 in v0.3.6: incremental hangs after prior --force-rebuildKill the run, then cass index --full --force-rebuild --json (25s typical)
cass status shows index.rebuilding=true and pid is stale (>1h)Crashed indexer left lockcass doctor --fix --json (removes stale .index.lock automatically)
cass search returns 0 hits but the file plainly contains the termTerm lives in tool stdout/stderr (skipped at index time)Fall back to rg -n "TERM" /path/to/session.jsonl
cass search --workspace /X returns 0; same query without --workspace worksWorkspace string mismatchcass search "KEYWORD" --aggregate workspace --limit 1 --json to discover the canonical path, then re-run
vtable constructor failed: fts_messages (older bug, fixed in 0.3.0+)DB↔FTS schema drift after upgradecass doctor --fix --json rebuilds the Tantivy side from SQLite
--limit 0 panicEarlier cass versions panicked on limit=0Always pass --limit 1 (or --limit 5) for aggregations
Massive core.NNNNN files in cass project dirPast indexer crash recorded a coredumpThey're SAFE to leave; they don't affect search. Only delete with explicit user permission.
cass models install fails with WSAENOTCONN on Windows (closed #193)Network blip during huggingface downloadRetry once; if it persists, use --mirror <URL> to point at a different HF mirror, or --from-file <DIR> if you have the model cached locally. Then cass models verify.
cass index says "Index rebuild is already in progress" but nothing visibleConcurrent agent triggered a rebuildDon't fight it — `cass status --json
cass index --full --force-rebuild --json runs for 200s+ then exits with "index failed: updating last_indexed_at after index run ... database is busy"Concurrent-rebuild race in persist_final_index_run_metadata. Fixed at HEAD (commit e06342f2, bead zz8ni); affects v0.3.6 and earlier.Verify the index data is good: `cass search "X" --limit 1 --json
cass status shows unhealthy indefinitely after a successful-looking rebuildSame as above — timestamp marker never landedSame fix: confirm searches return hits, then a single quiet cass index --json writes the marker. Upgrade past v0.3.6 for the proper fix

Never paper over by skipping cass and falling back to manual find/grep. The autonomous fixes above resolve every real failure without user intervention. Asking the user to "rebuild your index" is the worst outcome — they have agents waiting.


Quick Reference

# Health + refresh (ALWAYS first)
cass status --json && cass index --json

# Project overview: who did what, when?
cass search "*" --workspace /path --aggregate agent,date --limit 1 --json

# Find keyword, minimal output
cass search "KEYWORD" --workspace /path --json --fields minimal --limit 50

# Follow a hit
cass view /path.jsonl -n LINE -C 20        # Line-oriented
cass expand /path.jsonl --line LINE --context 3  # Message-oriented

# Find related sessions
cass context /path.jsonl --json

# Export for parsing
cass export /path.jsonl --format json --include-tools -o /tmp/out.json

# Inspect or change persistent agent-harness exclusions
cass sources agents list --json
cass sources agents exclude openclaw
cass sources agents exclude openclaw --keep-indexed-data
cass sources agents include openclaw

When to Use What

You WantUseWhy
Project overview--aggregate agent,date --limit 1Counts only, no content
Find prompts--fields minimal + jq select(.line_number <= 3)User prompts are lines 1-3
Ritual detectionCount matches: >10 = ritualRepeated = working
Full conversationcass expand --context 3Message boundaries preserved
Raw JSON parsingcass export --include-tools -o file.jsonNever pipe exports
Content not foundrg "string" /path.jsonlcass skips tool outputs
Noisy harness flooding indexcass sources agents exclude <agent>Persistently disable future indexing

Critical Rules

RuleWhyConsequence
--limit 1 minimum--limit 0 panicsUse 1 for aggregations
--fields minimalToken efficiency5x smaller output
Export to filePiping causes broken pipe panic-o /tmp/out.json always
Exact workspace pathsCase-sensitive matchingUse --aggregate workspace to discover
--include-toolsTool calls hidden by defaultRequired for full export

Agent Harness Exclusion

When a user tells you one agent harness is producing garbage, loops, or too much disk usage, handle that directly in cass instead of telling them it cannot be excluded.

# See current state
cass sources agents list --json

# Persistently stop indexing this harness in future scans/syncs/watch mode
cass sources agents exclude openclaw

# Keep already indexed data but block future indexing
cass sources agents exclude openclaw --keep-indexed-data

# Re-enable later
cass sources agents include openclaw

What exclude actually does

  • Writes the preference to sources.toml, so the setting survives future runs
  • Prevents future indexing even if the source files still exist on disk
  • By default, purges already archived local data for that harness and rebuilds lexical search so the exclusion also reclaims space

When to use it

  • A harness is spamming looped or low-value output
  • A user wants cass to remember "ignore this source going forward"
  • You need a reversible, agent-friendly way to reduce archive bloat without manually deleting source files

Search Modes

ModeWhenExample
lexical (default)Exact strings, filenames"AGENTS.md", "--workspace"
semanticConceptual, unknown wording"scope reduction discussions"
hybridBroad exploration"architecture decisions"

Default to lexical. Only use semantic when you don't know exact wording.

Enabling Semantic / Hybrid (one-time)

cass models status --json    # state: not_installed | installed | partial
cass models install          # downloads ~90MB MiniLM bundle from HuggingFace
cass index --semantic --build-hnsw --json   # builds vector + HNSW
cass search "QUERY" --mode hybrid --json    # then queries fall back to lexical if semantic missing

If the model is not_installed, --mode hybrid and --mode semantic silently fall back to lexical — no panic, no degraded experience. See SEMANTIC_AND_HYBRID.md.


Cross-Machine Search (Multi-Workstation Corpus)

When the user has agents running on css, csd, ts1, ts2, etc., the cass corpus on each machine is disjoint. Three ways to reach across:

# Option A: One-shot remote query (no setup, slow per call)
ssh css 'cass search "KEYWORD" --json --fields minimal --limit 20' | jq '.hits'

# Option B: Configured sources (preferred — caches the remote sessions locally)
cass sources setup                                      # interactive wizard, auto-discovers from ~/.ssh/config
cass sources add ssh://user@css --name css --preset linux-defaults
cass sources sync --source css --json                   # rsyncs new sessions, then re-indexes
cass search "KEYWORD" --json                            # results now span all configured sources
cass sources list --json                                # see what's wired up

# Option C: Parallel fan-out (when speed matters more than dedup)
for h in css csd ts1 ts2; do
  ssh "$h" 'cass search "KEYWORD" --json --fields minimal --limit 10' > "/tmp/cass-$h.json" &
done
wait
jq -s '[.[] | .hits[]] | unique_by(.source_path + (.line_number|tostring))' /tmp/cass-*.json

cass sources doctor diagnoses connectivity. Configured-source results carry origin_host in their hit metadata — preserve it when reporting back to the user. Full reference: REMOTE_SOURCES.md.


Anti-Patterns (Don't Do These)

Anti-patternWhy it's wrongDo instead
Asking the user "should I rebuild the index?"They have agents waiting; rebuild is safe and idempotentJust run cass doctor --fix --json (preserves source data)
Running cass index --full whenever status says unhealthyA 25s rebuild for a 30-min stale index is wastefulCheck index.stale separately from database.exists; prefer incremental
Running bare cass to "see what's there"Launches blocking TUI in the agent's sessionAlways --json or --robot; never bare
Piping cass export into head/jqBroken-pipe panic on large sessionscass export ... -o /tmp/x.json first, then operate on the file
Treating subagent files as the same as parent sessionsSubagents are separate conversation logs with their own line-2 promptFilter by select(.source_path | contains("subagent"))
Using --limit 0 for "no limit"Earlier cass panics; modern cass caps to RAM ceiling but rarely what you wantUse a real limit (--limit 50) or pagination via --cursor
Searching with --workspace /X and trusting 0 hitsWorkspace strings are case-sensitive and trailing-slash-sensitiveWhen 0 hits but you expected some, re-run with --aggregate workspace --limit 1 to discover the canonical key
Skipping --fields minimal on wide scansDefault full returns ~3KB per hit × 100 hits = 300KB context burnAlways pass --fields minimal for wide passes; upgrade to summary/full for the few you keep
Reading session file with cat to extract a promptLoads the full conversation into contextcass view PATH -n LINE -C 5 (window) or cass expand PATH --line LINE --context 3 (message-aware)
Re-indexing on every cass searchWasteful; index is shared across processesIndex is shared. Only refresh when cass status says stale or recommended_action says so

Resume a Past Session in Its Native Harness

cass resume resolves a session path into the exact command its native CLI uses to continue the conversation — Claude Code, Codex, Gemini, OpenCode, pi_agent.

# Find a relevant past session
cass search "KEYWORD" --json --fields minimal --limit 5 \
  | jq -r '.hits[0].source_path' > /tmp/sess.path

# Print the resume command without executing
cass resume "$(cat /tmp/sess.path)" --shell

# Or replace the current process with the resumed agent
cass resume "$(cat /tmp/sess.path)" --exec

Pitfall: Subagent files (subagents/agent-*.jsonl) are not resumable by design — they're orchestrated by a parent. You'll get session_id_not_found with a hint to pass --agent claude. Resolve to the parent session via cass context <path> --json first. See RESUME.md.


The Heuristics

SignalMeaningAction
line_number 1-3User promptsFilter: select(.line_number <= 3)
/subagents/ line 2THE extraction promptCopy-paste ready
total_matches > 10Ritual patternDocument it, reuse it
0 results + content existsWorkspace path mismatchUse --aggregate workspace

jq Essentials

# User prompts only
| jq '[.hits[] | select(.line_number <= 3)]'

# Source paths for follow-up
| jq '.hits[].source_path' -r

# Aggregation buckets
| jq '.aggregations.agent.buckets'

# Count matches
| jq '.total_matches'

# Find repeated prompts (ritual detection)
| jq '[.hits[] | select(.line_number <= 3) | .title[0:80]] | group_by(.) | map({prompt: .[0], count: length}) | sort_by(-.count) | .[0:20]'

Hidden Power: Capabilities the Old Skill Missed

CommandWhat it gives youWhen
cass health<50ms exit-code-only preflightCron / hook gating
cass index --watch --jsonFilesystem-watcher keeps index live; one cycle = --watch-once /pathLong-running orchestrator hosts
cass index --idempotency-key K --jsonCached identical-key responses for 24hRetried CI runs
cass index --semantic --build-hnswO(log n) approximate vector searchAfter cass models install
cass doctor --fix --jsonAuto-rebuilds index from DB; backs up corrupt DB to .corrupt.<ts>Any time status.healthy=false
cass resume PATH --shellCross-harness resume command emitterContinuing a past Codex/Claude/Gemini session
cass sources setupInteractive ssh-config-aware multi-machine wizardFirst time wiring a fleet
cass sources sync --source NAME --jsonrsync remote sessions, then re-indexPeriodic fleet refresh
cass sources doctor --jsonConnectivity + path probeBefore relying on cross-machine results
cass sources mappings ...Rewrite source paths to local equivalentsAfter moving a workspace
cass sources agents {list,exclude,include}Persistent harness exclusion (writes disabled_agents in ~/.config/cass/sources.toml)When openclaw / a noisy connector floods the index
cass models install / status / verify / removeManage the MiniLM bundle (~90MB)Enabling semantic search
cass analytics tokens | tools | modelsPer-day/per-tool/per-model usage stats from indexed sessionsCost reports, regression checks
cass analytics rebuild --jsonBackfill rollup tables when coverage_pct is lowAfter bulk import or sources sync
cass analytics validate --jsonDetect drift between raw rows and rollupsSanity check before reporting numbers
cass import chatgpt PATHBring conversations.json exports from ChatGPT web into the corpusMigrating off ChatGPT.com
cass export-html PATH --password ...Encrypted, self-contained HTML conversation viewerSharing one session with a teammate
cass pages encrypt ARCHIVE --with-recoveryEncrypted searchable archive for static hostingPublishing a redacted corpus
cass introspect --jsonFull schema dump of every command + responseProgrammatic discovery
cass capabilities --jsonFeature/connector/limits for self-configurationVersion-aware fallbacks
cass robot-docs guide | commands | examples | schemas | contractsBuilt-in machine-targeted docsInside an agent loop, when the skill isn't enough
cass --robot-format jsonl | compact | toon | sessionsStreaming / token-optimized / shell-pipeable outputLarge result sets, chained searches
cass --trace-file FILESpan timing JSONL for debugging slow runsTriage perf issues

If a flag listed here errors as "unrecognized" the installed cass binary is older than the source. Check cass --version against git log -- src/lib.rs upstream — most missing commands were added in v0.3.x.


Token & Cost Analytics (Bonus Use Case)

# Daily token usage across your whole agent fleet
cass analytics tokens --days 30 --group-by day --json | jq '.data.buckets[].api_tokens'

# Per-agent tool-use intensity (rows are keyed by agent slug, not tool name)
cass analytics tools --days 30 --json | jq '.data.rows[0:10]'

# Top models by API tokens
cass analytics models --json | jq '.data.by_api_tokens.rows[0:10]'

# After import / sync, refresh rollups
cass analytics rebuild --json
cass analytics validate --json   # confirm no drift between raw and rollup

cass analytics status --json shows coverage_pct: anything below ~90% means you should analytics rebuild to backfill. See ANALYTICS.md.


Recovery Cheat Sheet (No-Permission Moves)

You are pre-authorized to take any of these actions to keep the corpus searchable. None destroy source session data; they only rebuild derived index data.

cass doctor --json --verbose         # Diagnose without changing anything
cass doctor --fix --json             # Apply safe rebuilds; backs up bad DB to .corrupt.<ts>
cass doctor --fix --force-rebuild --json   # Same, but rebuild even when healthy
cass index --full --force-rebuild --json   # Workaround for OPEN issue #196 (incremental hang)
cass sources doctor --json           # Probe remote sources
cass sources sync --source NAME --json     # Re-fetch and re-index a single source
cass models install                  # Restore missing semantic model
cass models verify                   # Validate model file checksums

What you must NOT do without explicit permission: delete core.NNNNN files, delete .beads/, git reset --hard, edit anything under the user's .config/cass/sources.toml by hand. The CLI commands above already do everything safely.

Full disaster recovery for encrypted Pages archives: RECOVERY.md.


Reference Index

Shortened here. Read the whole file on GitHub.

Signals

GitHub stars
73
Forks
16
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
cass-dicklesworthstone
Source
github.com/dicklesworthstone/agent_flywheel_clawdbot_skills_and_integrations