agentleFS
leroyguillaumeleroyguillaume/claude/starlight-conventions/SKILL.md

starlight-conventions

Skill7 starsChanged 4 days agoMITView on GitHub

Astro Starlight documentation sites: setup, theme, links, versions, `llms.txt`. TRIGGER when: editing a Starlight site (`astro.config.*` with `@astrojs/starlight`, `src/content/docs/`); moving Markdown docs into a site; setting up GitHub or GitLab Pages for docs; user asks about a docs site, doc versions or `llms.txt`. SKIP when: plain Markdown with no site generator, or another generator (MkDocs, Docusaurus, …).

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check what the Pages settings actually hold (gh api repos/{owner}/{repo}/pages --jq .cname, or the GitLab project's Pages page) rather than …

    line 37
  2. Very specific:

    Run astro build --force --outDir <staging>/out/<label> from docs/ with the version passed through the environment, then copy the output …

    line 143
  3. Very specific:

    Add starlight-llms-txt to every site.

    line 176
  4. Distinctive:

    Never deploy from the tag's checkout.

    line 210
  5. Very specific:

    Never set site/base without asking where the site is served.

    line 220
  6. Distinctive:

    Never copy the logo into the site, and never pick theme colours that are not the logo's, or an accent under 4.5:1 on its background.

    line 221
  7. Distinctive:

    Never write a relative link or a base-prefixed link in the content, and never put an internal link in the frontmatter.

    line 223
  8. Distinctive:

    Never commit per-version snapshots of the content, and never build a version from outside the project directory.

    line 225
  9. Distinctive:

    Never treat a pre-release tag as a documentation version.

    line 227
  10. Distinctive:

    Never deploy the site from a tag pipeline's checkout.

    line 228

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Starlight conventions

A documentation site is an Astro project in docs/ with its own package.json and lockfile, on the Node.js the root mise.toml pins (mise-conventions). frontend-conventions applies to its TypeScript (strict tsconfig, Biome, no any), with two adjustments: UI is .astro components, not React, and tsc --noEmit is astro check, which also checks the content frontmatter.

Ask the public URL first

Before writing astro.config.ts, ask where the site will be served. site and base follow from it, and a wrong base does not fail the build: it produces a site whose every page, stylesheet and image URL answers 404. The symptom is an unstyled "Skip to content" page with a broken image.

Served atsitebase
a custom domain (docs.example.com)https://docs.example.com/ (omit it)
GitHub Pages without a custom domainhttps://<owner>.github.io/<repo>/
GitLab Pages, unique domainthe unique domain URL/
GitLab Pages, <group>.<pages-domain>/<project>https://<group>.<pages-domain>/<project>/

Check what the Pages settings actually hold (gh api repos/{owner}/{repo}/pages --jq .cname, or the GitLab project's Pages page) rather than assuming. A custom domain added later means changing site and dropping base.

Theme from the logo

  • Use the repository's logo file itself, never a copy: logo: { src: "../logo.svg" }, and docs/public/favicon.svg as a symlink to ../../logo.svg (inside the repo, so allowed). No logo in the repo → ask for one before theming.
  • Read the colours from the logo and set Starlight's tokens in src/styles/theme.css, listed in customCss: --sl-color-accent-low, --sl-color-accent, --sl-color-accent-high, --sl-color-white, --sl-color-gray-1 … -6 (-7 in light mode) and --sl-color-black, on :root (dark) and :root[data-theme="light"].
  • Each theme takes as accent the logo colour that reads on its background, at ≥ 4.5:1 contrast for link text: typically the dark brand colour in light mode and the bright one in dark mode. Compute the ratio; never pick by eye. In light mode --sl-color-text-accent is the accent, in dark mode it is --sl-color-accent-high.
  • Tint the grays with the dominant brand hue instead of Starlight's default blue-gray. Light mode inverts the scale (white is the darkest).
  • Say in one comment at the top of theme.css which logo colours these are.

Content and links

  • Pages are Markdown under src/content/docs/; guides/ and reference/ are autogenerated sidebar groups ({ label, items: [{ autogenerate: { directory } }] }), ordered by sidebar.order in each page's frontmatter.
  • Moving a README into the site: the site becomes the home of every fact; the README keeps the description, a minimal getting started and links to the site (readme-conventions, documentation-conventions). Extract sections by script rather than retyping them, then rewrite the anchors that crossed sections. Grep the repo for links into the old README (ARCHITECTURE.md, CONTRIBUTING.md, code comments) and repoint them.
  • Link pages by root-absolute path, /guides/metrics/, without the base. A plugin adds the base (below). Links to repository files are https:// URLs to the forge, since the site is served elsewhere.
  • starlight-links-validator is mandatory: the build fails on a broken internal link or anchor, and on a relative link. It also reads frontmatter links (hero actions), which are not base-prefixed: keep internal links out of the frontmatter and put them in the page body.
  • Astro 7's default Markdown processor is Sätteri: markdown.remarkPlugins do not run. Pass plugins through markdown.processor: satteri({ mdastPlugins: [...] }) from @astrojs/markdown-satteri (declare it and satteri as dependencies).

The base-prefixing plugin. An mdast plugin runs before the hast plugins, so the validator sees the prefixed links:

import { defineMdastPlugin } from "satteri";

export function prefixBase(url: string, base: string): string {
	if (!url.startsWith("/") || url.startsWith("//") || base === "/") return url;
	return base.replace(/\/$/, "") + url;
}

export function baseLinks(base: string) {
	return defineMdastPlugin({
		name: "base-links",
		link(node, ctx) {
			ctx.setProperty(node, "url", prefixBase(node.url, base));
		},
		definition(node, ctx) {
			ctx.setProperty(node, "url", prefixBase(node.url, base));
		},
	});
}

Versions

A versioned site serves:

PathContent
/the latest stable release
/next/the default branch, with a banner saying it is unreleased
/vX.Y/each older minor release, at its last patch, with a banner

Stable tags only (^v\d+\.\d+\.\d+$); a tag with a - is never a version. Tags that predate the site (no docs/src/content/docs in their tree) are skipped. With no release left, the default branch takes / and there is no picker.

Every version is the current site around the pages of its tag: the config, theme and components of the default branch, the content of the tag. A site fix reaches every version; the pages of a release stay as released. Never commit snapshot copies of the content per version.

The build

npm run build:versions runs scripts/build.ts with Node's native type stripping (node scripts/build.ts, imports with a .ts extension):

  1. List the stable tags that contain the content directory (git cat-file -e <tag>:docs/src/content/docs) and plan the builds with a pure, unit-tested function: tags in, { label, path, latest, ref } out.
  2. For a tag, stage the current src/ under docs/.versions/<label>/, mirroring the repository (.versions/<label>/docs/src/, .versions/<label>/logo.svg) so the content's relative paths still resolve, and replace its content with git archive <tag> docs/src/content/docs | tar -x. Staging stays inside the project: a copy elsewhere with a symlinked node_modules breaks Astro's module resolution.
  3. Run astro build --force --outDir <staging>/out/<label> from docs/ with the version passed through the environment, then copy the output into dist/<path>. --force is required: the content-layer cache lives in the shared node_modules and would serve the previous version's pages.
  4. Clean .versions/ in a finally. It is git-ignored and excluded from tsconfig.json.

The environment is tooling's, so the variables carry the project prefix (<PROJECT>_DOCS_VERSIONS: the JSON list, validated with zod on read; <PROJECT>_DOCS_VERSION: the label being built; <PROJECT>_DOCS_SRC_DIR: the staged sources). astro.config.ts reads them once through a small module and derives base (the version's path) and srcDir (the staged sources, else ./src). Unset, the build is a plain single version at /, which is what astro dev and astro build give.

Picker and banner

  • Picker: override SocialIcons (components: in the Starlight config) with a <select> rendered at build time from the version list, followed by the default component. Every version is rebuilt on each deployment, so the list is static; no runtime fetch of a versions.json. The client script swaps the current base for the target one in location.pathname, keeping the page. Keep that function in its own module so the client bundle doesn't pull zod.
  • Banner: override Banner to render, before the default one, a notice on every version that is not the latest ("unreleased development version" for next, "an older release" otherwise) linking to /.
  • Biome only analyses an .astro file's frontmatter, so it flags imports used in the template. Turn noUnusedImports and noUnusedVariables off for **/*.astro in a biome.json override.

llms.txt

Add starlight-llms-txt to every site. It is base-aware, so each version gets its own llms.txt, llms-full.txt and llms-small.txt, and the root one, the standard location, describes the latest release. On a versioned site pass details: one sentence naming the version the file covers and the absolute URLs of the other versions' llms.txt. A model reads the file outside the site. Link /llms.txt from the README next to the documentation link.

Tests and checks

  • npm test runs node --test '{src,scripts}/**/*.test.ts': the version planning, the version-list parsing, the page-switching function and the base-prefixing plugin (through markdownToHtml from satteri, not a hand-built tree). It runs in the quality pipeline, never in a hook (pre-commit-conventions).
  • Pre-commit hooks, as local language: system hooks on files: ^docs/, pass_filenames: false: npm --prefix docs run lint (biome check .) and npm --prefix docs run check (astro check). The quality job therefore runs npm ci --prefix docs before pre-commit.
  • check-added-large-files already skips docs/package-lock.json through the baseline lockfile exclude (pre-commit-conventions). A hook takes a single exclude: extend that regex, never replace it.
  • The dependency bot tracks npm in /docs. Pin typescript within the peer range of @astrojs/check; a major it does not accept fails the install.
  • The build logs structured key=value lines on stderr, never console.*.

The docs pipeline

Independent of the platform (syntax in github-actions-conventions and gitlab-ci-conventions):

  • Change proposal: build every version (validation, links included), deploy nothing.
  • Push to the default branch: build every version and deploy.
  • Stable release: rebuild and deploy from the default branch, since the root now serves a new release and /next/ must stay the default branch. Never deploy from the tag's checkout.
  • Path filter: docs/**, the logo, and the pipeline file. Releases and manual runs are not filtered.
  • A full clone with tags; a shallow one sees no version.
  • CONTRIBUTING.md documents the site: where pages live, how to link, the versioning model, and the commands (npm --prefix docs run dev, build, build:versions after git fetch --tags, test).

Never

  • Never set site/base without asking where the site is served.
  • Never copy the logo into the site, and never pick theme colours that are not the logo's, or an accent under 4.5:1 on its background.
  • Never write a relative link or a base-prefixed link in the content, and never put an internal link in the frontmatter.
  • Never commit per-version snapshots of the content, and never build a version from outside the project directory.
  • Never treat a pre-release tag as a documentation version.
  • Never deploy the site from a tag pipeline's checkout.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.