> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI4OGUwMTI3ZS1jOTgzLTRhYmUtODQ2Zi0wZDc4NzhiMDgxNGIiLCJleHAiOjE3NzkxNTI0NTAsImlhdCI6MTc3OTE1MjE1MH0.WSPkpO5f41EhOc99UjR2PmysUyjzcsMA75YBZdJOkvc
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# Customization

> Customize generated CLIs with overrides, overlays, multi-spec merging, and custom commands.

The CLI generator is in early access. [Reach out](https://buildwithfern.com/book-demo?type=cli) to get started.

A generated CLI can be customized at three levels: the OpenAPI spec it's built from, the configuration that combines multiple specs into a single command tree, and code that adds custom commands alongside the spec-derived ones.

## Overrides and overlays

The CLI generator supports both [overrides](/learn/api-definitions/openapi/overrides) and [overlays](/learn/api-definitions/openapi/overlays) for customizing the OpenAPI spec before the CLI is built. This lets you add Fern extensions, rename parameters, or remove internal endpoints without modifying your original spec.

Overlays follow the [OpenAPI Overlay Specification](https://spec.openapis.org/overlay/v1.0.0.html) and use JSONPath to target elements:

```yaml title="overlay.yaml"
overlay: 1.0.0
info:
  title: CLI customizations
  version: 1.0.0
actions:
  - target: $.paths['/plants'].get
    update:
      x-fern-sdk-group-name: plants
      x-fern-sdk-method-name: list
  - target: $.paths['/internal/debug']
    remove: true
```

When both are present, overrides are applied first, then overlays.

## Multi-spec merging

A single CLI can combine multiple OpenAPI specs into one command tree. This is useful for APIs that split their spec across domains or versions.

Specs can be merged flat (all commands at the top level) or under a namespace prefix:

```rust title="main.rs"
CliApp::new("my-api")
    .spec(include_str!("core.yaml"))
    .spec_under("billing", include_str!("billing.yaml"))
    .run()
```

This produces a CLI where core commands live at the top level and billing commands live under a `billing` subcommand:

```bash
my-api users list          # from core.yaml
my-api billing invoices list  # from billing.yaml
```

When a namespace matches a top-level resource in the incoming spec, the CLI hoists that resource's methods into the namespace to avoid repetition (for example, `billing billing invoices list` becomes `billing invoices list`).

## Custom commands

Generated CLIs can include custom commands alongside the spec-derived ones. Custom commands have access to the same API executor, so they can chain multiple API calls into a single workflow.

```rust title="main.rs"
CliApp::new("my-api")
    .spec(include_str!("openapi.yaml"))
    .auth_scheme_env("bearerAuth", "MY_API_TOKEN")
    .command(whoami_cmd(), whoami_handler)
    .run()
```