sem-ctx is a lightweight, local, location-agnostic semantic search utility written in Python. It provides fast semantic search using a local vector embedding engine and template lookup for agent workflows.
sem-ctx can be installed in editable mode, which keeps the command pointed at
this checkout while you work on the code.
On Windows, install from the project directory:
cd C:\Users\USER\syntax-syllogism\sem-ctx
py -m pip install -e .This registers the sem-ctx command in the active Python environment.
On recent Ubuntu/Python installations, running pip install -e . against the
system Python may fail with an "externally managed environment" warning. That is
Python protecting packages managed by Ubuntu's package manager.
If you use uv, install the CLI as an isolated editable tool:
cd sem-ctx
uv tool install --editable .If you prefer a local virtual environment:
cd sem-ctx
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .Avoid pip install -e . --break-system-packages unless you intentionally want to
modify the OS-managed Python environment.
You don't need to specify the --dir argument on every invocation. The tool resolves the active target directory by checking the following hierarchy:
- Explicit argument:
sem-ctx --dir ~/notes/my-docs search "login issues" - Environment variable: The
SEM_CTX_DIRenv var. - Local configuration: A
.envor.sem-ctx.jsoncontainingSEM_CTX_DIRin the current working directory. - Global configuration: A path set in your user config file (
~/.config/sem-ctx/config.json).
To set a global default target folder, run:
sem-ctx set-default path/to/your/directoryPerform semantic vector search using a highly optimized, local embedding model (BAAI/bge-small-en-v1.5 running via fastembed):
sem-ctx search "authentication workflow"To output raw structured JSON for scripts or automation:
sem-ctx search "authentication workflow" --jsonFind the best template and target folder for a new item:
sem-ctx template "work item"For agent workflows, use JSON output. The command does not write files; it returns the template, target folder, nearby markdown files, and ranked candidates so the agent can create the final note with its own filesystem tools.
sem-ctx template "work item" --jsonAdd the Semantic Context agent protocol to AGENTS.md in the current directory:
sem-ctx install-protocolYou can also pass a specific AGENTS.md path or a directory containing one:
sem-ctx install-protocol path/to/project/AGENTS.mdThe command creates or updates a marked Semantic Context protocol block, so it is safe to run again when the protocol changes.
Re-scan the directory and force-rebuild the embedding index from scratch:
sem-ctx reindex