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 its first real user message (injected context such as codex <recommended_plugins> or AGENTS.md instructions is skipped).

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, one module.
  • Extensible. Adding another agent is one REGISTRY entry plus two small functions (see below).

Install

pip install .            # from a checkout
pipx install .           # recommended: isolated environment

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 packages/session-ls/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.

Release files for session-ls 0.2.0

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.0
File Size Uploaded
session_ls-0.2.0.tar.gz 24.6 kB Details

Built distribution (wheel)

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

Total release size: 44.2 kB

Release files / session_ls-0.2.0.tar.gz

Download URL session_ls-0.2.0.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
54445ef60b95a6ce544942e072de7f613ac965808813858b78b4e19df04d0978
BLAKE2b-256 checksum
How to use checksums
51ddc43369907fa997e870630267cb54bb5b37d3da5538dc7bcfd75f39e6eb2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

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

Download URL session_ls-0.2.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
842095cb921bcbf1d642963d049c08b8156fd194de15229fa63a56186069a86b
BLAKE2b-256 checksum
How to use checksums
7d44a40f21149f534f4da3378f24582c96543345046b34b2bb26d21191d68946
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.1

2 release files

This release

0.2.0 This release

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