Fern CLI

How the Fern CLI stays clear for people and predictable for scripts and agents.

Reach for it when
  • Adding a command, flag, prompt or message to the fern CLI or @fern-api/wizard.
  • Printing anything a person reads in a terminal: status, progress, errors and next steps.

The short version

If you read nothing else on this page, read these.

✓ Created fern/ from openapi.yaml⚠ No logo found. Using the starter logo.✗ fern check found 2 errors in fern/docs.yml
Do. Lead each status with its glyph and say it in words, in the terminal's own colors.
Created fern/ from openapi.yamlNo logo foundfern check found 2 errors
Don't. Hard-code a color and let it carry the status. On a light terminal there's nothing left.
✗ Couldn't create the Fern project.  pnpm exited with code 1. To see the full error, run:  $ pnpm exec fern init --log-level debug
Do. Say what failed in words, then the command that fixes it.
Error: ENOENT: no such file or directory, open 'generators.yml'    at Object.openSync (node:fs:573:18)    at readFileSync (node:fs:452:35)    at loadGenerators (cli.cjs:88231:19)
Don't. Print the stack trace and leave the fix to the reader.
$ npx @fern-api/wizard < /dev/nullInteractive mode needs a terminal.Re-run with --yes to accept the defaults.
Do. Without a terminal, stop at once and name the flag that answers the question.
? Fern organization name (used for fern.config.json) Error: The job timed out after 360 minutes.
Don't. Wait for an answer nobody can type. In CI, the job hangs until it times out.

Fern CLI splash

Plays once as it scrolls into view. Switch to a light terminal to see why the summary beside the logo uses the terminal's own colors.

~/code/acme
$ npx @fern-api/wizard 

Primitives

What every Fern command does, distilled from clig.dev, GitHub's CLI guidelines, Heroku's CLI style guide and Atlassian's principles for delightful CLIs. Download them for an agent working in fern-api/fern.

10 primitives
  1. 01Status is a glyph and words, never color aloneStart the line with ✓, ✗, ⚠ or ◆, then say what happened. Color backs it up in chalk's named colors, so the person's theme picks the shade, and turns off under NO_COLOR or when stdout isn't a terminal.
  2. 02Errors say what happened, then how to fix itName the failure in words, not an internal id, and put the command that fixes it on the next line. Stack traces and raw tool output appear only with --log-level debug.
  3. 03Every prompt has a flagPrompt only when stdin is a terminal, and show the default. Every answer is also a flag and --yes takes every default, so a script, a CI job or a coding agent never waits on a question. Without a terminal, stop at once and name the flag.
  4. 04Streams and exit codes are the APIResults go to stdout; progress, warnings and errors go to stderr. Data has a --json form with no color or prose. Exit 0 when it worked and anything else when it didn't: a failed step fails the run, even if later steps pass.
  5. 05Respond at once, and show the shape of the workPrint something within 100 ms. Count work of known length (3 of 8) and narrate the rest in a present-tense line (Scanning ~/acme…). Animate only in an interactive terminal; in CI, print one line when a step starts and one when it ends.
  6. 06End with the next stepFinish on the commands to run next, exactly as they'll run ($ pnpm exec fern check), then a prompt to hand to a coding agent. ✓ is only for what already happened.
  7. 07Help leads with examplesEvery command takes --help: one line on what it's for, the common examples, then every flag with its default. Flags are long and kebab-case, and a mistyped command suggests the closest one.
  8. 08Writes are safe by defaultAnything that writes takes --dry-run. Never overwrite a file someone wrote; skip it and say so. Changes outside the repo, like signing in or editing ~/.cursor/mcp.json, are opt-in, and --yes never widens them.
  9. 09Ctrl-C always worksStop at once, give back the cursor and exit with 130. A terminal left without a cursor is the most visible bug a CLI can ship.
  10. 10Speak like FernUse the dashboard's voice and names: sentence case, outcome first, no exclamation marks or em dashes. One name per thing (docs site, SDK, API definition) and one meaning per flag, on every command.

In a terminal and in CI

Every command reads top to bottom in the same order: what it found, what you chose, what it did, what to run next. The wizard's first run, at a keyboard and then in CI.

At a keyboard: each step shows the command it runs, and the run ends on what to do next.

~/code/acme
What Fern can do for this repo   ✓ SDK generation: found openapi.yaml (OpenAPI 3.0.3)    https://buildwithfern.com/learn/sdks/overview/introduction  ✓ API documentation: build docs from openapi.yaml    https://buildwithfern.com/learn/docs/getting-started/overview  ✓ Fern MCP for coding agents: found a claude-code configuration    https://buildwithfern.com/learn/docs/ai-features/fern-mcp-servers ? Choose what to set up Fern CLI, Fern project, Docs site, Agent handoff? Site title Acme? Docs URL (acme.docs.buildwithfern.com) acme? Landing page layout Stacked? Features API Reference, Ask Fern, Changelog ◆ Install the Fern CLI  $ pnpm add -D fern-api✓ Installed fern-api◆ Create a Fern project from your OpenAPI spec  $ pnpm exec fern init --openapi openapi.yaml --org acme✓ Created fern/ with fern.config.json and generators.yml◆ Create a docs site from a template  Stacked layout · acme.docs.buildwithfern.com · API Reference, Ask Fern, Changelog✓ Wrote fern/docs.yml, fern/docs/ and fern/styles.css◆ Teach your coding agent about Fern✓ Wrote .claude/skills/fern/SKILL.md⚠ Skipped AGENTS.md: already exists Next steps   $ pnpm exec fern check  $ pnpm exec fern docs dev  $ pnpm exec fern generate --docs    https://acme.docs.buildwithfern.com Hand this to your coding agent   Help me get started with Fern. Read https://buildwithfern.com/learn/home/get-started.md and follow it step by step.

In CI: flags answer every question, and the exit code fails the job even though a later step passed.

$ npx @fern-api/wizard --yes --org acme✓ Scanned ~/work/acme: openapi.yaml, fastapi, pnpm◆ Install the Fern CLI✓ Installed fern-api◆ Create a Fern project from your OpenAPI spec✗ Couldn't create the Fern project. pnpm exited with code 1.  Run it yourself to see the full error:  $ pnpm exec fern init --openapi openapi.yaml --org acme --log-level debug◆ Create a docs site from a template✓ Wrote fern/docs.yml, fern/docs/ and fern/styles.css$ echo $?1

Glyphs

Five status glyphs and two markers, each with its ASCII fallback and chalk style. Dim is for detail lines, bold for headings and names.

✓+Done, or foundgreen
✗xFailedred
⚠!Worked, with a caveatyellow
◆*A step, or an answercyan
??A questiongreen.bold
$$A command to rundim
…...Still workingdim

Keep going

Content
Write plainly with sentence case. Follow these guidelines to ensure you do so.
Design language
The macro guidelines that define design at Fern.
Accessibility
Fern supports accessibility standards out of the box.