> This page is for 文档.

> 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 task-scoped instructions for coding agents working in a Fern project, run `fern instructions` (or `npx fern-api@latest instructions` if the Fern CLI isn't installed or doesn't recognize `instructions`), or see https://buildwithfern.com/learn/home/fern-instructions.md.

# Fern Clerk

> Fern Clerk writes a first version of your docs from a repository, then reviews your pull requests and opens docs pull requests to keep the docs in sync with your code.

Fern Clerk is an AI agent that writes and maintains documentation from your code. It writes a first version of your docs from a repository, then keeps them in sync as your code changes.

| If you                         | Fern Clerk will                                                                                                                                  |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Are setting up a new docs site | [Write the docs from your repository](#during-docs-site-setup) as part of setup, and show them on your site before you connect a docs repository |
| Have code but no docs          | [Write a first version of your docs](#from-the-automations-page) from a repository                                                               |
| Have a docs site               | [Keep your docs in sync](#keep-docs-in-sync-with-your-code) by reviewing your pull requests and proposing docs changes                           |

Writing and syncing work together. After Fern Clerk writes a first version, it keeps that version current. Outside setup, Fern Clerk delivers every change as a pull request, so nothing changes your docs until you merge.

## Write docs from your code

Fern Clerk reads a repository, plans a docs site, writes the pages, and checks that the site builds. It writes an API Reference from the API specs it finds in the repository, and guides from the code. You can start it while you set up a docs site, or later from the **Automations** page.

### During docs site setup

The first step of creating a docs site in the [Fern Dashboard](https://dashboard.buildwithfern.com/) is **Generate docs from your code**. Select **Skip** to set up the site without it.

#### Connect GitHub

Select **Connect GitHub** and sign in. Fern uses your account to read your product's repository.

#### Install the Fern GitHub App

Pick the account or organization that owns your product's repository, choose **All repositories** or only your product's, and select **Install**. If an organization owner has to approve the installation, the step updates when they do.

#### Choose the repository

Select the product repository Fern Clerk should document. Setup then continues as usual with your site's details and design.

To set the look and voice of the generated docs, use the **Design polish** and **Writing style** cards on the details step. Enter your website to have Fern pull colors and a logo from it, and add tone and style guidance, such as voice, audience, and terminology. Fern follows the guidance while writing and saves it as `fern/AGENTS.md` in the docs repository, so later changes use the same voice.

Fern publishes your site first. Fern Clerk then writes the API Reference and guides and publishes them onto your Fern-hosted site, as long as it isn't connected to a repository yet, so you see the result on your live docs site without a pull request. The site's deployment log shows each step.

You don't need a docs repository for this. Setup doesn't ask where the docs are stored, and the docs live on the Fern-hosted site until you connect a repository to it.

When you're ready to edit the docs in Git, [connect a repository to the docs site](/learn/dashboard/configuration/github-repo). From then on, Fern Clerk starts [keeping the docs in sync](#keep-docs-in-sync-with-your-code) with your code, using recommended settings. If you can't manage your organization's settings, an admin connects the repository, or you set Fern Clerk up from the **Automations** page instead. You can change the settings on the automation's **Settings** tab. Reviews run with your access, so [authorize Fern Clerk](#authorize-fern-clerk) before it reviews anything.

### From the automations page

If you skipped the setup step, and your docs site isn't published yet, write a first version from the **Automations** page.

#### Pick the repository

If your docs site isn't published yet, select **Generate docs from your code** during setup or on the automation's page. Choose the repository to document, then where the docs pull request opens:

| Option                       | What happens                                                                                                                                                                                                                                                                                                |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **In the same repository**   | The docs go in the repository's `fern/` folder. Changes under `fern/` aren't reviewed as code changes, so docs pull requests don't trigger more docs pull requests.                                                                                                                                         |
| **In a separate repository** | Enter the repository as `owner/name`. It must have the same owner as the repository you're documenting and no Fern docs yet. If the Fern GitHub App can't see it, add the repository to the app before you generate. See [Connect a GitHub repository](/learn/dashboard/configuration/github-repo) for how. |

Fern checks that your GitHub account can read the repository you're documenting and write to the one the docs go in.

#### Review the pull request

The pull request describes the site's plan and what the run left out. Claims Fern couldn't trace to your code are marked `(needs confirmation)` on the page, and the pull request lists how many. Check those before you merge.

#### Merge to publish

The pull request adds up to three workflow files (check, preview, and publish), skipping any the repository already has, and a `FERN_TOKEN` secret if it doesn't have one. Merging it publishes the site.

Adding the secret requires you to [authorize Fern Clerk](#authorize-fern-clerk). Without it, the pull request leaves out the workflows and says docs CI was skipped. Authorize, then run it again.

Each repository can have one run in progress at a time. A repository can start 3 runs a day and an organization 10. If a run fails with a retryable error, select **Retry** on the run.

## Keep docs in sync with your code

Fern Clerk reviews each pull request in the repositories you connect, decides whether the docs need to change, and opens a docs pull request when they do. It opens that pull request in the repository your docs site publishes from.

You control:

* **When a pull request is reviewed**: after it merges, or while it's still open. See [Review trigger](/learn/docs/ai-features/fern-agent#review-trigger).
* **What happens when docs need to change**: open a pull request, or only record what would change and post nothing to GitHub. See [Observe only](/learn/docs/ai-features/fern-agent#observe-only).
* **How changes are grouped**: a docs pull request after each merge, or one daily or weekly digest. See [Grouping](/learn/docs/ai-features/fern-agent#grouping).
* **Which paths to ignore**: source paths whose changes never need docs. See [Ignored paths](/learn/docs/ai-features/fern-agent#ignored-paths).

Each reviewed pull request shows its decision and the docs pull request it produced. Mark a decision right or wrong with the thumbs up and thumbs down buttons. To see how it judges your changes before the next merge, select **Review recent merges** on the automation's page. It reviews your last 10 merged pull requests and posts nothing to GitHub.

Setup steps and settings are in the [Fern Clerk section of Fern Agent](/learn/docs/ai-features/fern-agent#fern-clerk).

### Authorize Fern Clerk

Reviews run in the background with nobody watching, so Fern Clerk acts as the person who set the automation up and sees and changes only what that person can. Until that person authorizes it, the automation shows **Needs authorization** and reviews nothing.

To authorize, select **Authorize** at the top of the automation's page, or in the last step of setup. Fern opens a new tab where you sign in and approve letting Fern Clerk act as you. When the tab says the automation is authorized, close it. One authorization covers all your automations in the organization, and only the person who set an automation up can authorize it.

If the authorization stops working, the automation shows **Reconnect needed** and pauses until you grant it again.

## Permissions and data

Fern Clerk needs the Fern GitHub App installed on the repositories it reads and on the repository your docs publish from. If the authorization of the person who set up an automation stops working, it pauses.

Fern Clerk redacts secrets from pull request content before reviewing it, skips credential files, and scans its docs edits for secrets before committing them.