# Commands

Every command of the `ahto` CLI on one page, in the groups `ahto --help` shows.
`ahto <command> --help` shows the options of each.

## Lake

| Command | What it does |
|---|---|
| `crawl` | fetch repositories and add them to the lake, then derive the read models and parse the new source files ([getting started](/docs/getting-started#choosing-what-to-crawl)) |
| `login` | show, check or keep the login for an https remote ([private repositories](/docs/private-repositories)) |
| `repo list`, `repo show`, `repo rm` | the repositories in the lake |
| `storage status`, `storage compact`, `storage gc`, `storage derive`, `storage verify` | the lake on disk and its read models ([the lake](/docs/lake)) |
| `parse` | parse the source files a crawl has not parsed yet; `--rebuild` parses them all again ([parsing](/docs/parsing)) |

## Query

| Command | What it does |
|---|---|
| `query sql`, `query file`, `query explain`, `query export` | SQL over the lake, a file of SQL, a query plan, and export to JSON, CSV, Parquet or Arrow ([querying](/docs/querying)) |
| `query tables`, `query schema` | the tables with their files, rows and bytes, and their columns with what each means |
| `files`, `history` | the files at a ref, and the commits that changed a path |
| `inspect` | one commit, tree, blob or tag; `--ast <ref>:<path>` the syntax tree of a source file |
| `security sync`, `security sources` | download the OSV, CISA KEV and EPSS feeds into the lake, and how the last sync went ([security](/docs/security)) |
| `security search`, `security show` | search the advisories, and one advisory with the lake commits it names |
| `security posture`, `security deps`, `security findings` | a repository's grade, its pinned packages, and what puts it at risk at a commit |
| `function list`, `function call` | the built-in and WebAssembly functions over the lake, and running one ([querying](/docs/querying#functions)) |
| `function new`, `function test` | start a new function in a folder, and compile and call it once without adding it |
| `task list`, `task tree`, `task get`, `task rollup` | the node's [task tree](/docs/gateway#the-task-service): the roots or a task's children, a subtree with roll-ups, one task with its path and links, and a roll-up |
| `task add`, `task update`, `task move`, `task state`, `task link` | add a task, change the fields given as flags, move it under a parent or among its siblings, set its state (with `--evidence`, `--pr`, `--reason` or `--force-reason`), and add or `--remove` a link |
| `task ready`, `task plan`, `task chain`, `task late` | the tasks to start next, the open tasks fitted into days at `--hours-per-day` from `--start`, the longest chain of dependencies by hours, and what is late |
| `task export`, `task import` | the whole task log in the `ahto.task.v1` format to a file or stdout, and adding the ops another node's export has that this one lacks |

## Serve

| Command | What it does |
|---|---|
| `serve` | run the [gateway](/docs/gateway): MCP, REST, gRPC, JSON-RPC, GraphQL, WebSocket, MQTT and OpenAPI on one port, with the lake as the [source service](/docs/gateway#the-source-service); `serve --stdio` serves the [MCP tools](/docs/gateway#mcp) over stdin and stdout instead, for a client that starts ahto itself. On a port it also answers the built-in [web app](/docs/gateway#the-web-app) at `/`, with the API also below `/api`; `--no-ui` leaves it out. It also takes OpenTelemetry on `127.0.0.1:4318` for the [debugger](/docs/debugger); `--otlp-listen off` turns that off |
| `mcp-tools` | print the MCP tools the gateway would offer |
| `ui` | print a one-time code that signs the web UI in as this node's owner, when the node is an authority member ([identity](/docs/identity)) |
| `migrate` | schema migrations of the configured databases ([adapters](/docs/adapters#migrations)) |
| `p2p init`, `p2p id`, `p2p ca`, `p2p admit`, `p2p revoke`, `p2p network`, `p2p publish`, `p2p psk` | the peer-to-peer node: its key and peer ID, the network's CA, and who is a member ([networking](/docs/networking)) |
| `p2p guardian list`, `set`, `rehearse`, `sign`, `cancel` | the guardians that sign a network's recovery ([identity](/docs/identity#recovery)) |

## Setup

| Command | What it does |
|---|---|
| `doctor` | check Git, the lake and DuckDB |
| `version` | the versions of ahto, Go, Git, DuckDB and the lake schema |
| `upgrade` (`update`) | replace this binary with the newest release, checked against its `SHA256SUMS`; `--check` only looks, `--version v0.1.2` picks one |
| `config` | print the settings in effect ([configuration](/docs/configuration)) |

## Tools

| Command | What it does |
|---|---|
| `check run`, `check plan`, `check key`, `check mtime` | run a repository's checks and skip the ones whose inputs did not change since they last passed ([checks](/docs/checks)) |
| `cas gocacheprog` | a content-addressed store, served to `go build` as its `GOCACHEPROG` build cache ([checks](/docs/checks#a-go-build-cache)) |

## Global flags

| Flag | What it does |
|---|---|
| `--lake <dir>` | the lake to use (`AHTO_LAKE_DIR`) |
| `--config <file or dir>` | a YAML config, or a directory of them; repeat to layer (`AHTO_CONFIG`) |
| `--env <name>` | `development`, `test`, `staging` or `production` (`AHTO_ENV`) |
| `--profile <dir>` | write Go profiles (cpu, heap, mutex and more) to this directory; `report` prints a table of spans, `trace` adds an execution trace (large, and slow for cgo-heavy commands such as parse) |
| `--log-level`, `--log-format` | how much to log, and as console text or JSON |
| `--pprof-listen <addr>` | serve Go's pprof on this loopback address while the command runs |