Skip to content

Explore a codebase

uh explore opens a repository in the uh review web UI, with no diff. It parses every supported file, builds the call and type graphs, and lets you read code in call order. Use it to learn a codebase you don't know. uh view is an alias for uh explore.

Explore mode showing the call graph canvas

Quick start

uh explore                 # the current directory
uh explore path/to/repo    # any local directory
uh explore --open          # also open the URL in your browser

It builds the graphs, starts a server on 127.0.0.1, and prints:

uhdiff UI listening at http://127.0.0.1:<port> (Ctrl-C to stop)

Choose what to explore

TARGET is a local path or a remote repository URL. It defaults to ..

Input Example What gets parsed
Local directory uh explore ~/src/app Files on disk as they are now, including uncommitted edits. The directory does not have to be a git repository.
Local repository at a revision uh explore ~/src/app --rev v1.2.0 The tree at that branch, tag or SHA, extracted with git archive into a temporary directory. Uncommitted edits are left out.
GitHub URL uh explore https://github.com/owner/repo A checkout of the default branch, or of --rev if you pass it.
Other git URL uh explore git@gitlab.com:group/repo.git Same as above, cloned with git.

Remote URLs

uh explore accepts https://, http://, ssh://, git://, file:// and git@host:path URLs. A URL is treated as GitHub when its host is github.com or contains github and its path is exactly owner/repo.

uh explore https://github.com/owner/repo
uh explore https://github.com/owner/repo --rev main
uh explore https://github.com/owner/repo --rev 3f2a9c1
uh explore git@github.com:owner/repo.git --gh-account work-login

How the code is fetched:

  1. Clone cache. For owner/repo URLs, uh keeps a persistent bare partial clone (--filter=blob:none) at <cache root>/<host>/<owner>/<repo>.git. It fetches --rev into the clone if given, then checks out a temporary working copy. Later runs reuse the cache. For the cache root (the repo_cache_dir config key, UHDIFF_REPO_CACHE_DIR, or $XDG_CACHE_HOME/uhdiff/repos), see Configuration.
  2. Fallback. If the cache is unusable, uh makes a depth-1 clone into a temporary directory: gh repo clone for GitHub URLs, git clone otherwise. A branch or tag --rev is passed as --branch. A SHA (7 to 40 hex characters) is fetched and checked out.

GitHub accounts

GitHub clones use the gh CLI. uh picks the account in this order:

  1. --gh-account <login>
  2. The saved default_gh_account, if it is one of the logged-in accounts
  3. The active gh account

Set the saved default with uh review --set-default-gh-account or uh config set default_gh_account. For tokens, accounts and private repos, see Review: GitHub auth and Configuration.

Outputs

Flag Result
(none) Serves the UI on 127.0.0.1. --port 0, the default, picks a free port.
--open Serves the UI and opens it in your system browser.
--dump-html <path> Writes a self-contained HTML file to <path> and exits. Parent directories are created. Prints Wrote <path>.
--json Prints the explore payload as JSON on stdout and exits.

If you pass several, --json wins over --dump-html, which wins over serving.

Every flag is listed in the CLI reference.

JSON payload

--json prints the same payload as uh review --json, with "mode": "explore":

uh explore crates/uhdiff-mmap --json
{
  "schema_version": 1,
  "mode": "explore",
  "source": {
    "kind": "explore",
    "title": "3 files · 54 functions · 36 types",
    "repo": "uhdiff-mmap",
    "has_conflict": false
  },
  "gh_auth": { ... },
  "ui_settings": { ... },
  "files": [ ... ],
  "functions_dag": { "nodes": [ ... ], "edges": [ ... ], "external_boundaries": [ ... ], "intra_scc_edges": [ ... ] },
  "types_dag": { ... }
}
  • files: one entry per source file, with path, language, is_test and new_lines (the contents). Each change is "unchanged". Files over 512 KiB are listed without contents.
  • functions_dag / types_dag: the call and type graphs. Each node has id, kind, name, file, start_line, end_line and topo_layer.
  • source.title: the file, function and type counts. With --rev, it starts with @<rev> ·.

What the explore view shows

The UI is the one in Reading the web UI, set up for reading code, not reviewing changes:

  • The header shows an Explore badge and the file, function and type counts.
  • Control Flow lists every function, ordered by callers. Structure shows the type graph. Files lists every file. Reader and Graph show the selected lens as code or as a canvas.
  • Code is plain source: no +/- lines, no split/unified toggle, no move markers, and no added/removed edge styling.
  • Tests are included and grouped under Tests.
  • Uncertain resolutions still appear as dashed possible edges.
  • Hidden review-only controls: the Overview tab, classic mode, draft comments, and the next-unreviewed and looks-good buttons.

Explore or uh graph

Both build the same call and type graphs. They differ in their reader.

uh explore uh graph
Reader A person, in the web UI Scripts, CI and other tools
Layers Calls and types, always --layer calls\|types\|both
Tests Always included --exclude-tests
Source text Embedded in the payload Not included
Diff overlay, bridges No --base/--head/--diff, --bridges
Remote URLs, --rev Yes No (local path; --base/--head for revisions)
Output Server, HTML file, JSON payload text, JSON, pretty JSON, binary
Extras parse cache, --strict exit status

Use uh explore to read and navigate code. Use uh graph to feed another program or gate CI on unresolved calls. To review a change rather than a snapshot, use uh review.