Skip to main content

Semantic grep for the terminal — search files by meaning, not pattern

Project description

semfind

Semantic grep for the terminal. Search files by meaning, not pattern.

grep finds exact text matches. semfind finds lines that mean the same thing. Search your logs, notes, docs, or any text file using natural language — no regex needed.

Why semfind?

Traditional grep fails when you don't know the exact wording. If your log says "container build failed due to missing environment variables" but you search for "deployment issue", grep finds nothing. semfind finds it instantly because it understands meaning.

Built for AI agents. Tools like OpenClaw and other AI agents need lightweight semantic search over local files — searching memory, history, and context without spinning up a full vector database. semfind is a single CLI command with auto-caching that agents can call directly from the shell.

Also great for humans. Search your markdown notes, project logs, documentation, or any text files by what you mean, not what you remember typing.

Key features

  • No API keys — runs 100% locally using fastembed (BAAI/bge-small-en-v1.5) + FAISS
  • Auto-caching — indexes files on first search, caches embeddings, auto-invalidates when files change
  • Fast — ~2s cold start, 14ms cached queries, 252MB RAM
  • Grep-like output — colored results with file, line number, and similarity score
  • Zero config — just pip install semfind and go

Install

pip install semfind

Usage

# Search a file
semfind "deployment issue" logs.md

# Search multiple files, top 3 results
semfind "permission error" memory/*.md -k 3

# Show 2 lines of context around each match
semfind "database migration" notes.md -n 2

# Force re-index (ignore cache)
semfind "query" file.md --reindex

# Set minimum similarity threshold
semfind "auth bug" *.md -m 0.5

Output

memory/HISTORY.md:9: [2026-01-15 10:30] DEPLOYMENT: Fixed docker build...  (0.796)
memory/HISTORY.md:3: [2026-01-17 09:15] FILE_PERMS: Agent couldn't...     (0.689)

How it works

  1. On first search, each file's non-empty lines are embedded and cached in ~/.cache/semfind/
  2. Cache is keyed by file content hash — changes auto-invalidate
  3. Your query is embedded and compared via FAISS inner-product search
  4. Results are printed grep-style with similarity scores

Options

Flag Description Default
-k, --top-k Number of results 5
-n, --context Context lines before/after 0
-m, --max-distance Minimum similarity score none
--reindex Force re-embed false
--model Embedding model BAAI/bge-small-en-v1.5
--no-cache Skip cache false
--version Print version

Use with AI agents

semfind is designed to be called from AI agent tool loops. Example use cases:

  • Memory search — agents searching their own history/memory files for relevant past context
  • Document retrieval — finding relevant docs before answering user questions
  • Log analysis — searching logs by describing the problem rather than knowing exact error strings
# An agent searching its memory
semfind "user asked about authentication" memory/*.md -k 3

# Searching project docs for context
semfind "how to configure database" docs/*.md -k 5

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

semfind-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

semfind-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file semfind-0.1.1.tar.gz.

File metadata

  • Download URL: semfind-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for semfind-0.1.1.tar.gz
Algorithm Hash digest
SHA256 880f5609dd846bd47bf0704ac091562b2109691f509f07efa4b29d672c851c2c
MD5 ac2a8c4966761afa52e4789b70cd803e
BLAKE2b-256 4ac805aed0d5a1637814bc19c6bee766c03dd3a474a73903a483a3b44cf1e09a

See more details on using hashes here.

File details

Details for the file semfind-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: semfind-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for semfind-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6284fefc404516fe7a6cc90d249472981326b42448cf029e4e8b4a17dce77afc
MD5 0ad0a78ff687e8c9c8fb5537f1809de9
BLAKE2b-256 0d817e11367f2aab15671fe42f6a2173f59203c27f9bb0e0cd2dc20b42614049

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