# Code

URL: https://docs.hanzo.ai/docs/cli/code

> The `hanzo code` commands.

Also for this capability: [API](https://docs.hanzo.ai/docs/openapi/code) · **CLI** · [MCP](https://docs.hanzo.ai/docs/mcp-tools/code) · [SDKs](https://docs.hanzo.ai/docs/sdks)

Search and symbols across your repos, for you and your agents.

[API reference →](https://docs.hanzo.ai/docs/openapi/code)

```bash
hanzo code file
```

Every command takes `--json` for the raw response and `--help` for its own flags. Sign in once with `hanzo auth login`; the commands below use that session, and the org they act in is the one it carries.

| Command              | What it does                                                                                                                                                                                                                                                             |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `hanzo code context` | Packs the most relevant code for a query into a token budget — THE primitive for a coding agent that has to decide what to put in a prompt.                                                                                                                              |
| `hanzo code file`    | Returns the INDEXED content of one file — read\_file over the chunks the search tiers hold, for pulling up code an agent just found.                                                                                                                                     |
| `hanzo code index`   | (re)indexes a repository for the caller's org, incrementally: files whose content hash is unchanged are skipped, so re-sending a whole tree is cheap.                                                                                                                    |
| `hanzo code search`  | Finds code in the caller org's index across three orthogonal retrieval tiers fused by reciprocal-rank fusion: lexical (FTS5 trigram over code-tokenized text), symbolic (real definition and reference edges), and semantic (embedding cosine over AST-boundary chunks). |
| `hanzo code tree`    | Returns one repository's file structure with a per-file symbol count — get\_repo\_structure over the org's own index, with no git checkout involved.                                                                                                                     |

### Ask

| Command                 | What it does                                                                                                                                                                                          |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `hanzo code ask create` | Answers a question about the caller org's code with a CITED answer, taking the question from the request BODY, for a question too long or too awkward to put in a URL.                                |
| `hanzo code ask get`    | Answers a question about the caller org's code with a CITED answer: retrieval packs grounding context, then the synthesizer writes the answer over exactly those spans, which come back alongside it. |
