"Mine Codex sessions JSONL (`~/.codex/sessions`) and file-based memories (`~/.codex/memories`) for skill usage, section/format compliance, trigger evidence, token metrics, and prompt-to-session lookup for resume workflows. Use for prompts like `$seq`, `analyze session history`, `find sessions by prompt`, `rank skill mentions`, `audit missing sections`, `report token usage`, `mine memories`, or `use $seq to improve skill trigger descriptions/frontmatter`."
Resources
3Install
npx skillscat add tkersey/dotfiles/seq Install via the SkillsCat registry.
seq
Overview
Mine ~/.codex/sessions/ JSONL and ~/.codex/memories/ files quickly and consistently with a single script. Focus on skill usage, format compliance, token counts, and memory-file mining.
Quick Start
CODEX_SKILLS_HOME="${CODEX_HOME:-$HOME/.codex}"
CLAUDE_SKILLS_HOME="${CLAUDE_HOME:-$HOME/.claude}"
SEQ_SCRIPT="$CODEX_SKILLS_HOME/skills/seq/scripts/seq.py"
[ -f "$SEQ_SCRIPT" ] || SEQ_SCRIPT="$CLAUDE_SKILLS_HOME/skills/seq/scripts/seq.py"
run_seq() {
if command -v seq >/dev/null 2>&1 && seq --help 2>&1 | grep -q "skills-rank"; then
seq "$@"
return
fi
if [ "$(uname -s)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
if ! brew install tkersey/tap/seq; then
echo "brew install tkersey/tap/seq failed; refusing silent fallback." >&2
return 1
fi
if command -v seq >/dev/null 2>&1 && seq --help 2>&1 | grep -q "skills-rank"; then
seq "$@"
return
fi
echo "brew install tkersey/tap/seq did not produce a compatible seq binary." >&2
return 1
fi
if [ -f "$SEQ_SCRIPT" ]; then
uv run python "$SEQ_SCRIPT" "$@"
return
fi
echo "seq binary missing and fallback script not found: $SEQ_SCRIPT" >&2
return 1
}
run_seq datasets --root ~/.codex/sessionsCommands below use seq directly for brevity. This is the preferred Zig execution path. Use run_seq in places where brew-aware bootstrap and Python fallback behavior are required.
Query (JSON Spec)
Run flexible mining via query with a small JSON spec (inline or @spec.json).
List datasets:
seq datasets --root ~/.codex/sessionsShow dataset fields/params:
seq dataset-schema --dataset token_deltas --root ~/.codex/sessionsExamples:
Rank skill usage:
seq query --root ~/.codex/sessions --spec \
'{"dataset":"skill_mentions","group_by":["skill"],"metrics":[{"op":"count","as":"count"}],"sort":["-count"],"limit":20,"format":"table"}'Daily token totals (from token_count events):
seq query --root ~/.codex/sessions --spec \
'{"dataset":"token_deltas","group_by":["day"],"metrics":[{"op":"sum","field":"delta_total_tokens","as":"tokens"}],"sort":["day"],"format":"table"}'Top sessions by total tokens:
seq query --root ~/.codex/sessions --spec \
'{"dataset":"token_sessions","select":["path","total_total_tokens"],"sort":["-total_total_tokens"],"limit":10,"format":"table"}'Rank tool calls:
seq query --root ~/.codex/sessions --spec \
'{"dataset":"tool_calls","group_by":["tool"],"metrics":[{"op":"count","as":"count"}],"sort":["-count"],"limit":20,"format":"table"}'Memory files by category:
seq query --spec \
'{"dataset":"memory_files","group_by":["category"],"metrics":[{"op":"count","as":"count"}],"sort":["-count"],"format":"table"}'Ready-made specs
Prebuilt specs live in specs/.
seq query --root ~/.codex/sessions --spec @specs/skills-rank.json
seq query --root ~/.codex/sessions --spec @specs/tools-rank.json
seq query --root ~/.codex/sessions --spec @specs/tokens-top-days.json
seq query --root ~/.codex/sessions --spec @specs/tokens-top-sessions.json
seq query --root ~/.codex/sessions --spec @specs/tk-trend-week.jsonSpec reference
Top-level keys:
dataset(string, required)params(object, optional; dataset-specific)where(list of predicates, optional)group_by(list of field names, optional)metrics(list of aggregations, optional; defaultcountwhen grouping)select(list of field names, optional; for non-grouped queries)sort(list of field names; prefix with-for descending)limit(int, optional)format(table|json|csv|jsonl; default:tablewhen grouped, elsejsonl)
Where predicate shape:
{"field":"day","op":"eq","value":"2026-02-05"}Supported where.op:
eq,neqgt,gte,lt,lte(numeric-ish compare)in,nin(value is a JSON list)contains(substring)regex(value is a regex string; optionalcase_insensitive: true)exists,not_exists
Metrics shape (grouped queries):
{"op":"sum","field":"delta_total_tokens","as":"tokens"}Supported metrics.op:
countsum,min,max,avgcount_distinct
Tasks
1) Rank skill usage
seq skills-rank --root ~/.codex/sessionsCommon options:
--format json|csv--max 20--roles user,assistant--since 2026-01-01T00:00:00Z
2) Trend a skill over time
seq skill-trend --root ~/.codex/sessions --skill tk --bucket week3) Report on a specific skill
seq skill-report --root ~/.codex/sessions --skill tk \
--sections "Contract,Invariants,Creative Frame,Why This Solution,Incision,Proof" \
--sample-missing 3Another example:
seq skill-report --root ~/.codex/sessions --skill fix \
--sections "Contract,Findings,Changes applied,Validation,Residual risks / open questions" \
--sample-missing 34) Role breakdown by skill
seq role-breakdown --root ~/.codex/sessions --format table5) Audit section compliance
seq section-audit --root ~/.codex/sessions \
--sections "Contract,Invariants,Creative Frame" \
--contains "Using $tk" \
--sample-missing 56) Export occurrences
seq occurrence-export --root ~/.codex/sessions --format jsonl --output occurrences.jsonl7) Bundle a report
seq report-bundle --root ~/.codex/sessions \
--top 20 --skills tk,fix \
--sections "Contract,Invariants,Creative Frame,Why This Solution,Incision,Proof"8) Token usage summary
seq token-usage --root ~/.codex/sessions --top 109) Reproducible perf harness
Run stable workloads with fixed warmup/sample counts and optional baseline comparison.
zig build bench -Doptimize=ReleaseFast -- --config perf/frozen/workload_config.jsonHead-to-head Zig vs Python gate (runs parity first):
scripts/perf/head_to_head.sh --root testdata/golden/sessions --gate 20 --samples 9 --warmup 1Differential parity against the Python oracle:
scripts/parity/run_diff.sh --root ~/.codex/sessions/2026/02/1910) Find sessions by prompt text
seq find-session --root ~/.codex/sessions --prompt "adapter=auto" --limit 2011) List prompts/messages for one session
seq session-prompts --root ~/.codex/sessions --session-id <session_id> \
--roles user,assistant --strip-skill-blocks --limit 100Notes
- Default root:
~/.codex/sessions. memory_filesdefaults to~/.codex/memoriesand acceptsparams.memory_rootto override.- Skill names are inferred from
${CODEX_HOME:-$HOME/.codex}/skillsby default, with fallback to${CLAUDE_HOME:-$HOME/.claude}/skillswhen needed. - Runtime bootstrap policy: prefer the Zig
seqbinary; on macOS withbrew, treatbrew install tkersey/tap/seqfailure (or incompatible binary) as a hard error; useuv run python "$SEQ_SCRIPT"only when no compatibleseqbinary is available. - Add
--output <path>to write results to a file. queryauto-projects only referenced dataset fields (where,group_by,metrics.field,select, and non-groupedsort) to reduce scan overhead.find-sessionreturnssession_idandpath; use these to target follow-onqueryor resume workflows.session-promptsdefaults to--roles user; set--roles user,assistantto include both sides of a conversation.session-promptsdeduplicates mirrored duplicate rows by default; pass--no-dedupe-exactto keep all duplicates.- Typical flow: run
find-session, then pass the returnedsession_idintosession-prompts --session-id <id>.
Resources
seqbinary: CLI for ranking skills, auditing sections, querying datasets, and summarizing token usage.zig build bench -Doptimize=ReleaseFast -- --config perf/frozen/workload_config.json: frozen-workload performance runner.scripts/parity/run_diff.sh: Zig/Python differential parity harness.scripts/perf/head_to_head.sh: parity-gated head-to-head p50 speed benchmark.