Skip to main content

session-ls

List and search session history across all coding agents on your machine: pi, codex, claude, cursor.

$ session-ls -n 3
AGENT   STARTED              LAST                  CWD                            TITLE
codex   2026-07-29T00:03:17  2026-07-29T00:21:15   /home/alice/projects/website   fix the login redirect loop
pi      2026-07-17T14:42:45  2026-07-18T08:45:13   /home/alice/projects/backend   tune the postgres connection pool
claude  2026-06-15T03:08:57  2026-06-15T03:31:55   /home/alice/dotfiles           migrate to starship prompt

Sessions are read directly from each agent's local store, newest first. The title of a session is the first thing the person actually typed. Injected context (plugin lists, AGENTS.md, environment blocks, image wrappers, slash-command echoes) is skipped part by part, and wrapped requests are unwrapped: Codex desktop's ## My request:, a thread goal's <objective>, and chat bridges' <user_input>.

Design

  • Fast. Metadata is cached in ~/.cache/session_ls_cache.json, keyed by file size + mtime; unchanged files are never re-read. Listing ~1000 sessions takes milliseconds. Full-text search streams literal matches and decoded JSON Unicode text.
  • Plain search, no semantics. No index, no embeddings, no network. Matching is literal substring comparison. Decide what's relevant yourself - or hand the file paths to an LLM.
  • Lightweight, zero dependencies. Pure stdlib: a legacy session-ls CLI, and a versioned typed API (session_ls.api) for programs such as 4top.
  • Extensible. Adding another agent is one REGISTRY entry plus two small functions (see below).

Install

uv tool install session-ls   # or:
pipx install session-ls      # isolated environment
pip install session-ls       # into the current environment
pip install -e '.[dev]'      # from a checkout, to work on it

Requires Python >= 3.9. A man page (session-ls(1)) is installed alongside; on macOS venvs, point MANPATH at the venv's share/man to see it.

Usage

session-ls [KEYWORD] [OPTIONS]
Option Meaning
KEYWORD search titles (first user message), case-insensitive substring
-f, --full search full session content instead of titles (literal decoded-text scan)
-a, --agent only this agent: pi, codex, claude, cursor
-c, --cwd only sessions under a cwd substring
--since DATE started on/after (YYYY-MM-DD)
--until DATE last active on/before (YYYY-MM-DD)
-n, --limit N show only the N newest
-l, --list print file paths only (for piping)
--json JSON Lines output (keys: agent, cwd, started, last, title, file)

Examples

session-ls -n 10                              # ten most recent sessions
session-ls websocket                              # title search
session-ls "immich 2283" -f                  # full-content search
session-ls -a pi -c nemo --since 2026-08-01   # filters combine
session-ls websocket -l | xargs head -1          # inspect raw matches
session-ls websocket --json | jq -r .file        # feed paths to other tools

Supported agents

Agent Store Timestamps
pi ~/.pi/agent/sessions/<encoded-cwd>/*.jsonl in file
codex ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl (+ archived_sessions/) in file
claude ~/.claude/projects/<encoded-cwd>/*.jsonl in file
cursor ~/.cursor/projects/*/agent-transcripts/<id>/<id>.jsonl file mtime (none in file)

Adding an agent

Append an entry to REGISTRY in src/session_ls/__init__.py:

  1. a glob of session files
  2. meta_parser(f, head) -> (cwd, started_iso) | None
  3. user_text(line) -> first real user text | '' (drives the early-exit read)
REGISTRY = [
    # (name, glob, meta-parser, user-text-extractor)
    ("myagent", os.path.join(HOME, ".myagent/sessions/*.jsonl"),
     _myagent_meta, _myagent_user),
]

Agent skill

For AI agents (pi et al.), skills/session-ls/SKILL.md is a ready-to-install skill: when to use session-ls, common flag combos, and how to pipe results into a read of the underlying session files. Copy skills/session-ls into your agent's skills directory to enable it.

Development

python -m pytest tests/        # plain asserts, also runnable via pytest
python -m session_ls ...       # run from a checkout

License

MIT

0.2 API

session_ls.api exposes explicit Root, HistoryIndex, HistoryRecord, search_full, and excerpt objects. Inject roots/cache/host identity rather than changing process-global HOME. The legacy command still emits the same six JSON fields. Package imports do not change SIGPIPE. No TUI dependencies are required.

HistoryRecord.subagent is true for a session another agent session started for itself (Codex thread_spawn workers and the guardian approval reviewer), and HistoryRecord.parent is the spawning session's native id when the child names it. Both default to "not a subagent".

Metadata

Release files for session-ls 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for session-ls 0.2.3
File Size Uploaded
session_ls-0.2.3.tar.gz 34.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for session-ls 0.2.3
File Interpreter ABI Platform
session_ls-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 57.8 kB

Release files / session_ls-0.2.3.tar.gz

Download URL session_ls-0.2.3.tar.gz
Size 34.7 kB
Tags Source
SHA-256 checksum
How to use checksums
aa46f73243efece0c0afd8945d96f170b2cd1b1d54cd7d4bfe410e6887a6de65
BLAKE2b-256 checksum
How to use checksums
ca90a31edc78eb508fd3ce6f135583c0e21fdc8025d6c01e8d0a461b9e6c9d9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / session_ls-0.2.3-py3-none-any.whl

Download URL session_ls-0.2.3-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd7d7760806eca8b8868bbfedb54d1eb665c033bb84fe740bda350623facb569
BLAKE2b-256 checksum
How to use checksums
c3114f002acf35395c2de2146c70a06921caa5be977a40ee7624692a99f84c3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.4

2 release files

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page