> 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-platform/3.0/harness-cli/cli/harness-cli-commands/knowledge-graph.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

* **Harness CLI installed and authenticated:** Go to [Install and upgrade](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/overview.md) and [Authenticate](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/authenticate-the-harness-cli.md) to set up the CLI.

## Explore the schema

List all entity types in the knowledge graph:

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

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

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

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

## Run HQL queries

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

Run a query:

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

Validate a query without executing it:

```shell
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:

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

Print the full HQL grammar reference:

```shell
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

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