Model or dataset
mohsen1/yek avatar
mohsen1/yek

yek: A Rust CLI That Serializes Repositories for LLM Context Windows

A fast Rust based tool to serialize text-based files in a repository or directory for LLM consumption

2,475 stars65 forksRustMIT

At a glance

What is it?
yek is a fast Rust tool that turns a repository's text files into a single, priority-ordered document for LLM consumption. It uses .gitignore and Git history to decide what matters, and it caps output by token count.
Who is it for?
Adopt yek if you regularly need to feed a codebase or directory into an LLM and want a single command that respects .gitignore, orders files by Git-derived importance, and enforces a token budget. Skip it if your inputs are mostly binary, if you cannot rely on Git history for every repository, or if you need deterministic byte-for-byte output across versions.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 78 days ago.
What is it written in?
Mainly Rust, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What yek Solves and Who It Is For

yek addresses a specific pain: preparing a codebase for an LLM prompt. Copy-pasting files manually is error-prone and eats context. yek reads a directory or repository, respects .gitignore, and writes a single text file where each file is delimited by a header line like ">>>> src/main.rs". The tool is aimed at developers who use LLMs to reason about code, and who want a repeatable way to turn a tree of files into one document. The README frames it as "a fast Rust based tool to serialize text-based files in a repository or directory for LLM consumption." The emphasis on speed and Rust suggests it competes with slower scripts that walk directories and concatenate files without any notion of importance.

How It Works: Git History and Priority Ordering

The core mechanism is priority ordering. yek uses Git history to infer which files matter more, and it places more important files later in the output. The README explains: "yek will prioritize more important files to come last in the output. This is useful for LLM consumption since LLMs tend to pay more attention to content that appears later in the context." So the tool does not just concatenate in alphabetical or tree order. It analyzes commit history to score files, then reverses the order so the highest-priority content sits at the end. This is a design choice that assumes the LLM's attention is biased toward the tail of the context, which is a plausible but not proven assumption. The same mechanism also drives the token cap: when you set --tokens 128k, yek removes files that do not fit, keeping the more important ones. That means the output is not a simple truncation; it is a selection based on inferred importance.

Installation and Basic Usage

Installation on Unix-like systems is a single curl pipe: curl -fsSL https://azimi.me/yek.sh | bash. Windows users run irm https://azimi.me/yek.ps1 | iex in PowerShell. There is also a source build: git clone, then cargo install --path . inside the repo. The basic usage is equally short. Run yek in a directory and it serializes the whole repository into a temporary file, printing the path to that file. You can pipe the output directly: yek src/ | pbcopy sends the serialized content to the macOS clipboard. You can process multiple directories (yek src/ tests/), multiple files (yek file1.txt file2.txt), or quoted glob patterns (yek "src/**/*.ts"). The CLI reference shows a --max-size option with a default of 10MB, and a --tokens option that switches from byte counting to token counting. For example, yek --tokens 128k caps the output at roughly 128,000 tokens, and yek --max-size 100KB --output-dir /tmp/yek src/ writes a bounded file to a specific directory.

Configuration File and Output Control

Beyond flags, yek reads a yek.yaml file placed at the project root, or a path passed via --config-file. The config file can set the same options as the CLI, including max_size, tokens, ignore_patterns, unignore_patterns, json, and debug. It also supports defining file priority rules and adding binary extensions to the built-in ignore list. The output format is configurable through --output-template, which defaults to ">>>> FILE_PATH\nFILE_CONTENT". That means you can change the delimiter to something your LLM workflow expects. There is also a --tree-header flag that prepends a directory tree, and --tree-only to output just the tree without file contents. JSON output is available via --json, though it is incompatible with tree options. This flexibility is useful, but it also means the default output is not a standard. If you rely on a specific delimiter, you must pin the config or accept that a future version could change the default template.

Limitations and When It Is the Wrong Tool

yek is explicitly for text-based files. The README says it infers ignore patterns for binary and large files, but it does not attempt to serialize binary content. If your repository is mostly images, PDFs, or other non-text assets, yek will either skip them or produce an output that omits them, which may be fine for LLM consumption but means you cannot use it as a general-purpose file packer. Another limitation: the priority ordering relies on Git history. In a directory that is not a Git repository, or where history is shallow or absent, the importance inference has little to work with. The tool may still run, but the ordering could be arbitrary or based only on the built-in ignore patterns. Also, the token counting mode is not a true LLM tokenizer; it is an estimate. The README says "--tokens 128k" caps the output, but it does not specify which tokenizer or heuristic it uses. That estimate can be off for code, which has many tokens per byte. So the cap is a guideline, not a guarantee that the output fits a specific model's context.

Alternatives and How They Differ

The closest alternative is a manual script that walks a directory and concatenates files, or a tool like ripgrep's --files output piped to a loop. That approach gives you full control but no ordering heuristic and no token cap. Another alternative is to use an LLM-specific tool that reads a repository directly, such as a code indexing service, but those are heavier and often require a server. The real difference with yek is that it bakes in two opinions: Git history determines importance, and later output position is better for LLM attention. A simple script does not do either. If you disagree with those opinions, you would need to write your own ordering logic. yek offers some control through configurable priority rules, but the default behavior is opinionated.

Maintenance and License Considerations

The repository is under the MIT license, which is permissive and allows commercial use, modification, and redistribution with attribution. The project is actively maintained, with recent releases in June 2026: v0.25.5, v0.25.4, and v0.25.3. The version number 0.25 suggests ongoing iteration, and the README notes that many CLI options can be mirrored in the config file, which implies a stable interface but also a surface area that can change. The last push date is 2026-06-29, so the project is not archived. For a tool that is meant to be part of a prompt pipeline, the maintenance cost is low: it is a single binary that you install once. But because it relies on Git history and heuristics, you should re-run it whenever your repository changes to keep the serialized output current. There is no indication of a plugin system or a way to extend the token counting, so if you need a different counting method, you would have to fork or wait for a feature.

Editorial conclusion

Adopt yek if you regularly need to feed a codebase or directory into an LLM and want a single command that respects .gitignore, orders files by Git-derived importance, and enforces a token budget. Skip it if your inputs are mostly binary, if you cannot rely on Git history for every repository, or if you need deterministic byte-for-byte output across versions. Before committing, verify how yek handles your specific file naming and ignore patterns, and check the current output template and token counting behavior, since these are configurable and may change between releases.

Official sources

  1. Issues
  2. License: MIT
  3. mohsen1/yek on GitHub
  4. README
  5. Releases
Community notes

Community notes