Skip to main content

Privacy-first CLI that turns shell history into searchable memory

Project description

mem

Your shell history, understood. Not just searched.

A privacy-first CLI that turns your terminal history into an intelligent,
searchable memory system — powered by on-device AI, with zero cloud dependencies.

macOS 26+ Python 3.10+ License: MIT Privacy: 100% on-device

mem demo


Unlike Ctrl+R, mem knows where you are. The same query returns different results depending on your current git repository — because kubectl apply means something different in your infra repo than in your backend repo.

Unlike cloud-based history tools, nothing ever leaves your machine. Every command, pattern, and session stays in plain text files you can cat, grep, and tail.

Features

  • Context-aware search — results ranked by your current git repo, not just recency
  • AI pattern extraction — learns that kubectl get pods, kubectl get services, kubectl get deployments are all kubectl get <resource>
  • 100% on-device — uses Apple Foundation Models locally. Zero network. Zero telemetry
  • Plain text storage — everything in ~/.mem/ as JSONL files. Inspect with cat. Search with grep
  • Silent capture — shell hook adds <5ms to prompt. You won't notice it
  • Session replay — recall the exact sequence of commands from last Tuesday's debugging session

Quick start

1. Install

# Homebrew (recommended)
brew install matinsaurralde/tap/mem

# Quick install script
curl -fsSL https://raw.githubusercontent.com/matinsaurralde/mem/main/install.sh | bash

# pip / pipx
pipx install mem-cli

2. Activate

echo 'eval "$(mem init zsh)"' >> ~/.zshrc
source ~/.zshrc

3. Use your terminal

Every command is silently captured with full context — directory, git repo, exit code, duration.

4. Search

mem deploy
 1  kubectl apply -f deployment.yaml    infra       2h ago
 2  docker compose up -d                backend     1d ago
 3  fly deploy                          api         3d ago

That's it. mem gets smarter the more you use it.

Usage

Search history

mem kubectl                    # search by keyword
mem "docker compose"           # search by phrase
mem deploy -n 20               # show more results
mem deploy --json              # machine-readable output

See patterns

After running mem sync, mem uses on-device AI to extract structural patterns from your history:

mem kubectl --pattern
Patterns for "kubectl":

  kubectl get <resource>
  kubectl describe <resource> <name>
  kubectl logs <pod> [--tail=<n>]
  kubectl apply -f <file>

Recall sessions

mem session "api outage"
+-----------------------------------------+
| Session: 2026-03-07 14:30  myapp        |
|-----------------------------------------|
|  1  kubectl logs api-7f9b --tail=100    |
|  2  kubectl get pods -n production      |
|  3  kubectl rollout restart deploy api  |
|  4  curl -s localhost:8080/health       |
+-----------------------------------------+

Replay a session? [number/n]: _

More commands

mem stats                      # top commands, repos, totals
mem sync                       # extract patterns + clean old data
mem forget "API_KEY=sk-..."    # permanently delete sensitive commands
mem init zsh                   # print shell hook code

How it works

You type a command
        │
        ▼
   Shell hook (preexec/precmd)
        │
        ▼
   mem _capture  ← runs in background, <5ms
        │
        ▼
   Append one JSON line to ~/.mem/repos/<repo>.jsonl

When you search, mem reads the JSONL file for your current repo and scores each command:

score = (frequency × 0.4) + (recency × 0.4) + (context × 0.2)
  • Frequency — how often you've run this exact command
  • Recency — exponential decay with a 7-day half-life
  • Context — 1.0 if same repo, 0.5 if same directory prefix, 0.0 otherwise

Pattern extraction uses Apple Foundation Models running entirely on-device. No API keys, no cloud calls, no data exfiltration — just your Mac's neural engine.

Storage

All data lives in ~/.mem/ as human-readable plain text:

~/.mem/
  repos/
    infra-k8s.jsonl          # commands from this git repo
    backend.jsonl
    _global.jsonl            # commands outside any repo
  sessions/
    2026-03-05.jsonl         # grouped work sessions
  patterns/
    kubectl.json             # AI-extracted patterns
    docker.json

Every file is inspectable:

cat ~/.mem/repos/myapp.jsonl
tail -f ~/.mem/repos/myapp.jsonl    # watch commands arrive in real-time
grep "docker" ~/.mem/repos/*.jsonl  # search across all repos with grep

Privacy

mem is built on a simple promise: your shell history never leaves your machine.

  • Zero network requests — not even update checks
  • Zero telemetry — no usage tracking, no analytics, no crash reports
  • Zero cloud dependencies — works fully offline, always
  • On-device AI only — Apple Foundation Models run on your Mac's neural engine
  • Plain text storage — no proprietary formats, no encrypted blobs. You own your data

Read more in PHILOSOPHY.md.

Requirements

Requirement Version
macOS 26.0+
Python 3.10+
Apple Intelligence Enabled (for pattern extraction)

Note: mem works without Apple Intelligence — you just won't get AI-extracted patterns. Search, capture, and everything else works fine.

Installation

Homebrew

brew tap matinsaurralde/tap
brew install mem

Quick install

curl -fsSL https://raw.githubusercontent.com/matinsaurralde/mem/main/install.sh | bash

pipx (recommended for Python users)

pipx install mem-cli

From source

git clone https://github.com/matinsaurralde/mem.git
cd mem
pip install -e ".[ai]"     # with AI pattern extraction
pip install -e "."         # without AI (search-only)

Shell setup

After installation, add the hook to your shell:

# zsh (v1)
echo 'eval "$(mem init zsh)"' >> ~/.zshrc
source ~/.zshrc

Bash and fish support coming in v1.5.

Data retention

mem never grows unbounded. Running mem sync automatically cleans old data:

Data Retention Rationale
Commands 90 days High-volume, older ones rarely recalled
Sessions 30 days Useful for recent postmortems
Patterns Forever Small files, accumulated learning

Override defaults: mem sync --keep-commands 180 --keep-sessions 60

Uninstall

brew uninstall mem          # or: pipx uninstall mem-cli
rm -rf ~/.mem               # remove all captured data

Remove the eval "$(mem init zsh)" line from your ~/.zshrc.

Contributing

Contributions are welcome. Please read the PHILOSOPHY.md first to understand the principles that guide this project.

git clone https://github.com/matinsaurralde/mem.git
cd mem
pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cli_mem-0.1.0.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cli_mem-0.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file cli_mem-0.1.0.tar.gz.

File metadata

  • Download URL: cli_mem-0.1.0.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for cli_mem-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d8d2c59337fb9d2e6b0f859d9325b466cd062bb19da341d163b69b98b79efa3
MD5 d011afc068187352facccee377966b6f
BLAKE2b-256 0647403f9af436585826995cf9beebd3ad47988140bb1df7659a4dfd7f832d1c

See more details on using hashes here.

File details

Details for the file cli_mem-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cli_mem-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for cli_mem-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19a43af1b46f8706dcc098d3afc1f9512c805b81ef94c3fb47646036bafae27f
MD5 6f5738ba584443885a53e0eb85664610
BLAKE2b-256 1850fdc00b5453fdcd8c9611c6a4ac29e3792b64d83c7c66f927b43327731d37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page