Reusable views of code for LLM context.
Designed for a middle ground in AI-assisted coding. Rather than copying files manually or relying on an LLM agent to search your codebase, define views once and reuse them as your code evolves. This can often "one-shot" problems by preparing the right context.
Install from npm
npm i -g llmviewCreate any number of view files in your project. These can be saved anywhere. For example, a full-stack monorepo:
.views/
backend.llmview
frontend.llmview
integration_tests.llmview
new_feature.llmview
And use one:
llmview .views/backend.llmviewRun llmview --help for all options.
A view is a list of glob patterns to select files. Use ** for recursive matching and ! for negation.
# Code
backend/**
!backend/migrations/**
# Docs
docs/style_guide.mdThe patterns are used to find files. The contents of each file are printed to stdout in XML tag format.
<file path="backend/main.py">
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World!"
if __name__ == "__main__":
app.run(debug=True)
</file>
<file path="docs/style_guide.md">
# Style guide
Make no mistakes
</file>The -t argument includes the file system directory for all selected files at the beginning of the result.
<directory>
my_project/
backend/
main.py
docs/
style_guide.md
</directory>
<file path="backend/main.py">
...The -n argument includes line numbers in each file, similar to cat -n.
The -m argument outputs the result as markdown with syntax-highlighted code blocks:
`src/main.py`
```py
from flask import Flask
...
```
The -j argument outputs the result as JSON instead of XML tags. This can be useful for piping into other tools like jq:
llmview -j .views/backend.llmview | jq '.files | length'This is the JSON structure:
{
"files": [
{
"path": "backend/main.py",
"size": 245,
"content": "..."
}
]
}A directory field is populated when using -t.
You can generate a custom render format using jq, like:
llmview -j .views/backend.llmview | jq -r '.files[] | "**\(.path)**\n---\n\(.content)\n"'The -l argument lists the selected files instead of rendering them. For example, to create a zip of selected files:
llmview .views/backend.llmview -l | zip context.zip -@Instead of reading from a view file, you can use it as a filter by reading from stdin. For example, to render all the unstaged changes in your repo:
git diff --name-only | llmview -There are some opinionated file renderers which are based on the file extension. Currently they are:
- CSV (truncated by default, preserving the header and the first 10 lines)
- Excel, media files, and other non-text formats (omitted)
If a file-specific renderer is not found, the default renderer is used. It assumes files are UTF-8 encoded and skips any files larger than 250KB.
To see what files will be included and a count of total output characters, use the verbose flag -v:
llmview -v .views/backend.llmview > /dev/nullVerbose information gets printed to stderr, and stdout goes to /dev/null.