> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-ai/use-harness-cli/harness-cli/harness-cli-commands/knowledge-graph-commands.md).

# Knowledge Graph

Use the Harness CLI to explore the Knowledge Graph schema and run HQL (Harness Query Language) queries against your Harness entity graph at runtime.

The Knowledge Graph exposes the Harness entity graph schema and provides HQL (Harness Query Language), a graph query language for querying entities and their relationships at runtime.

***

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* **Harness CLI installed and authenticated:** Go to [Install and upgrade](/harness-ai/use-harness-cli/harness-cli/install-and-upgrade.md) and [Authenticate](/harness-ai/use-harness-cli/harness-cli/authenticate.md) to set up the CLI.

***

### Explore the schema <a href="#explore-the-schema" id="explore-the-schema"></a>

List all entity types in the knowledge graph:

```sh
harness list kg:type
harness get kg:type platform:project
```

Discover which types support queries and how they relate to each other:

```sh
harness list kg:queryable_type
harness list kg:related_type platform:project
harness list kg:connection platform:project
```

Here is the `platform:project` serves as the `<type_id>`.

***

### Run HQL queries <a href="#run-hql-queries" id="run-hql-queries"></a>

HQL lets you traverse the entity graph and retrieve structured results from your Harness account.

Run a query:

```sh
harness execute hql:run --query 'find entity "platform:project" | select { * } | limit 10'
```

Validate a query without executing it:

```sh
harness execute hql:validate --query 'find entity "platform:project" | select { * } | limit 10'
```

Get a step-by-step explanation of how the query engine will process a query:

```sh
harness execute hql:explain --query 'find entity "platform:project" | select { * } | limit 10'
```

Print the full HQL grammar reference:

```sh
harness execute hql:grammar
```

Run `harness execute hql:grammar` to see the complete HQL syntax, supported entity types, field names, and filter operators.

***

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go to [Supported resources and actions](/harness-ai/use-harness-cli/harness-cli/supported-resources-and-actions.md) to view the full Knowledge Graph resource matrix.
* Go to [Global flags and output](/harness-ai/use-harness-cli/harness-cli/global-flags-and-output.md) to learn about output formats and pagination.
