# Get folded output back

> Every fold prints a hash. tokenade expand-ref answers questions about the stashed output, greps it or returns the exact bytes, without a re-run.

Source: https://tokenade.net/en/docs/expand-ref-disclose · Updated: 2026-10-07

When Tokenade folds a large output, the complete original goes to a local stash and the banner prints a hash. `tokenade expand-ref <hash>` is how you get what you need from it: ask it questions, grep it, or page through the exact bytes. Nothing is re-run.

## Where the hash comes from

Every fold ends with a banner like this one:

```text
[tokenade:find 443263 tokens folded away; the stash holds the COMPLETE output — this blob is ~444645 tokens — too large to dump whole. recover with `tokenade expand-ref 6f961168e46c` · `--prompt "q1, q2"` to ask (RAG, several at once) · `--grep <pat>` exact lines. Any other hash above covers only what was shown.]
```

The hash is 12 hex characters. Your agent reads the banner and can call `expand-ref` itself; you can too.

## expand-ref

```text
tokenade expand-ref <hash> [--prompt "q1, q2"] [--grep <pat>…] [--raw]
```

Alias: `xref`.

| Flag | Effect |
| --- | --- |
| `--prompt "q1, q2"` | Ask several questions in one call and get only the passages that answer. The cheapest option in tokens. Also `--question`, `-q` |
| `--grep <pat>` | Exact matching lines, repeatable. The pattern is a regex matched per line. Prints `N matching line(s) of M total` so a narrow match never looks like the whole output |
| `--ignore-case`, `-i` | Fold case on both sides of `--grep` |
| `--raw`, `--full` | The bytes, verbatim, in bounded pages |
| `--from-line N` | With `--raw`: resume from line N |
| `--budget N` | With `--raw`: move the ceiling to N tokens; `--budget 0` removes it |

Reach for `--prompt` or `--grep` first. `--raw` puts the stored bytes back in context, which is what the fold existed to avoid, so it stops at a budget and tells you exactly how to continue.

```text
$ tokenade expand-ref f6351f5ead9a --grep '^1999[0-2]$'
19990:19990
19991:19991
19992:19992
[tokenade:expand-ref] 3 matching line(s) of 20000 held under this hash
```

```text
$ tokenade expand-ref f6351f5ead9a --raw
1
2
…
12399
[tokenade: lines 1-12399 of 20000 (~59997 tokens). 7601 line(s) left — continue with `tokenade expand-ref f6351f5ead9a --raw --from-line 12400`, narrow with `--grep <pattern>`, or take the rest in one go with `--budget 0`.]
```

### Unknown or expired hash

```text
$ tokenade expand-ref 000000000000 --grep x
expand-ref: hash '000000000000' not found in dedup cache or stash
  …
  the bytes are gone, so there is no second way back to THEM: re-run the command that printed this hash (`tokenade raw <cmd>` re-runs it uncompacted)
```

Exit code `1`. Stashes unused for 7 days are evicted (see [maintenance](https://tokenade.net/en/docs/maintenance)), and the stash directory is capped at 2 GiB, oldest first. After that, re-run the command.

## expand-fold

```text
tokenade expand-fold <id> [hash] [--max N]
```

Alias: `xfold`. Some folds shorten a run of repetitive log lines and print an id for it in the banner. `expand-fold` brings that one run back as its raw lines. Without a hash it uses the most recent fold for that id; `--max N` caps the number of lines returned.

## disclose: stash anything yourself

`disclose` applies the same stash-and-ask pattern to any output you pipe in.

```text
<cmd> | tokenade disclose stash [--source web|shell|mcp|graphql]
tokenade disclose read <hash>
tokenade disclose search <hash> <query>
```

| Subcommand | Effect |
| --- | --- |
| `stash` | Reads stdin. Below the size threshold it passes the input through unchanged and stashes nothing. Above it, writes the blob to the stash and prints a folded preview plus a banner with the file, an estimated token count and the hash |
| `read <hash>` | Returns the stashed bytes |
| `search <hash> <query>` | Returns only the passages that match |

`--source` tells the reader what produced the blob; omit it and the content is sniffed.

```text
$ seq 1 30000 | tokenade disclose stash --source shell
1
…
30000
[stashed: ~/.cache/tokenade/stash/5bc81dbc42fe.txt · ~129290 tokens · folded summary (omits middle lines) · recover with `tokenade expand-ref 5bc81dbc42fe` · …]
```

An unknown hash says so and exits `1` instead of returning nothing with exit `0`.

## Where the stash lives

| Item | Value |
| --- | --- |
| Directory | `~/.cache/tokenade/stash/` on Linux (the platform cache directory elsewhere); override with `TOKENADE_STASH_DIR` |
| Stash threshold | About 5,000 tokens for command output (`TOKENADE_DISCLOSE_THRESHOLD`), 25,000 for file reads |
| Size cap | 2 GiB in total, oldest evicted first (`TOKENADE_STASH_MAX_DIR_BYTES`) |
| Lifetime | 7 days since last use |

Everything in the stash has already been through secret redaction. Details in [output compaction and the stash](https://tokenade.net/en/docs/compaction).

## Related

- [Output compaction and the stash](https://tokenade.net/en/docs/compaction)
- [wrap, raw and filter](https://tokenade.net/en/docs/wrap-raw-filter)
- [Read documents and media](https://tokenade.net/en/docs/read-documents-media)
- [Maintenance commands](https://tokenade.net/en/docs/maintenance)
