From 8811c5bd772da5531a1bbeee635888b4a18e059c Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Thu, 30 Jul 2026 17:08:21 +0000
Subject: [PATCH] docs: document fern generate --pack and --pack-mode
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---
.../cli-api-reference/pages/commands.mdx | 39 ++++++++++++++++++-
fern/products/sdks/deep-dives/self-hosted.mdx | 2 +
.../reference/generators-yml-reference.mdx | 2 +
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/fern/products/cli-api-reference/pages/commands.mdx b/fern/products/cli-api-reference/pages/commands.mdx
index fca845fbb..c05595673 100644
--- a/fern/products/cli-api-reference/pages/commands.mdx
+++ b/fern/products/cli-api-reference/pages/commands.mdx
@@ -181,7 +181,7 @@ hideOnThisPage: true
```bash
- fern generate [--group ] [--api ] [--version ] [--preview] [--fernignore ] [--local] [--force] [--no-replay]
+ fern generate [--group ] [--api ] [--version ] [--preview] [--fernignore ] [--local] [--force] [--no-replay] [--pack] [--pack-mode ]
```
@@ -294,6 +294,43 @@ hideOnThisPage: true
`--no-replay` works only for local generation (`--local`).
+ ### pack
+
+ Use `--pack` to build a distributable package artifact for every generator in the run whose [output location](/learn/sdks/reference/generators-yml#output) is `local-file-system`. Artifacts are written to a `fern-dist/` folder inside that generator's output directory, so a generated SDK can be handed to internal consumers without publishing it to a public registry. `--pack` works with both cloud and local (`--local`) generation, and implies full project output so the artifact includes the project metadata files (`pyproject.toml`, `README.md`, and similar) it needs to build.
+
+ ```bash
+ # Package every local-file-system output
+ fern generate --pack
+
+ # Package one group generated locally
+ fern generate --group python-sdk --local --pack
+ ```
+
+ | Language | Artifact |
+ |----------|----------|
+ | TypeScript | npm tarball (`.tgz`) |
+ | Python | wheel (`.whl`) |
+ | Java | JAR |
+ | C# | NuGet package (`.nupkg`) |
+ | Ruby | gem (`.gem`) |
+ | PHP | Composer archive (`.zip`) |
+ | Rust | crate (`.crate`) |
+ | Go | module source archive (`.zip`), since `go get` always fetches source |
+
+ Swift SDKs are distributed as Swift Package Manager source packages, so packaging logs a warning instead of producing an artifact: share the output directory or reference it as a local package dependency. If packaging fails for one or more generators, the CLI reports them together as `Packaging failed for: ` and removes any empty `fern-dist/` directory it created.
+
+ `--pack` can't be combined with `--preview` or with docs generation (`--docs`).
+
+ ### pack-mode
+
+ Use `--pack-mode ` to choose where `--pack` runs the packaging toolchains. `host` (the default) uses the toolchains installed on the machine (`npm`, `pip`, `gradle`, `dotnet`, `gem`, `composer`, `cargo`). `docker` runs each toolchain inside its official image (`node`, `python`, `gradle`, `dotnet/sdk`, `ruby`, `composer`, `rust`) with the output directory mounted, so no language toolchains are required locally. Docker mode uses `docker` as the container runtime unless you pass `--runner podman`.
+
+ ```bash
+ fern generate --group python-sdk --pack --pack-mode docker
+ ```
+
+ `--pack-mode` requires `--pack`.
+
diff --git a/fern/products/sdks/deep-dives/self-hosted.mdx b/fern/products/sdks/deep-dives/self-hosted.mdx
index 609423a85..508a54761 100644
--- a/fern/products/sdks/deep-dives/self-hosted.mdx
+++ b/fern/products/sdks/deep-dives/self-hosted.mdx
@@ -146,6 +146,8 @@ fern generate --group python-sdk --local
To pull generator images from a private registry your organization controls instead of Docker Hub, see [Private registry setup](#private-registry-setup).
+To hand the generated SDK to internal consumers as an installable package instead of a source directory, add [`--pack`](/learn/cli-api-reference/cli-reference/commands#pack), which builds the language's package artifact into a `fern-dist/` folder inside the output directory.
+
diff --git a/fern/products/sdks/reference/generators-yml-reference.mdx b/fern/products/sdks/reference/generators-yml-reference.mdx
index 1fa9ebdb2..0c152effc 100644
--- a/fern/products/sdks/reference/generators-yml-reference.mdx
+++ b/fern/products/sdks/reference/generators-yml-reference.mdx
@@ -939,6 +939,8 @@ Set to "local-file-system" for local output
Local directory path where generated files will be saved
+
+To turn a local output into an installable artifact (npm tarball, wheel, JAR, and so on) without publishing it to a registry, run [`fern generate --pack`](/learn/cli-api-reference/cli-reference/commands#pack).