---
title: Agent setup
description: Run docslit agents init to write AGENTS.md, Claude Code skills, Cursor, Copilot, Windsurf and Gemini files and MCP config so your AI tool writes valid DocsLit pages.
tag: AI and agents
readtime: 6 min read
---
> For AI agents: the complete documentation index is at [llms.txt](https://docs.docslit.com/0.3/llms.txt). This page as Markdown: [ai-and-agents/agent-setup.md](https://docs.docslit.com/0.3/ai-and-agents/agent-setup.md).


# Agent setup

`docslit agents init` writes the instruction files an AI coding tool needs to write correct DocsLit pages in your project. It reads your `docslit.json`, so the instructions name your real sidebar groups, versions and locales.

```bash
npx docslit agents init
```

New projects already have an `AGENTS.md`. `docslit init` writes it unless you pass `--no-agents`.

## What it writes

`AGENTS.md` is always written. It is the cross-tool convention, and Codex reads it directly. Other files are written for the tools it detects in your project, or for the tools you name with `--tool`.

| Tool | Detected when the project has | Files written |
|---|---|---|
| Claude Code | `.claude/` or `CLAUDE.md` | `.claude/skills/docslit-author/SKILL.md`, `.claude/skills/docslit-migrate/SKILL.md`, `CLAUDE.md`, `.mcp.json` |
| Cursor | `.cursor/` | `.cursor/rules/docslit.mdc`, `.cursor/mcp.json` |
| GitHub Copilot | `.github/` | `.github/instructions/docslit.instructions.md`, `.vscode/mcp.json` |
| Windsurf | `.windsurf/` | `.windsurf/rules/docslit.md` |
| Gemini CLI | `GEMINI.md` or `.gemini/` | `GEMINI.md`, which imports `AGENTS.md` |
| Codex | not detected | nothing extra: Codex reads `AGENTS.md` |

Pass `--tool all` to write every tool's files, or a comma-separated list:

```bash
docslit agents init --tool all
docslit agents init --tool claude,cursor
docslit agents init ./my-docs --tool copilot --json
```

Here is a real run in a fresh project with `--tool all --json`:

```json
{
  "tools": ["claude", "cursor", "copilot", "windsurf", "codex", "gemini"],
  "detected": [],
  "written": [
    ".claude/skills/docslit-author/SKILL.md",
    ".claude/skills/docslit-migrate/SKILL.md",
    "CLAUDE.md",
    ".mcp.json",
    ".cursor/rules/docslit.mdc",
    ".cursor/mcp.json",
    ".github/instructions/docslit.instructions.md",
    ".vscode/mcp.json",
    ".windsurf/rules/docslit.md",
    "GEMINI.md"
  ],
  "updated": ["AGENTS.md"],
  "unchanged": [],
  "skipped": [],
  "notes": [
    "Codex reads AGENTS.md directly; no extra files needed.",
    "GEMINI.md imports AGENTS.md with Gemini CLI's `@file` syntax.",
    "MCP is configured where the tool supports a project-level file (Claude Code, Cursor, VS Code Copilot); Windsurf, Codex and Gemini MCP settings are user-level, add `npx -y docslit mcp` there yourself."
  ]
}
```

<wc-fields header="Options">
<wc-field name="--tool" type="string">
Comma-separated list from `claude`, `cursor`, `copilot`, `windsurf`, `codex`, `gemini`, or `all`. Default: `AGENTS.md` plus the tools detected in the project.
</wc-field>
<wc-field name="--force" type="flag">
Overwrite generated files that you changed, and replace a customized `docslit` MCP entry.
</wc-field>
<wc-field name="--json" type="flag">
Print the result as JSON. The keys are `tools`, `detected`, `written`, `updated`, `unchanged`, `skipped` and `notes`. On failure the output is `{ "error": "..." }` and the exit code is 1.
</wc-field>
</wc-fields>

The optional first argument is the project directory. It defaults to the current directory.

## What is in AGENTS.md

The block between `<!-- docslit:start -->` and `<!-- docslit:end -->` holds a short, project-specific brief:

- where pages live and how a page id maps to a file
- whether the sidebar is explicit, autogenerated or mixed, and the names of your groups
- your versions and locales, if you use them
- the [authoring loop](overview#the-authoring-loop): discover with `docslit components --json`, create with `docslit new --json`, check with `docslit validate --format json` and `docslit lint --format json`
- the rules that prevent most mistakes: one H1, blank lines around components, close tags explicitly, respect nesting, use `icon` (`icon-name` is an alias) and `label`

## Safe to re-run

Run the command again after you upgrade DocsLit or change your sidebar. It is designed not to destroy your edits:

- Your own text in `AGENTS.md`, `CLAUDE.md` and `GEMINI.md` is kept. Only the marked block is replaced. If the file has no block yet, one is appended.
- Skill and rule files carry a `<!-- docslit:generated -->` marker. DocsLit updates files with the marker. It skips a file without the marker and reports it under `skipped`, unless you pass `--force`.
- MCP config files are merged. Other servers in `.mcp.json`, `.cursor/mcp.json` and `.vscode/mcp.json` are never touched. A `docslit` entry you customized is skipped unless you pass `--force`. A config file that is not valid JSON is skipped too.

## The skills

The Claude Code files are skills. Claude loads a skill when a task matches its description.

<wc-fields header="Skills">
<wc-field name="docslit-author" type="skill">
How to write and edit DocsLit pages. Its component reference is generated from the same manifest as `docslit components`, so it cannot drift from the CLI. It also covers frontmatter, the `docslit.json` options, autogenerated sidebars and the check loop.
</wc-field>
<wc-field name="docslit-migrate" type="skill">
How to migrate Mintlify, Fern, GitBook and MkDocs docs, and other MDX-based docs, into DocsLit. It starts with `docslit import`, works through the `MIGRATION.md` report and the `--json` output, and uses the MCP tool `convert_mdx` for single pages. See [Migrate with your AI agent](../migration/migrate-with-ai).
</wc-field>
</wc-fields>

Print either skill, or the `AGENTS.md` block, without writing files. This is useful for tools that take a system prompt instead of a file:

```bash
docslit agents print            # the author skill (default)
docslit agents print migrate    # the migrate skill
docslit agents print agents-md  # the AGENTS.md block
```

## Example prompts

With the files in place, you can give short instructions.

<wc-accordion-group>
<wc-accordion title="Create a new documentation page">

<wc-prompt title="Prompt">
Write a DocsLit page for our REST API authentication flow. Include steps for getting an API key, making a first request, and handling errors. Use code examples in curl, Python and JavaScript. Run validate and lint when you are done.
</wc-prompt>

The agent runs `docslit new`, writes `wc-steps` for the flow and `wc-code-group` for the languages, then fixes whatever `validate` and `lint` report.

</wc-accordion>
<wc-accordion title="Document API endpoints">

<wc-prompt title="Prompt">
Create an API reference page for our /users endpoints: GET /users, POST /users, GET /users/:id and DELETE /users/:id. Document every parameter.
</wc-prompt>

The agent uses `wc-endpoint`, `wc-fields` and `wc-field`, and checks each attribute with `docslit components wc-field --json`.

</wc-accordion>
<wc-accordion title="Migrate existing docs">

<wc-prompt title="Prompt">
Migrate the MDX files in ../old-docs into this project. Run docslit import with --dry-run first, then fix what the report flags by hand.
</wc-prompt>

The agent starts with the importer, reads the report, and uses the migrate skill for the rest. See the [migration guides](../migration/from-mintlify).

</wc-accordion>
</wc-accordion-group>

<wc-callout type="tip" title="Be specific">
Say who the page is for, what the reader should be able to do afterwards, and which components to use. "A getting-started page for backend developers, with steps and a code group" gives better results than "write a page about auth".
</wc-callout>

## Previous skill install method

Earlier versions of these docs told you to download skill files with `curl`. You do not need that any more. `docslit agents init` writes the same content from the version of DocsLit you have installed, so the instructions always match the CLI.

## Next steps

- Connect your tool to the [MCP server](mcp-server) for typed tools instead of shell commands
- Learn the [machine-readable CLI](machine-readable-cli) that the instructions point to
