# Chalk CLI Reference: Codegen
source: https://docs.chalk.ai/cli#codegen

Generate type-safe client code for your features in Python, Go, Java, and TypeScript. Keep your application code in sync with your feature definitions.

## `chalk stubgen`
source: https://docs.chalk.ai/cli?command=stubgen

```bash
chalk stubgen [--flags]
```

Use the `stubgen` command to generate [Python stubs](https://mypy.readthedocs.io/en/stable/stubs.html) using your feature types.

**Flags**

- `--watch <watch>` (bool, default `false`)
  Watch the current files for changes and run `stubgen` when there are changes in the project.
- `--root <root>` (string)
  The root directory of your project. By default, Chalk will find the root directory by looking for a `chalk.yaml` file.

**Example**

```
$ chalk stubgen --watch
⡿  Waiting for changes...
```

## `chalk codegen python`
source: https://docs.chalk.ai/cli?command=codegen_python

```bash
chalk codegen python
```

This command generates features that can be used with the `ChalkClient` class in the `chalkpy` pip package.

**Flags**

- `--include-dtype <include-dtype>` (bool, default `false`)
  Whether to include the dtype explicitly for each feature, e.g. `feature(dtype=pa.int64())`.
- `--out <generated.py>` (string)
  Path of output file with the filename included. Creates the file if it does not exist.

**Example**

```
$ chalk codegen python --out=output.py
Wrote features to file 'output.py'
```

## `chalk codegen go`
source: https://docs.chalk.ai/cli?command=codegen_go

```bash
chalk codegen go
```

This command generates Go structs that mirror the defined features, and create references to the available features. For details on using the resulting generated code, see the [Go client](https://pkg.go.dev/github.com/chalk-ai/chalk-go#readme-online-query).

**Flags**

- `--out <export.go>` (string)
  Path of output file with the filename included. Creates the file if it does not exist.
- `--package <package>` (string)
  Package name to use. If unspecified, we will guess the appropriate package based on neighboring files of the output file specified.

**Example**

```
$ chalk codegen go --out=/codegen/features.go
✓ Wrote features to file '/codegen/features.go'
```

## `chalk codegen java`
source: https://docs.chalk.ai/cli?command=codegen_java

```bash
chalk codegen java
```

Java codegen generates classes that mirror the features classes defined in Python and creates `Feature` objects for each available feature. If that also fails, please use the `--package` flag to specify the package name explicitly. For details on using the resulting generated code, see the [Java client](https://github.com/chalk-ai/chalk-java#codegen-enhanced-queries).

**Flags**

- `--out <./export>` (string)
  Output directory to dump generated Java class files.
- `--package <package>` (string)
  Java package name that the generated code should use. If not specified, we will infer from existing files in the output directory. If that fails, we will concatenate folder names in the path after `src/main/java`.
- `--case <case>` (string, default `camel`)
  Whether feature names are `'snake'` or `'camel'` case.

**Example**

```
$ chalk codegen java --out=/java_project/src/main/java/codegen/
✓ Wrote features to folder '/java_project/src/main/java/codegen/'
```

## `chalk codegen typescript`
source: https://docs.chalk.ai/cli?command=codegen_typescript

```bash
chalk codegen typescript
```

Typescript codegen generates TypeScript types that mirror the defined features. It will also generate a type `FeaturesType` that can be used to parameterize the Chalk TypeScript client in order to provide automatic autocomplete and type checking for queries.

**Flags**

- `--out <out>` (string)
  Path of output file with the filename included. Creates the file if it does not exist.
- `--depth <depth>` (int, default `4`)
  Maximum depth of the feature path to generate types for: e.g. depth 4 => `x.y.z.feature_1`.

**Example**

```
$ chalk codegen typescript --out=/ts_project/src/codegen/features.ts
✓ Wrote features to file '/ts_project/src/codegen/features.ts'
```

## `chalk codegen pydantic`
source: https://docs.chalk.ai/cli?command=codegen_pydantic

```bash
chalk codegen pydantic
```

This command will generate Pydantic models that can be used to describe streaming messages and structs from proto files given with `--in`.

**Flags**

- `--out <out>` (string)
  Output filepath to dump the pydantic models. The path should include the filename, and the file will be created if it does not exist.
- `--in <in>` (string)
  Path to the input proto file or directory of proto files.

**Example**

```
$ chalk codegen pydantic --in proto/ --out=output.py
✓ Wrote Pydantic models to file 'output.py'
```
