# Getting started

Run your first commands against a broker

Package: @cookiemonsterdev/kafka-cli 1.12.1
Canonical: https://cookiemonsterdev.github.io/kafka/docs/cli/start/getting-started/
Source revision: b112a684d2b3cdc7deadb3513041fcdbdc1c18b5

Assume a broker at `localhost:9092`. Every connecting command accepts `--brokers` directly:

```sh
kafka ping --brokers localhost:9092
kafka topic create orders --brokers localhost:9092 --partitions 3 --replication-factor 1
kafka topic list --brokers localhost:9092
kafka topic describe orders --brokers localhost:9092
kafka group list --brokers localhost:9092
```

Typing `--brokers` on every call gets old fast — `kafka init` writes a `kafka.config.ts` in the
current directory, discovered automatically from then on:

```sh
kafka init
# writes ./kafka.config.ts with client.brokers = ['localhost:9092']
kafka topic list   # --brokers no longer needed
```

`kafka doctor` reports which config file (if any) was discovered, where each of its values came
from, and whether broker settings resolve locally — the first thing to reach for when a command
connects to the wrong cluster or fails to connect at all.

```sh
kafka doctor
```

Add `--json` to any command for one machine-readable document on stdout instead of a human table:

```sh
kafka topic list --json | jq '.topics[]'
```

Next: [Configuration](https://cookiemonsterdev.github.io/kafka/docs/cli/guides/configuration/),
[Output and scripting with JSON](https://cookiemonsterdev.github.io/kafka/docs/cli/guides/output-and-scripting/),
[Command reference](https://cookiemonsterdev.github.io/kafka/docs/cli/reference/commands/).
