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

# rtk tree

> Token-optimized directory tree visualization

## Overview

Proxy for the `tree` command with intelligent output filtering and compaction.

## Syntax

```bash theme={null}
rtk tree [OPTIONS] [DIRECTORY]
```

## Options

All native `tree` flags are supported and passed through:

**-L \<level>** `number`

Descend only `level` directories deep

**-d** `flag`

List directories only

**-a** `flag`

Show all files (including hidden)

**-I \<pattern>** `string`

Exclude files matching pattern

**-P \<pattern>** `string`

List only files matching pattern

**--gitignore** `flag`

Filter files according to .gitignore

## Examples

### Basic Tree

```bash theme={null}
rtk tree
```

**Output:**

```
.
├── src/
│   ├── main.rs
│   ├── lib.rs
│   └── utils.rs
├── Cargo.toml
└── README.md

1 directory, 5 files
```

### Limited Depth

```bash theme={null}
rtk tree -L 2
```

### Directories Only

```bash theme={null}
rtk tree -d
```

**Output:**

```
.
├── src
├── tests
└── docs

3 directories
```

## Features

* **Gitignore-aware**: Automatically respects `.gitignore` patterns
* **Compact output**: Removes excessive whitespace and formatting
* **Token-optimized**: Aggregates file counts, truncates deep trees

## Token Savings

Average token reduction: **60%**

## Related Commands

* [rtk ls](/api/ls.md) - Directory listing
* [rtk find](/api/find.md) - File search

## Implementation

Source: `src/tree.rs`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.