> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# File Tree

> Browse, search, and navigate project files with the built-in file tree. Pipe-style rendering, search-as-you-type, path history.

## File Tree

MonoTerm includes an embedded file tree for adding project paths to an `@`
prompt. The separate `monotree` package uses the same file-tree foundation as a
standalone browser. They share rendering and indexing behavior, but their input
modes are intentionally different.

```
┌──────────────────────────────────────────────────────────┐
│ FILES                       │                            │
│ │ src/                      │                            │
│ │ │ main.rs                 │   ┌─ Prompt ──────────┐    │
│ │ │ lib.rs                  │   │ check             │    │
│ │ │ config.rs               │   └──────────────────┘     │
│ │ .claude/                  │                            │
│ │ Cargo.toml                │                            │
│ │ README.md                 │                            │
│ Tab:files                   │                            │
└──────────────────────────────────────────────────────────┘
```

### How it works

1. Press `@` to open the prompt box
2. The sidebar switches to a searchable file tree
3. Press `Tab` to focus the tree; search mode starts immediately
4. Type a query, use `Up`/`Down`, and press `Enter` to insert a file path
5. Press `Tab` to return to the prompt, or `Esc` to close everything

### Design

Files are displayed with a clean pipe-tree layout:

```
│ README.md              ← markdown files first
│ .claude/               ← dot folders (prioritized whitelist)
│ │ settings.json
│ src/                   ← regular folders
│ │ main.rs
│ │ lib.rs
│ Cargo.toml             ← regular files
│ empty-dir/ -           ← empty folders marked with -
```

**Sort order**: markdown first, then dot folders (`.claude`, `.git`, etc.),
then regular folders, then files. Within each group, sorted by name or
modification time.

**Empty folders** are marked with ` -` suffix so you can tell at a glance
which folders have content.

### Search

When the embedded tree has focus, type to search instantly. The leading `/` in
the rendered search bar is a visual marker; you do not press `/` to start
searching.

```
/ lib                        ← search bar
│ lib-monotree/              ← parent folder shown for context
│ │ src/
│ │ │ lib.rs                 ← matched file
│ lib-keybinding/
│ │ src/
│ │ │ lib.rs                 ← matched file
```

Search is depth-progressive — it starts shallow and goes deeper only if
no matches are found at lower depths. Parent folders of matched files
are always shown for path context.

### Embedded prompt-tree controls

| Key                 | Action                                                          |
| ------------------- | --------------------------------------------------------------- |
| Type                | Append characters to the active search query.                   |
| `Up` / `Down`       | Move through filtered results.                                  |
| `Backspace`         | Delete from the search query.                                   |
| `Enter` on a file   | Insert its path into the prompt and return focus to the prompt. |
| `Enter` on a folder | Expand or collapse the folder.                                  |
| `Tab`               | Return focus to the prompt.                                     |
| `Esc`               | Close the prompt and tree.                                      |

Because this surface is already in search mode, `j`, `k`, `/`, and other
printable keys become query characters. Use the arrow keys for navigation.

### Standalone MonoTree controls

Standalone `monotree` starts in browse mode, so it exposes the broader tree
navigation surface:

| Key                      | Action                                                             |
| ------------------------ | ------------------------------------------------------------------ |
| `Up` / `Down`, `k` / `j` | Move the selection.                                                |
| `Enter` / `Right`, `m`   | Open the selected entry's context menu.                            |
| `Left`                   | Collapse an expanded folder or move selection to its parent.       |
| `/`                      | Enter search mode; type to filter and use `Up`/`Down` for results. |
| `1`–`5`                  | Expand the selected folder to that depth.                          |
| `e` / `E`                | Expand the first level / fully expand the selected folder.         |
| `c`                      | Collapse all folders.                                              |
| `s` / `r`                | Change sort mode / refresh.                                        |
| `u` / `Backspace`        | Re-root at the parent directory.                                   |
| `b` / `Ctrl+F`           | Move backward / forward in path history.                           |
| `Home` / `End`           | Select the first / last visible entry.                             |

Search mode exits with `Esc`; `Backspace` edits the query, and
`Ctrl+Backspace` or `Command+Backspace` clears it.

### Project Detection

When standalone MonoTree opens without a specific path, it automatically finds
the project root by scanning for `.git`, `.claude`, or similar marker
directories. Its history remembers re-rooted paths for `b` and `Ctrl+F`.

### Standalone: monotree

The same file tree engine runs as a standalone CLI tool:

```bash theme={null}
monotree                    # current directory (auto-detect project root)
monotree /path/to/project   # specific path
monotree search QUERY PATH  # depth-5 non-interactive file search
monotree docs [topic]       # embedded documentation
monotree test               # Unix-only three-check PTY harness
monotree --help             # show all keys
```

See the complete [MonoTree reference](/ai-clis/monotree) for its context menu,
sorting, expansion, history, non-interactive search, and mutation boundaries.
The standalone browser and MonoTerm's embedded prompt tree share an engine,
but not the same CLI surface or initial input mode. MonoTree 0.1.5's bundled `--help` omits
`search`, `docs`, and `test`; the reference documents the actual parser rather
than repeating that incomplete banner.
