# Driftless # Introduction Source: /introduction > What Driftless is, and how it keeps docs in step with code. Driftless is an open-source docs site with agent skills. Your coding agent writes pages from your code and updates them from each pull request. It also keeps draw.io diagrams, screenshots and clips current. You review every change. Create the site in your app repo or a repo of its own, and name it. Add the skills to Claude Code, Codex or another agent. ## How it works Each docs page lists the product files it describes. The agent that builds a feature also updates the pages that the feature changes, in the same session. If the docs are in your app repo, the docs change goes in the same pull request. If they are in a repo of their own, the agent drafts a linked docs pull request. On each pull request, a check lists the pages to review. A weekly check finds anything that slipped through. ## What you get | Part | What it does | |---|---| | Static site | Astro and MDX, with search, light and dark themes, versions and an API reference. | | Source map | Links each page to the product files it describes. | | Drift checks | Lists pages that a change can make out of date, on each pull request and each week. | | Diagrams | Editable draw.io files that the agent updates in place. | | Screenshots and clips | Captured by a script from seeded demo data, in light and dark. | | Agent skills | `driftless-init`, `docs-update`, `docs-diagram` and `docs-capture`. | Driftless has no telemetry and no hosted service. The site is static files on any host. ## Limits The drift check compares file paths. A changed file means that a page can be out of date. It does not prove that the page is wrong. A person or an agent still reads the page and the change. These docs are built with Driftless, in a repo of their own, and they describe the Driftless repo. The same drift checks keep them current. --- # For coding agents Source: /agents > The repo, the commands and the setup steps, for an agent that sets up Driftless for a user. This page is for a coding agent that a user asked to set up Driftless. Follow the steps in order. Ask the user only for what you cannot find. | Item | Value | |---|---| | Framework repo | `MitchStares/driftless` on GitHub | | Package | `driftless-docs`, installed from the repo's release tags | | Licence | MIT | | Needs | Node.js 24 or later, git | | Agent instructions | `AGENTS.md` at the repo root, and in each new site folder | | Skills | `plugin/skills//SKILL.md` | ## 1. Choose the layout A Driftless site is a folder with `driftless.config.ts`. It can live in one of two places. Ask the user once. Recommend in-app unless a reason for a separate repo applies. | Layout | Where the site folder goes | Choose it when | |---|---|---| | **In-app** (recommended) | A folder in the app repo: `apps/docs` if the repo has an `apps/` folder, otherwise `docs-site` | The user owns the app and builds it with a coding agent. The docs change in the same pull request as the code. | | **Separate** | A repo of its own, usually beside the app: `../-docs` | The app is someone else's open-source project, another team owns the docs, or one site covers several products. | ## 2. Create the site folder The same command creates both layouts. It finds the layout from git. ```bash # In-app: run in the app repo npx github:MitchStares/driftless init docs-site cd docs-site && npm install ``` ```bash # Separate: run beside the app repo npx github:MitchStares/driftless init ../my-app-docs cd ../my-app-docs && git init && npm install ``` In-app, `init` sets `product.path` to the repo root. It also writes `.driftless.json` at the repo root, so that other agents find the docs. In a separate repo, set `product.repo`, `product.path` and `product.ref` in `driftless.config.ts`. The site folder holds only content. The framework is in `node_modules/driftless-docs`. ## 3. Install the skills | Agent | Command | |---|---| | Claude Code | `/plugin marketplace add MitchStares/driftless`, then `/plugin install driftless@driftless` | | Codex | `codex plugin marketplace add MitchStares/driftless`, then `codex plugin add driftless@driftless` | | Other agents | Read `AGENTS.md`. It names the skill file for each task. | ## 4. Find the user's product Find these facts before you run the setup skill. Ask the user only for the ones you cannot find. - The product repo: its GitHub `owner/name` and a local checkout path. In-app, this is the repo you are in. - The branch or tag that the docs follow, for example `origin/main`. - The agent that the user works with. - Where the user will host the docs: a static host, or a container behind a sign-in. - If the product has a UI that can run locally with demo data, for screenshots. ## 5. Run driftless-init Run the `driftless-init` skill in the site folder. It reads the product code, sets `driftless.config.ts`, proposes the page structure in `docs/nav.ts`, and drafts the first pages. Show the user the proposed structure before you write pages. In-app, read the product code only. Write only in the site folder, `.driftless.json` and `.github/workflows/docs-check.yml`. ## 6. Check and hand over ```bash npm run build npm run check:sources ``` Then tell the user how to keep the docs current. - **In-app:** run `/docs-update` before you open each feature pull request, so that the docs change goes in the same pull request. Copy `node_modules/driftless-docs/templates/github/docs-check.yml` to the app's `.github/workflows/` and set `SITE_DIR`. - **Separate:** run `/docs-update` on each product pull request. Copy `docs-impact.yml` from the same folder to the product repo, and `drift.yml` to the docs repo. Refer to [Linked pull requests](/linked-prs). ## Rules - Do not add telemetry, analytics or calls to other hosts. Refer to `PRIVACY.md`. - Keep the user's brand in `theme` in `driftless.config.ts`. The defaults are neutral. - Edit diagrams in place. Do not regenerate a `.drawio` file over manual edits. - Do not assume a host. The site is static files in `dist/`. --- # Set up your site Source: /setup > Name, logo, theme and the product repo. Driftless keeps your settings in one file and your content in one folder. A site created with `init` holds only these files. The framework is in `node_modules/driftless-docs`, and `npm update driftless-docs` upgrades it. | Path in the site folder | What it holds | |---|---| | `driftless.config.ts` | Site name, logo, versions, Ask, product repo, capture and diagram settings | | `docs/nav.ts` | Tabs, groups and pages | | `docs/pages/` | One `.mdx` file for each page | | `docs/diagrams/` | `.drawio` sources and their exported `.svg` files | | `docs/source-map.json` | The product files behind each page | | `public/brand/`, `public/product/`, `public/logos/` | Your logo, product images and clips, and integration logos | | `STYLE-GUIDE.md` | How to write pages | | `AGENTS.md` | Instructions for coding agents that work in the site folder | ## Choose the layout The site folder can live in your app repo, or in a repo of its own. | Layout | Where the site goes | Choose it when | |---|---|---| | **In-app** (recommended) | A folder in the app repo, such as `docs-site` | You own the app. The docs change in the same pull request as the code. | | **Separate** | A docs repo of its own | You document someone else's project, another team owns the docs, or one site covers several products. | The drift checks and the skills find the layout from git, so the two need no different settings. ## Start a new site For an in-app site, run this in your app repo: ```bash npx github:MitchStares/driftless init docs-site cd docs-site && npm install && npm run dev ``` For a separate site, run it beside your app repo, then start a repo: ```bash npx github:MitchStares/driftless init my-docs cd my-docs && git init && npm install && npm run dev ``` In-app, `init` also writes `.driftless.json` at the app repo root. It tells the skills where the docs are. In `driftless.config.ts`, set `site.name`, `site.docsTitle`, `site.website` and `site.home`. Remove `site.cta` to hide the header button. Put a light and a dark logo in `public/brand`. Set `site.logo` to their paths. Without a logo, the header shows the site name. Set `theme` in `driftless.config.ts`. Leave it out to keep system fonts and the default accent. Refer to [Fonts and colours](#fonts-and-colours). Set `product.repo`, `product.path` and `product.ref`. The drift checks and the agent skills read these. In-app, `init` already set `product.path` to the repo root. ## Fonts and colours The default theme uses each reader's system fonts, so a reader's browser downloads no font files. Set `theme` in `driftless.config.ts` to change this. ```ts theme: { fonts: 'geist', accent: { light: '#b45309', dark: '#f5a524' }, diagramAccent: { light: '#b45309', dark: '#f5a524' }, }, ``` | Setting | What it does | |---|---| | `fonts: 'system'` | The default. Each reader sees their platform's own fonts. | | `fonts: 'geist'` | Serves Geist and Geist Mono from your site. Readers download about 140 KB, once. | | `fonts: { sans, mono, files }` | Your own font stacks. Put the font files in `public/` and list them in `files`. | | `accent` | The colour of buttons, links and selection, for light and dark. The site mixes the hover and selection shades from it. | | `diagramAccent` | The highlight colour in diagrams. Leave it out to keep the drawio-design accent. | Your own site serves every font file. No setting loads a font from another host. The default values are in `src/styles/tokens.css` in the framework. Each light value has a dark value under `[data-theme='dark']`. ## Or let an agent do it Install the [agent skills](/skills), open Claude Code in your app repo, and run `/driftless-init`. It asks which layout you want, creates the site folder, reads your product code, proposes a structure, and fills in the config, the nav and the source map. ## More than one site in a repo A site is a folder with `driftless.config.ts`, `docs/` and `public/`. Each `driftless-docs` command works on the folder you run it in. To work on another folder, set `DRIFTLESS_ROOT`: ```bash DRIFTLESS_ROOT=examples/open-webui npx driftless-docs build ``` Every command reads `DRIFTLESS_ROOT`, including the screenshots, diagrams and drift checks. The [Open WebUI example](https://github.com/MitchStares/driftless-site/tree/main/examples/open-webui) works this way. --- # Agent skills Source: /skills > Install the skills in Claude Code, Codex or another agent, and use each skill. Driftless comes with a set of agent skills. They write pages, keep them current, draw diagrams and capture images. They follow the rules in `STYLE-GUIDE.md`. The skills are plain Markdown files in `plugin/skills`. Claude Code and Codex install them as a plugin. Both plugins use the same files, so the skills do not drift apart. ## Install in Claude Code In Claude Code, run: ```text /plugin marketplace add MitchStares/driftless /plugin install driftless@driftless ``` The plugin depends on two other plugins, so Claude Code installs them too: - [drawio-design](https://github.com/MitchStares/drawio-design) draws the diagrams. - [ste80-humanizer](https://github.com/Dodaios/ste80-humanizer) rewrites text in plain English. Both install from their own repos, at the version that Driftless was tested with. ## Install in Codex Run: ```bash codex plugin marketplace add MitchStares/driftless codex plugin add driftless@driftless ``` Codex does not install plugin dependencies. Install drawio-design too, so that `docs-diagram` can draw: ```bash codex plugin marketplace add MitchStares/drawio-design codex plugin add drawio-design@mitchstares-skills ``` `npm run prose` runs the ste80-humanizer checker from the docs repo, so it works with no extra install. ## Use another agent `AGENTS.md` at the repo root tells any coding agent how the site works and which skill file to read for each task. Agents that read `AGENTS.md`, such as Cursor and GitHub Copilot, can use the skills with no install. To install the skills into an agent's own skills folder, run: ```bash npx skills add MitchStares/driftless ``` ## Update Claude Code does not update community plugins on its own. To get updates in Claude Code, do one of these: - In `/plugin`, go to **Marketplaces**, select **driftless** and turn on auto-update. - Run `claude plugin update driftless@driftless`. In Codex, run `codex plugin marketplace upgrade`. The Driftless repo checks the two upstream plugins each week. When one has a new version, a pull request moves the pin, and a new Driftless plugin version follows. ## Skills | Skill | Use it to | |---|---| | `driftless-init` | Read an app's code, propose the docs structure, and draft the first pages. | | `docs-update` | Draft docs for a product pull request, finish them after the merge, or run the weekly sweep. | | `docs-diagram` | Create or change a draw.io diagram that follows the theme. | | `docs-capture` | Capture screenshots and short clips from a running copy of the app. | | `ste80-humanizer` | Rewrite text in plain, clear English. `npm run prose` runs a copy of its checker. | ## Use them from the product repo `docs-update` usually runs in the product repo, in the same session that built the feature. It reads `.driftless.json` at the product repo root to find the docs: ```json { "docsPath": "docs-site" } ``` In-app, `init` writes this file. For a separate docs repo, add it yourself with the path to the docs repo, such as `../my-docs`. Then run `/docs-update` on the feature branch. In Codex, ask it to "run docs-update for this change". It decides if the change needs docs. In-app, it commits the docs change to the same branch, before you open the pull request. With a separate repo, it drafts a docs pull request and links the two. --- # Deploy Source: /deploy > Publish the docs on a static host, or run them in a small container behind your company sign-in. `npm run build` writes a static site to `dist/`: plain HTML, CSS and a small script. Any static host can serve it. The site must be served from the root of a domain or subdomain, such as `docs.example.com` or `my-docs.pages.dev`. ## Public docs on a static host | Host | Build command | Output folder | |---|---|---| | Cloudflare Pages | `npm run build` | `dist` | | Netlify | `npm run build` | `dist` | | Vercel | `npm run build` | `dist` | | Azure Static Web Apps | `npm run build` | `dist` | | GitHub Pages | `npm run build` | `dist` (with a custom domain) | Set the Node version to 24 on the host. Set `SITE_URL` to the public address of the site. For an in-app site, set the root directory, or base directory, to the site folder, such as `docs-site`. The host then reads the output folder from inside it. Driftless needs no account with any host. These hosts are examples only. ## Internal docs in a container Docs for an internal application, or for one customer's deployment, should not be public. Run them as a container in the same network as the app, behind the same sign-in. The Driftless repo has a `Dockerfile` and an `nginx.conf`. Copy both into your site folder. The `Dockerfile` builds the site, then serves it with unprivileged nginx on port 8080. The image is about 20 MB to download. Run the build in the site folder: ```bash docker build -t my-docs . ``` ```bash docker run --rm -p 8080:8080 my-docs ``` Open `http://localhost:8080`. Deploy the image where your app runs, for example Azure Container Apps, AWS App Runner, Google Cloud Run or Kubernetes. Put it behind the same identity provider as the app, for example with Microsoft Entra ID, Cloudflare Access or an authenticating proxy. The container serves files to anyone who can reach it. It has no sign-in of its own. Keep internal docs behind your identity provider. A `robots.txt` that blocks search engines is not access control. ### Build options | Build argument | Use | |---|---| | `DRIFTLESS_ROOT` | Build another site in the repo, such as `examples/open-webui` | | `DRIFTLESS_INTERNAL=1` | Include [internal tabs](/write-a-page#internal-pages), for a docs team's own copy | | `SITE_URL` | The address the docs are served at | ## Checks on each pull request Each layout has a workflow template in `node_modules/driftless-docs/templates/github/`. | Layout | Workflow | What it does | |---|---|---| | In-app | `docs-check.yml` in the app repo | Lists the pages that each pull request affects. When the pull request changes docs, it builds the site and attaches `dist` to the run, so reviewers can open the built pages. | | Separate | `docs-impact.yml` in the product repo, `drift.yml` in the docs repo | Lists the pages that each product pull request affects, and checks every page each week. | A build artifact works on every host. If your host makes preview deployments for pull requests, you can use those too. Refer to [Linked pull requests](/linked-prs#check-each-pull-request-automatically). ## Privacy Driftless has no telemetry and no hosted service. The built site loads nothing from other hosts. `astro.config.mjs` turns off Astro's own telemetry and update check. The only call to another host is Ask, and only if you set `ask.endpoint`. `PRIVACY.md` in the repo lists every network call that the scripts and workflows can make. --- # Write a page Source: /write-a-page > Add a page, pick its type and check the writing. ## Add a page 1. Add an entry to `docs/nav.ts` with a `title`, `slug` and `description`. 2. Add the slug to `docs/source-map.json` with its `type` and the product `sources` it describes. 3. Create `docs/pages/.mdx`. Until the file exists, the page shows "Not written yet". The title and description come from the nav entry. Set them in the front matter only to override it. A content file with no nav entry stops the build, so no page is unreachable. ## Internal pages Some pages are only for the docs team, such as how to write and maintain the docs. Mark their tab as internal in `docs/nav.ts`: ```ts { id: 'authoring', title: 'Authoring', icon: 'pen-line', internal: true, groups: [ ... ] } ``` An internal tab shows in `npm run dev`. Production builds leave it out, with its pages, search entries and `llms.txt` lines. To include it in a build, for example for the docs team's own copy, set `DRIFTLESS_INTERNAL=1`. Use an internal tab for pages that only the docs team needs, such as how to write and maintain the docs. ## Pick a page type Every page uses one type: concept, how-to, integration or reference. `STYLE-GUIDE.md` lists the headings for each type. The example pages in the Documentation tab show each one. ## Record what you checked Each written page records the product commit it was checked against, and how: ```yaml verified: commit: a1b2c3d method: Ran the steps on a local copy ``` The drift check uses this commit. State the method honestly. "Read the code" is valid. ## Check the writing ```bash npm run prose -- docs/pages/get-started/quickstart.mdx npm run build ``` The prose checker finds sentences to look at again. A person or an agent still reads the page. --- # Components Source: /components > Every component you can use in a page. These components work in every `.mdx` page without an import. ## Callout Extra facts the reader may need. A faster or better way to do something. Put a warning before the step it protects. ```mdx Text ``` ## Cards Icons are Lucide names. Cards link to other pages. ```mdx Text ``` ## Steps One action in each step. Steps can hold code blocks and images. ## Tabs ```bash npm install ``` ```bash pnpm install ``` `Tabs` takes labels separated by `|`. Each direct child is one panel. Add `plain` for a row of product images. ## Accordion Use an accordion for detail that most readers can skip. ## Param The number of results. The default is `20`. ## Update One line for each change. ## Diagram, Screenshot and Clip ```mdx ``` Refer to [Diagrams](/diagrams) and [Screenshots and clips](/screenshots). --- # Diagrams Source: /diagrams > Draw editable draw.io diagrams that follow the theme. Diagrams are native draw.io files, drawn with the [drawio-design](https://github.com/MitchStares/drawio-design) skill. Anyone can open and edit them later. One file serves the light and the dark theme. ## Before you start - Install the agent skills. The driftless plugin installs drawio-design with it. Refer to [Agent skills](/skills). - Install the draw.io desktop app. `npm run diagrams` uses it to export. Set `DRAWIO` to its path if `drawio` is not on PATH. ## Draw a new diagram In Claude Code, ask for the diagram and name the page it is for, for example "draw how a request moves through the API, for the API overview page". The `docs-diagram` skill picks the type, states its plan, and builds the file from a script in `docs/diagrams/src/.py`. The skill runs drawio-design's `check_drawio.py` and renders a preview. It fixes every defect the check names, such as text that does not fit or lines that cross a box. Run `npm run diagrams -- `. This writes `docs/diagrams/.svg`, with theme tokens in place of colours. Add the diagram to the page. The alt text says what the diagram shows, not how it looks. ```mdx ``` ## Change a diagram Open `docs/diagrams/.drawio` in draw.io or diagrams.net, or ask Claude Code to edit the XML in place. Do not run the script in `docs/diagrams/src` again: it would overwrite manual edits. Then run `check_drawio.py` and `npm run diagrams -- `. ## How the theme works 1. You draw with colours from the palette in `driftless.config.ts`. The default palette matches drawio-design's default skin. 2. `npm run diagrams` exports each `.drawio` file to SVG. 3. The export changes each palette colour to a `--d-*` token from `src/styles/tokens.css`. Each token has a light and a dark value. A colour outside the palette stays as drawn, and the export lists it. Set `diagrams.strict: true` to stop the export instead. To use your brand colours, make a drawio-design profile, and write `profile: ` in a `.diagram-design` file at the repo root. Then put the profile's colours in `diagrams.palette` and the `--d-*` tokens. ## Rules | Rule | Why | |---|---| | Canvas 560px wide | Text draws at about its real size in the page column | | Light skin only | The site maps colours to theme tokens for dark mode | | Plain-text labels, in sentence case | HTML labels export as images | | Accent on one or two items | The accent marks what the diagram is about | | About 9 boxes at most | Over that, split it into an overview and a detail | | Dashed outline for a boundary that someone else owns | It shows who runs what | --- # Screenshots and clips Source: /screenshots > Capture product images and short clips from a running app. Product images go out of date when the UI changes. Driftless captures them with a script, so you can take them all again in one command. ## Screenshots List each screen in `driftless.config.ts`: ```ts capture: { appUrl: 'http://127.0.0.1:3000', themes: ['light', 'dark'], // Optional: runs once in Node, for example to sign in. Its result is passed to init. setup: async ({ appUrl }) => ({ token: await signIn(appUrl) }), // Runs in the page before each load. It is sent to the browser as text, so use only its arguments. init: (theme, data) => { localStorage.setItem('theme', theme); localStorage.setItem('token', data.token); }, views: [ { name: 'home', path: '/' }, { name: 'new-item', path: '/items', selector: '[role=dialog]', prepare: async (page) => { await page.getByRole('button', { name: 'New item' }).click(); } }, ], clips: [], }, ``` Then run: ```bash npx playwright install chromium ffmpeg # once npm run screenshots ``` Each view gives `public/product/-light.webp` and `-dark.webp`. The page shows the image that matches the reader's theme: ```mdx ``` ## Clips A clip shows a short flow, such as a drag or a multi-step change. Write the steps with Playwright: ```ts clips: [ { name: 'create-item', path: '/items', steps: async (page) => { await page.getByRole('button', { name: 'New item' }).click(); await page.getByLabel('Name').fill('Quarterly report'); await page.waitForTimeout(400); await page.getByRole('button', { name: 'Save' }).click(); } }, ], ``` ```bash npm run clips # .webm for the docs npm run clips -- --gif # also a .gif, for READMEs and pull requests ``` Clips need `ffmpeg` to trim the page load and to make GIFs. ```mdx ``` ## Rules - Use demo or seed data. Never show customer data, real names, keys or internal hostnames. - The script captures only from `localhost` or `127.0.0.1`. To capture from a test server that holds only demo data, set `CAPTURE_ALLOW_REMOTE=1`. Never capture a customer deployment. - If the app has no demo data, write a seed script, and a mock server for any paid API it calls. The [Open WebUI example](https://github.com/MitchStares/driftless-site/tree/main/examples/open-webui/demo) has both. - Keep view names stable, because pages refer to them. - Keep a clip under 10 seconds. --- # Linked pull requests Source: /linked-prs > The docs change goes with each product change. In-app, it is in the same pull request. With a separate docs repo, it is a linked docs pull request. The docs stay current because the work happens next to each product change, not in a big rewrite later. The coding agent that builds a feature also runs `/docs-update`, in the same session. Each docs change covers one product change, so it stays small. How the docs change travels depends on the layout: | | In-app | Separate | |---|---|---| | Where the docs change goes | The same branch and pull request as the code | A linked pull request in the docs repo | | When the agent runs `/docs-update` | Before it opens the feature pull request | When the product pull request is ready for review | | After the merge | Nothing to do. The merge covers both. | `/docs-update finish` completes the docs pull request | | Workflow | `docs-check.yml` in the app repo | `docs-impact.yml` in the product repo | ## What needs docs | Change in the product pull request | Docs | |---|---| | A new view, control, label or flow in the UI | Needed | | A new or changed setting, default or environment variable | Needed | | A change to the API: endpoints, fields, errors or limits | Needed | | Deployment, container, cloud services, permissions or sign-in | Needed | | A change in behaviour that a user can notice, such as limits or costs | Needed | | A refactor, tests, or an internal fix with no visible effect | Not needed | If you are unsure, draft the docs. A small docs change costs less than a wrong page. ## In-app: docs in the same pull request Work on the feature branch as usual, with Claude Code, Codex or another agent. Run it on the feature branch, before you open the pull request. The `docs-update` skill reads the diff, matches the changed files against `docs/source-map.json`, and changes only the site folder. It commits the docs change last, after the code. The pull request has the code and the docs. If no docs change is needed, add a line `Docs: not needed ()` to its body. Reviewers read the docs change in the same diff. `docs-check.yml` attaches the built site to the run. The merge needs no extra step. The commit that changes a page counts as its check, so in-app pages need no `verified` commit. Refer to [How drift checks work](/drift#in-app-sites). ### Check each pull request automatically 1. Copy `node_modules/driftless-docs/templates/github/docs-check.yml` to `.github/workflows/docs-check.yml` in the app repo. 2. Set `SITE_DIR` in the file to the site folder, such as `docs-site`. On each pull request, the workflow lists the pages whose sources changed while the page did not. It keeps one comment on the pull request up to date. When the pull request changes docs, it builds the site and attaches `dist` as an artifact for 14 days. Reviewers download it and open `index.html`, or serve it with any static server. The check is advisory. To make it block a merge, set `REQUIRE_DOCS` to `'true'` and make the check required in the branch rules. A `Docs: not needed ()` line in the pull request body then lets the check pass. The workflow needs no secrets, because the docs and the code are in one repo. ## Separate: a linked docs pull request Add a `Docs:` line to the product repo's pull request template, so that every pull request has one. Leave it empty. Run it when the pull request is ready for review. The skill reads the diff, matches the changed files against `docs/source-map.json`, and decides. Either the `Docs:` line says `not needed` with a reason, or it links a draft docs pull request on the branch `product/pr-`. The draft lists the screenshots and clips to capture again. Review and merge it as usual. It sets `verified` on each changed page to the merge commit, builds the site, and marks the docs pull request ready. Capture images again first if the draft listed any. ### Tell the skill where the docs are `/docs-update` usually runs in the product repo. Add `.driftless.json` to the product repo root, so that the skill finds the docs repo: ```json { "docsPath": "../my-docs" } ``` In-app, `init` writes this file for you, with the site folder's path. ### Check each pull request automatically This feature is in beta. A workflow in the product repo can list the docs pages that each pull request affects. It does not write docs. It tells the author and the reviewers which pages to check. 1. Copy `templates/github/docs-impact.yml` from the `driftless-docs` package to `.github/workflows/docs-impact.yml` in the product repo. 2. Set `DOCS_REPO` in the file to your docs repo. 3. If the docs repo is private, add a `DOCS_REPO_TOKEN` secret to the product repo. Use a fine-grained token with read access to the docs repo contents. On each pull request, the workflow compares the pull request with its base branch. It writes the list of affected pages to the job summary and keeps one comment on the pull request up to date. If the pull request affects no page, it adds no comment. The check is advisory. To make it block a merge, set `FAIL_ON_IMPACT` to `'true'` and make the check required in the branch rules. Do this only after the source map is complete, or the check flags pages that do not need a change. ## Forks and secrets Both workflows use the `pull_request` trigger, so a pull request from a fork gets a read-only token and no secrets. On a fork, the comment step can fail, but the job summary still has the result. `docs-check.yml` builds the pull request's code, like any CI job. `docs-impact.yml` runs no code from the pull request. It only compares files. ## Catch what slips through Some changes skip the flow. `npm run check:drift` lists written pages whose product sources changed after the page was last checked. A weekly workflow keeps a "Docs drift" issue up to date with that list. Run `/docs-update sweep` to fix them in one change. Refer to [How drift checks work](/drift). ## Upstream products If you document a product that someone else owns, such as an open-source project, use a separate docs repo. The skill only reads the upstream pull requests. It never comments on them or edits them. Each docs pull request links the upstream change instead. --- # How drift checks work Source: /drift > Link pages to product code and find pages that went out of date. Docs drift when the product changes and the page does not. Driftless finds drift by linking each page to the product files it describes. ## The source map `docs/source-map.json` lists the product files behind each page: ```json { "pages": { "get-started/quickstart": { "type": "how-to", "sources": ["README.md", "src/cli/init.ts"], "visuals": ["screenshot: home"] } } } ``` `npm run check:sources` checks that every page has an entry and that every source file exists at `product.ref`. ## The drift check `npm run check:drift` lists pages whose sources changed after the page was last checked, up to `product.ref`. How it finds the last check depends on the layout. It finds the layout from git: if the site folder and `product.path` are in the same repo, the site is in-app. ### Separate sites Each written page has a `verified.commit`, the product commit that someone checked the page against. The check lists pages whose sources changed between that commit and `product.ref`. It also lists pages with no `verified` commit. `/docs-update finish` sets it after each product merge. ### In-app sites The docs and the code share one history, so the last commit that changed a page counts as its check. A page is stale when its sources changed in a later commit. If a page has a `verified.commit` that is later, the check uses that commit instead. | Merge style | Result | |---|---| | Squash merge | Code and docs are in one commit, so the page is current. | | Rebase or merge commit, docs committed last | The page is current. | | Rebase or merge commit, docs committed first | The page shows as stale. `/docs-update` commits the docs last to prevent this. | ### Options Add `-- --issue` to keep one "Docs drift" GitHub issue up to date. The workflow templates run this each Monday: `docs-check.yml` in-app, `drift.yml` in a separate docs repo. If a separate product repo is private, add a `PRODUCT_REPO_TOKEN` secret with read access to it. | Option | What it does | |---|---| | `--json` | Prints the result as JSON, for other tools and CI steps. It includes the `layout`. | | `--fail` | Exits with code 1 if a page needs review or a `verified` commit is not in the product repo. | | `--no-fetch` | Uses the product checkout as it is, with no `git fetch`. | | `--issue` | Keeps the "Docs drift" issue up to date. This works only in drift mode. | ## Check one change Set `PRODUCT_BASE` to check one change instead of all pages. The script then lists the written pages whose sources changed between the merge base of `PRODUCT_BASE` and `PRODUCT_REF`. This is the same diff that a pull request shows. ```bash PRODUCT_BASE=origin/main PRODUCT_REF=HEAD npm run check:drift ``` The result also counts the changed files that no page maps. Some of them can need a new page. Both workflows in [Linked pull requests](/linked-prs) use this mode. In-app, the same change can update the pages too. The result then puts each page in one of two lists: - **Stale:** its sources changed and the page did not. With `--fail`, these pages make the check fail. - **Updated:** its sources changed and the change also edits the page. ## What the check can and cannot tell you The check compares file paths. A changed source file means that a page can be out of date. It does not prove that the page is wrong, and it cannot find a wrong page whose sources did not change. A person or an agent still reads the page and the change. ## Fix drift - For each product change, run `/docs-update`. In-app, it adds the docs change to the feature pull request. With a separate repo, it drafts a linked docs pull request. Refer to [Linked pull requests](/linked-prs). - With a separate repo, run `/docs-update finish ` after the merge. It updates `verified.commit`. - Each week, run `/docs-update sweep` to fix the pages in the drift issue. These steps are advisory. A missing docs change blocks a merge only if you turn that on in the workflow. --- # Ask and search Source: /ask > How search works and how to connect Ask to a model. ## Search Search works with no setup. The build writes `search.json` with the text of every page, and the browser searches it. Press Ctrl K, or ⌘ K on a Mac. ## Files for AI tools The build also writes files that AI tools can read: | Path | What it holds | |---|---| | `/llms.txt` | A list of every page with its description | | `/llms-full.txt` | Every written page as Markdown, in one file | | `/.md` | One page as plain Markdown | Each page also has **Copy page**, which copies it as Markdown. ## Ask Ask starts in preview mode. It shows the sample answers from `ask.samples` in `driftless.config.ts`, and search matches for other questions. To connect a model, set `ask.endpoint` to a URL that accepts a POST request: ```json { "question": "How do I add a page?", "page": "/ask" } ``` and returns: ```json { "answer": ["First paragraph.", "Second paragraph."], "sources": [{ "title": "Write a page", "href": "/write-a-page" }] } ``` A small serverless function can do this. It reads `llms.txt` and the `.md` pages, sends the question and the matching pages to a model, and returns the answer. Keep the model key in the function. Never put it in the site.