# Tutorial: document an undocumented repository

import { Steps, Aside } from '@astrojs/starlight/components';

Turn a repository that has no documentation into a structured documentation set: an overview, a getting started guide, and an API reference. You start from an empty session and finish with a single pull request that adds all three pages, written to a consistent style.

By the end, you can:

- Have the agent survey a codebase and propose a documentation structure.
- Generate several linked pages in one session.
- Teach the agent your style and terminology so the pages read as one set.
- Review every new page and ship them all in one pull request.

The whole path takes about 30 minutes. For a single README, see [Getting started](/agent/getting-started/). To update docs that already exist, see [Tutorial: document a code change](/agent/tutorial-document-a-code-change/).

## Before you begin

You need:

- An EkLine account in your organization.
- A repository that contains working code but little or no documentation. A small library or service works best for a first run.
- Permission to open pull requests on that repository.

You don't write any documentation by hand in this tutorial. You direct the agent, review what it drafts, and refine it with follow-up prompts.

## Step 1: Connect your repository

The agent documents only code it can read, so connect a repository first.

<Steps>
1. Log in to your [EkLine dashboard](https://ekline.io/dashboard).
2. Click **New session** in the sidebar. If the composer shows **Docs** and **Marketing**, select **Docs**.
3. If you haven't connected a repository yet, follow [Connect GitHub to EkLine](/agent/github-app-setup/) to install the GitHub App and select which repositories the agent can access.
</Steps>

**Verify:** The new session page reads **I can help improve your documentation**, with a box for your request. The editor panel opens on the left once the agent drafts a file.

<img
    className={'rounded-2xl'}
    width={1288}
    height={711}
    src={`/assets/images/docs-agent-editor.png`}
    alt={`A new Docs Agent session with the sessions sidebar and the chat panel ready for a prompt`}
/>

If you use GitLab instead, follow [Connect GitLab to EkLine](/agent/gitlab-setup/). The rest of this tutorial is the same.

## Step 2: Survey the codebase

Before you generate a single page, let the agent read the repository and tell you what a documentation set should contain. This grounds every later page in what the code actually does.

In the chat panel, type:

```text
This repository has no documentation. Survey the codebase and
propose a documentation structure. List the pages to create, what
each page should cover, and who it is for.
```

The agent reads your repository structure, source files, and configuration, then responds with a proposed outline.

<Aside type="tip" title="Shape the structure to your readers">
If you already know your audience, say so: `"The main readers are developers integrating our SDK."` The agent adjusts which pages it proposes and how deep each one goes.
</Aside>

**Verify:** The agent responds with a list of proposed pages and a short description of each. Read it and decide which pages to create first. The next steps create three: an overview, a getting started guide, and an API reference.

## Step 3: Generate the overview page

Start with the page that frames everything else. Give the agent the page, the audience, and where it belongs.

```text
Create an overview page at docs/index.md. Explain what this
project does, who it is for, and its key capabilities. Keep it
to a short introduction that links out to the other pages.
```

**Verify:** A draft of the overview appears in the editor panel on the left. Read it and confirm the description of the project matches what the code does.

## Step 4: Generate the rest of the set

With the overview in place, add the remaining pages in the same session. The agent keeps each new page consistent with the ones already drafted.

<Steps>
1. Generate the getting started guide:
   ```text
   Create a getting started guide at docs/getting-started.md.
   Cover installation, the minimum configuration, and a first
   working example pulled from the code.
   ```
2. Generate the API reference:
   ```text
   Create an API reference at docs/api-reference.md for the
   public functions in this repository. Include parameters,
   return values, and an example for each.
   ```
3. Switch between the drafts in the editor panel to read each page.
</Steps>

For more ways to generate each page type, see [Create documentation](/agent/create/) and [Generate an API reference](/agent/generate-api-reference/). To pull in a spec or a design doc from a connected tool, see [Combine multiple sources](/agent/combine-sources/).

**Verify:** The editor panel shows a tab for each of the three new files: `docs/index.md`, `docs/getting-started.md`, and `docs/api-reference.md`.

## Step 5: Make the pages read as one set

Separate prompts can drift in tone and terminology. Bring the set into line with a single follow-up.

```text
Review these three pages together. Use the same term for each
concept across all of them, match the heading style, and make
sure every link between the pages resolves.
```

Because the agent is now changing pages it already drafted, the editor shows its edits under a **Reviewing changes** banner. Open each page's tab, read the changes, and click **Accept All** to keep them or **Reject All** to discard them.

<Aside type="note" title="Set the style once for every future session">
To apply your voice, terminology, and structure automatically in every session, save them as organization instructions. See [Customize for your organization](/agent/custom-instructions/). After you set them once, you can skip this step on your next repository.
</Aside>

**Verify:** The agent updates the drafts so the pages share terminology and heading style, and the cross-links between them point to real pages.

## Step 6: Review the whole set

Never ship a first draft unread. You know your product, so check the set before it becomes a pull request.

<Steps>
1. Open each file in the editor panel and read it in full.
2. Check the file tabs in the editor panel for any file you didn't ask for.
3. Check three things on every page:
   - **Accuracy**: Does each page describe what the code actually does?
   - **Completeness**: Does the getting started guide take a reader from nothing to a working example?
   - **Consistency**: Do the three pages use the same terms and structure?
</Steps>

If something is off, ask the agent to fix it rather than editing by hand. For example: `"The installation command in the getting started guide is wrong. Read the package configuration and correct it."`

**Verify:** The three pages are accurate, complete, and consistent, and the editor panel holds no file you didn't ask for.

## Step 7: Ship the set in one pull request

When the set reads well, publish all three pages through your normal review process.

<Steps>
1. Click **Raise PR** in the toolbar.
2. The agent prefills a prompt such as `Open a pull request`. Edit it to add a title or description if you want, then press **Enter**.
3. The agent creates the pull request and responds in the chat with a link to it on GitHub.
</Steps>

**Verify:** The chat shows a link to a new pull request. Open it. The PR adds your three documentation pages and nothing else.

## Summary

You took a repository from no documentation to a review-ready pull request. Along the way you:

- Had the agent survey the codebase and propose a structure.
- Generated an overview, a getting started guide, and an API reference in one session.
- Brought the pages into a single, consistent style.
- Reviewed every page and shipped the whole set in one pull request.

You now have a documentation set to build on. Each time your product changes, you update it with the same review-and-refine loop rather than starting over.

## Next steps

- [Customize for your organization](/agent/custom-instructions/): save your voice and terminology so every future session matches them.
- [Prevent documentation drift](/agent/prevent-documentation-drift/): catch pages that fall out of date as your code changes.
- [Tutorial: document a code change](/agent/tutorial-document-a-code-change/): keep the set you created in sync with your code.
- [Integrations](/agent/integrations/): pull context from Slack, Notion, Linear, Jira, and Confluence into your prompts.