# Install

## Add the package

This is a Starlight plugin that requires Astro v7+.

**pnpm**

```sh
pnpm add @nu-appdev/starlight-agent-docs
```

**npm**

```sh
npm install @nu-appdev/starlight-agent-docs
```

**yarn**

```sh
yarn add @nu-appdev/starlight-agent-docs
```

## Register the plugin

Import the plugin in `astro.config.mjs` and add it to Starlight’s `plugins`.

> **Two things to get right**
>
> * Set Astro’s `site`. It is the base URL used for the links in `/llms.txt`.
> * Register `starlightAgentDocs()` **after** any theme or plugin that overrides Starlight’s `EditLink` component.

astro.config.mjs

```js
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import starlightAgentDocs from "@nu-appdev/starlight-agent-docs";


export default defineConfig({
    site: "https://docs.example.com",
    integrations: [
        starlight({
            title: "Example Docs",
            description: "Documentation for Example.",
            sidebar: [
                { label: "Guides", items: [{ autogenerate: { directory: "guides" } }] },
                { label: "Reference", items: [{ autogenerate: { directory: "reference" } }] },
            ],
            plugins: [
                starlightAgentDocs({
                    guidance: "Start with the guides before reading the reference.",
                }),
            ],
        }),
    ],
});
```

## Check the output

Build the site. The plugin adds a `.md` file for each page and an `llms.txt` to the output directory.

**pnpm**

```sh
pnpm build
```

**npm**

```sh
npm run build
```

**yarn**

```sh
yarn build
```

* dist/

  * llms.txt

  * index.md

  * guides/

    * getting-started/

      * index.html
      * index.md

During `astro dev`, the same URLs are served on the fly, and draft pages are included.

> **Note**
>
> If a file in your `public/` directory has the same path as a generated Markdown file or `llms.txt`, the build fails instead of overwriting it.
