What is Yggdrasil?
Yggdrasil is a project flattener and diff engine. It builds a single, deterministic codex from whatever subset of your codebase you choose:
- A full index of files
- Accurate line counts
- Language-tagged code blocks
- Markdown or plain text output
- Optional rich diff mode
- Optional movement annotations (
[MOVED])
Use it for:
- LLM prompts
- Documentation snapshots
- Code reviews
- Reproducible archives
- Project comparisons
Yggdrasil does not guess what you want. You explicitly choose the files — this makes your snapshot deterministic and deeply controllable.
How Yggdrasil Selects Files (Critical)
Yggdrasil never prints the entire repo by default. You must specify what to include using any of:
--only <paths…>--show <extensions…>--white <manifest>--sniff <entry file>
You may also exclude using:
--ignore--black
Formatting is separate:
--printed→ Markdown (SHOW.mdby default)--contents --out FILE→ explicit output mode
--printed does not select files.
It only specifies the output format.
Snapshot Examples
These examples are accurate and guaranteed to work because they always include a file-selection flag.
Export all .rs and .md files as Markdown
Export specific files and directories
Export files listed in a manifest
WHITE.md:
src/lib/model.rs
src/app/main.tsx
README.md
Command:
Use explicit --contents --out
Markdown:
Plain text:
List file paths without contents
Flatten everything under a directory
Sniff Mode — Semantic File Expansion
--sniff is the fastest way to build a codex when you have a single entry point
and want everything it depends on — without manually listing files.
Given an entry file, Yggdrasil reads its static imports, resolves them to local
files inside --dir, and repeats recursively until no new local files are found.
The full reachable set is fed into the snapshot pipeline exactly like --only.
How it works
- Start from the entry file
- Read its top-level (preamble) imports only
- Resolve each import to local files inside
--dir - Recursively repeat for every discovered file
- Stop when no new local files are found
- Pass the complete set to the snapshot pipeline
External libraries (numpy, pandas, etc.) are silently ignored — only files
that exist inside --dir are included.
Examples
# Snapshot an analysis script and all its local dependencies
# Same, but split into LLM-safe shards
# Combine with --ignore to exclude noisy files
What sniff resolves
For Python, given from graveyard.meta.macro_runner import load_data_macro:
graveyard/meta/macro_runner.pygraveyard/meta/macro_runner/__init__.py- truncated forms:
graveyard/meta.py,graveyard.py
The first candidate that exists inside --dir is followed.
What sniff does not do
- It does not scan the entire repo
- It does not analyze runtime behavior or call graphs
- It does not follow relative imports (
.sibling,..parent) — planned for a future release - It does not include external libraries
Mental model
| Flag | Selection method |
|---|---|
--only |
manual paths |
--white |
manifest file |
--sniff |
semantic expansion from entry point |
Sniff is just a smart way to fill --only.
All other flags (--ignore, --split, --printed, etc.) apply normally after expansion.
Large Codices & Context Limits
Yggdrasil can split large codices into LLM-safe shards while preserving structure.
Use --split to divide output into multiple standalone codex files:
Each shard:
- preserves canonical file order
- never breaks files mid-content
- includes full INDEX + FILES structure
- is independently valid for AI ingestion
Splitting is expressed in thousands of tokens, not raw token counts.
Interactive Mode
Interactive paste mode is ONLY triggered by --whited.
--white never triggers interactive input.
The --whited Shortcut (Interactive)
--whited enables the fastest workflow:
- launches interactive paste mode
- implies
--white - implies
--contents - writes Markdown to
SHOW.mdautomatically
Run:
You will see:
Enter WHITE patterns (one per line):
Tip: Paste your paths (e.g., from VS Code → Copy Relative Path).
Finish with Ctrl+D (Linux/macOS) or Ctrl+Z then Enter (Windows).
Paste:
src/main.rs
src/utils/io.rs
README.md
Then Yggdrasil generates SHOW.md automatically.
This is the only flag that triggers interactive paste mode.
Diff Mode
Compare directories:
Compare specific files:
Align annotations:
Diff features:
- inline diff visualization
- contextual additions/removals
- cross-file movement detection
[MOVED → file:line]annotations- optional aligned metadata
Installation
Requires Rust:
Ensure ~/.cargo/bin is in your path.
Install from local source:
Philosophy
In Norse myth, Yggdrasil is the world-tree unifying realms. This tool unifies your project structure into one portable artifact.
Design principles:
- Explicit over implicit
- Deterministic, repeatable output
- Minimal configuration
- LLM-friendly structure
- Complete control over what's included
Roadmap
Completed (v0.2.4)
- Snapshot export
- Markdown and plain-text modes
- Manifests:
--whiteand interactive--whited - Blacklists:
--ignore,--black --onlyand--showfilters- Diff engine
- Block movement detection
--align-tags--printed
Completed (v0.3.0)
--split: LLM-safe shard output
Completed (v0.4.0)
--sniff: semantic file expansion from a single entry point- Recursive static import resolution bounded to
--dir - Nordic-flavoured sniff header in both CLI and Markdown output
--dirpromoted to named flag for robustness
Planned (v0.5 → v1.0)
- Relative import resolution in
--sniff(.sibling,..parent) - Multi-language sniff (Rust
use, TypeScriptimport) - Tree-view / flat-view toggle
- Themeable CLI output
- HTML codex export
- Combined codex+diff bundles
License
MIT License.