# cloudflare/cf architecture

> Architecture diagram of the GitHub repository cloudflare/cf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cloudflare/cf
- Repository: https://github.com/cloudflare/cf

## Overview

cf is Cloudflare’s agent-oriented CLI. The principal workflow is selecting a command, issuing an API operation, and presenting its result; the README additionally highlights command discovery, JSON output, TypeScript configuration, and Vite-based development. The tree shows generated command coverage, a command generator, and a broad generated SDK, but the excerpts do not expose the CLI’s runtime dispatch or output wiring. Accordingly, those connections are left unverified rather than inferred.

Main entry points: [`packages/cli/src/commands`](https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands) (cf CLI), [`packages/cli/src/sdk/sdk/Client.ts`](https://github.com/cloudflare/cf/blob/main/packages/cli/src/sdk/sdk/Client.ts) (SDK client), [`packages/cli/src/commands/_generated`](https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands/_generated) (Generated commands), [`packages/cli/src/sdk/sdk/api/resources`](https://github.com/cloudflare/cf/tree/main/packages/cli/src/sdk/sdk/api/resources) (API resources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI experience"]
  node_cli["cf CLI"]
  node_commands["Generated commands"]
  node_discovery["Command discovery"]
  node_json["JSON interface"]
end

subgraph group_generation["Command generation"]
  node_generator["Command generator<br/>[generator.ts]"]
  node_emit["Command emission"]
end

subgraph group_sdk["API client"]
  node_sdk["SDK client<br/>[Client.ts]"]
  node_api["API resources"]
  node_transport["SDK core"]
end

subgraph group_capabilities["Product capabilities"]
  node_workers["Workers setup<br/>[workers.ts]"]
  node_config["TypeScript config"]
  node_vite["Vite development"]
  node_plugins["Developer plugins"]
end

node_user(("Engineer or agent"))
node_cloudflare(("Cloudflare API"))

node_user -.->|"invokes"| node_cli
node_cli -.->|"dispatches"| node_commands
node_commands -.->|"calls"| node_sdk
node_sdk -->|"exposes"| node_api
node_sdk -.->|"uses"| node_transport
node_api -.->|"API operations"| node_cloudflare
node_generator -.->|"emits"| node_emit
node_user -->|"searches"| node_discovery
node_cli -->|"presents results"| node_json
node_user -->|"configures"| node_config
node_user -->|"develops with"| node_vite
node_vite -->|"supports"| node_plugins

click node_cli "https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands"
click node_commands "https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands/_generated"
click node_generator "https://github.com/cloudflare/cf/blob/main/packages/cli/generator/generator.ts"
click node_emit "https://github.com/cloudflare/cf/tree/main/packages/cli/generator/emit"
click node_sdk "https://github.com/cloudflare/cf/blob/main/packages/cli/src/sdk/sdk/Client.ts"
click node_api "https://github.com/cloudflare/cf/tree/main/packages/cli/src/sdk/sdk/api/resources"
click node_transport "https://github.com/cloudflare/cf/tree/main/packages/cli/src/sdk/sdk/core"
click node_workers "https://github.com/cloudflare/cf/blob/main/packages/cli/src/commands/init/workers.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_commands,node_discovery,node_json toneBlue
class node_generator,node_emit toneAmber
class node_sdk,node_api,node_transport,node_cloudflare toneMint
class node_workers,node_config,node_vite,node_plugins toneRose
class node_user toneIndigo
```

## Components

### CLI experience

- [cf CLI](https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands): `packages/cli/src/commands`
- [Generated commands](https://github.com/cloudflare/cf/tree/main/packages/cli/src/commands/_generated): `packages/cli/src/commands/_generated`
- **Command discovery**
- **JSON interface**

### Command generation

- [Command generator](https://github.com/cloudflare/cf/blob/main/packages/cli/generator/generator.ts): `packages/cli/generator/generator.ts`
- [Command emission](https://github.com/cloudflare/cf/tree/main/packages/cli/generator/emit): `packages/cli/generator/emit`

### API client

- [SDK client](https://github.com/cloudflare/cf/blob/main/packages/cli/src/sdk/sdk/Client.ts): `packages/cli/src/sdk/sdk/Client.ts`
- [API resources](https://github.com/cloudflare/cf/tree/main/packages/cli/src/sdk/sdk/api/resources): `packages/cli/src/sdk/sdk/api/resources`
- [SDK core](https://github.com/cloudflare/cf/tree/main/packages/cli/src/sdk/sdk/core): `packages/cli/src/sdk/sdk/core`

### Product capabilities

- [Workers setup](https://github.com/cloudflare/cf/blob/main/packages/cli/src/commands/init/workers.ts): `packages/cli/src/commands/init/workers.ts`
- **TypeScript config**
- **Vite development**
- **Developer plugins**

### Other components

- **Engineer or agent**
- **Cloudflare API**

## Connections

- Engineer or agent → cf CLI: invokes
- cf CLI → Generated commands: dispatches
- Generated commands → SDK client: calls
- SDK client → API resources: exposes (evidence: `packages/cli/src/sdk/sdk/Client.ts`)
- SDK client → SDK core: uses
- API resources → Cloudflare API: API operations
- Command generator → Command emission: emits
- Engineer or agent → Command discovery: searches
- cf CLI → JSON interface: presents results
- Engineer or agent → TypeScript config: configures
- Engineer or agent → Vite development: develops with
- Vite development → Developer plugins: supports
