obsidian-context
is a CLI script to query and export content from your Obsidian vault for use with LLMs.
It can list recent-links
(recently modified files) and pack
your files (a la repomix) into a single context blob.
For now it's meant to support two main workflows:
- Pack Files: Easily pack files I edited this week/month for use with LLMs.
- List Links: Get a list of frequently used links that I might want to consider as options when auto-tagging content in my vault / adding new content.
obsidian-context
works fully offline and will not modify any files.
brew install babashka/brew/bbin
bbin install io.github.martinklepsch/obsidian-context
obsidian-context
is a babashka program, using bbin for distribution.
The tool relies on a location to an Obsidian vault, this can be provided via the $OBSIDIAN_DIR
environment variable.
export OBSIDIAN_DIR=/path/to/your-vault
Combine files modified within a specified timeframe into a single text blob (useful for feeding context to LLMs).
Pack all files:
obsidian-context pack
Pack files modified in the last 7 days:
obsidian-context pack --lookback 7d
Pack files modified in the last 3 months:
obsidian-context pack --lookback 3m
(You can pipe the output to less
for easier viewing: obsidian-context pack --lookback 3m | less
)
Get a list of recently modified files, sorted by modification time (newest first). This is useful for seeing recent activity or providing an LLM with potentially relevant recent notes.
Note
Currently only links to existing files are shown. Links to files that are not found in the vault are not listed.
Default (show recently modified files):
obsidian-context recent-links
This defaults to --lookback 30d
and --limit 100
.
List the 20 most recently modified files:
obsidian-context recent-links --limit 20
Links for files modified in the last 7 days:
obsidian-context recent-links --lookback 7d
List the top 10 files modified in the last 60 days, excluding empty files and daily notes:
obsidian-context recent-links --lookback 60d --exclude-daily-notes --limit 10
General help:
obsidian-context --help
or simply:
obsidian-context
Help for a specific command (e.g., pack
):
obsidian-context pack --help