diff --git a/.claude/skills/doc-check/SKILL.md b/.claude/skills/doc-check/SKILL.md index 3cfe79f2817..fc6632da8ff 100644 --- a/.claude/skills/doc-check/SKILL.md +++ b/.claude/skills/doc-check/SKILL.md @@ -25,10 +25,13 @@ writing them. - For local changes: `git diff main` or `git diff --staged` - For a branch: `git diff main...` -2. **Triage the diff.** Walk the +2. **Triage the diff.** Check the changed paths against + [`path-priors.md`](./path-priors.md) for what they predict, then walk the [quick decision checklist](../../../docs/.style/content-guidelines.md#quick-decision-checklist) in the content guidelines. Most non-user-facing diffs route out of the docs entirely; see [What not to comment on](#what-not-to-comment-on). + A prior sets the starting assumption, not the verdict: verify it against + the diff either way. 3. **Understand the scope.** Consider what changed: - Is this user-facing or internal? @@ -194,7 +197,11 @@ find this comment. ## What not to comment on Do not produce sticky-comment suggestions for these classes of change. -They have no user-visible documentation surface. +They have no user-visible documentation surface. When every changed file +falls in one of these classes, CI skips the review before this skill +runs, so a diff in front of you has already passed that gate or a +maintainer forced the review with the `doc-check` label. See +[`path-priors.md`](./path-priors.md). - **Auto-generated CLI docs** under `docs/reference/cli/`. These are generated from Go code under `cli/`; suggest edits to the CLI diff --git a/.claude/skills/doc-check/path-priors.md b/.claude/skills/doc-check/path-priors.md new file mode 100644 index 00000000000..e2831b5d604 --- /dev/null +++ b/.claude/skills/doc-check/path-priors.md @@ -0,0 +1,63 @@ +# Path priors + +What the changed paths predict about whether a change needs docs. A prior sets +the starting assumption and the burden of proof; it never replaces the evidence +discipline in [`SKILL.md`](./SKILL.md). Verify against the diff either way. + +Three classes. The first is decided before this skill runs. + +## Decided in CI: no documentation surface + +Tests and stories, generated output, dependency and toolchain manifests, build +and lint plumbing, styling, internal environments, vendored trees. When *every* +changed file is in this class, `.github/workflows/doc-check.yaml` skips the +review and no chat starts, so you will not see these diffs. + +Two consequences: + +- A mixed diff still reaches you. One qualifying file is enough to start a + review, so do not assume every file in front of you has a documentation + surface. +- The skip is overridable. A maintainer can force a review with the `doc-check` + label, which means you can be handed a diff the skip would otherwise have + dropped. Review it on its merits. + +The authoritative list is the `nodocs` filter in that workflow. Docs-affecting +CI is carved back out of it, because a change to how the docs build, deploy, +preview, or get reviewed can change the docs themselves. + +## Strong prior: absent docs is the finding + +These paths add or change a surface a user configures, types, calls, or lands +on. Missing documentation here is a gap, not a judgment call. Start from +"this needs docs" and look for the page that proves otherwise. + +| Change | Why it earns docs | +|---|---| +| New or changed `cli/` command or flag | Appears in `--help`, so it is user-facing by default | +| New or changed public `codersdk/` field or endpoint | The API is a first-class user surface | +| New `coderd/apidoc/` endpoint | Same, and the path must be documented in full | +| New or changed deployment option or `CODER_*` environment variable | Configuration is product surface area | +| New `site/src/pages/` route | A new navigable page is net-new surface | +| New licensed `enterprise/` feature, or a new Premium gate | Needs the page plus both Premium markers | +| A changed setup, enablement, or migration procedure | The steps a user follows are the documentation | +| Renamed or deprecated product or feature name | The glossary and every referring page drift otherwise | + +Two cautions that survive a strong prior: + +- An auto-generated reference page regenerating is not documentation. A new flag + landing in `docs/reference/cli/` still leaves a conceptual guide gap. +- A surface that is not visible by default, including anything behind an unsafe + experiment, has not reached the bar yet. + +## No prior: decide from the diff + +Everything unlisted, including component-level frontend changes, +`coderd/` handler behavior, provisioner changes, and database migrations. A +migration alone has no user surface, but it often ships next to an API change, +and the mixed-diff rule above means you will see that change too. + +Here the path tells you nothing and the evidence discipline decides. This is +also where the near-miss lives: a page enumerates a sibling surface rather than +the one that changed. Resolve it under the finding bar in `SKILL.md`, and prefer +naming no page over naming the nearest one. diff --git a/.github/workflows/doc-check.yaml b/.github/workflows/doc-check.yaml index 33fb2e76f17..b764d51cbd3 100644 --- a/.github/workflows/doc-check.yaml +++ b/.github/workflows/doc-check.yaml @@ -74,8 +74,115 @@ jobs: echo "skip=false" >> "${GITHUB_OUTPUT}" fi - - name: Determine PR Context + # A review costs the full skill context before it can conclude anything, + # so decide here instead of in the model when no changed file can have a + # documentation surface. Path classes live in + # .claude/skills/doc-check/path-priors.md; keep the two in sync. + - name: Classify changed paths + if: steps.check-secrets.outputs.skip != 'true' && github.event_name == 'pull_request' + id: filter + uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3 + with: + filters: | + all: + - "**" + nodocs: + # Extension patterns use the `**/*` form, not `**`. The globber + # treats a `**` glued to a suffix inconsistently: `**.test.ts` + # matches at any depth, but `**_test.go` only matches the repo + # root. `**/*` behaves the same at every depth, including the + # root, so every pattern here uses it. + # Tests, stories, and fixtures. + - "**/*_test.go" + - "**/*.test.ts" + - "**/*.test.tsx" + - "**/*.stories.tsx" + - "**/testdata/**" + # Generated output. Changes belong in the generator. + - "docs/reference/cli/**" + - "site/src/api/typesGenerated.ts" + - "**/*.pb.go" + - "**/*.golden" + - "coderd/apidoc/swagger.json" + - "coderd/apidoc/docs.go" + # Dependency and toolchain manifests. + - "go.mod" + - "go.sum" + - "package.json" + - "pnpm-lock.yaml" + - "site/package.json" + - "site/pnpm-lock.yaml" + - "**/mise.toml" + # Build, lint, and CI plumbing. Docs-affecting CI is carved back + # out by the ci_docs filter below. + - ".github/**" + - "Makefile" + - ".golangci.yaml" + - ".editorconfig" + - ".gitattributes" + - ".gitignore" + - "**/biome.jsonc" + - "**/.markdownlint.jsonc" + - "**/.markdownlint-cli2.jsonc" + # Styling only. A restyle changes no documented behavior. + - "**/*.css" + - "site/components.json" + # Internal environments and vendored trees. + - "dogfood/**" + - "**/vendor/**" + ci_docs: + # CI that builds, deploys, previews, or reviews the docs. A change + # here can change the docs themselves, so it earns a review even + # though it sits under .github. + - ".github/workflows/ci.yaml" + - ".github/workflows/doc-check.yaml" + - ".github/workflows/deploy-docs.yaml" + - ".github/workflows/docs-preview.yaml" + - ".github/workflows/audit-docs-paths.yaml" + - ".github/workflows/weekly-docs.yaml" + - ".github/workflows/test-deploy-docs-diff.sh" + - ".github/workflows/test-deploy-docs-release.sh" + - ".github/workflows/test-docs-preview-mapper.sh" + + - name: Decide whether to review if: steps.check-secrets.outputs.skip != 'true' + id: check-paths + env: + # The doc-check label and a manual dispatch always force a review, so + # any skip below stays overridable from the pull request. + FORCED: ${{ github.event_name == 'workflow_dispatch' || github.event.label.name == 'doc-check' }} + ALL_COUNT: ${{ steps.filter.outputs.all_count }} + NODOCS_COUNT: ${{ steps.filter.outputs.nodocs_count }} + CI_DOCS_COUNT: ${{ steps.filter.outputs.ci_docs_count }} + run: | + set -euo pipefail + + if [[ "${FORCED}" == "true" ]]; then + echo "skip=false" >> "${GITHUB_OUTPUT}" + echo "Review forced by label or manual dispatch; path classes ignored." + exit 0 + fi + + # Comparing against all_count is what makes this "every changed file". + # A pull request that mixes a test file with a CLI flag still gets a + # full review, because the counts differ. + if [[ -n "${ALL_COUNT}" && "${ALL_COUNT}" != "0" && + "${NODOCS_COUNT}" == "${ALL_COUNT}" && "${CI_DOCS_COUNT}" == "0" ]]; then + echo "skip=true" >> "${GITHUB_OUTPUT}" + echo "All ${ALL_COUNT} changed file(s) are in path classes with no documentation surface." + { + echo "### Documentation check skipped" + echo "" + echo "All ${ALL_COUNT} changed file(s) are in path classes with no documentation surface, so no review ran." + echo "" + echo "Add the \`doc-check\` label to review anyway." + } >> "${GITHUB_STEP_SUMMARY}" + else + echo "skip=false" >> "${GITHUB_OUTPUT}" + fi + + - name: Determine PR Context + if: steps.check-secrets.outputs.skip != 'true' && steps.check-paths.outputs.skip != 'true' id: determine-context env: GITHUB_EVENT_NAME: ${{ github.event_name }} @@ -132,7 +239,7 @@ jobs: fi - name: Check the review workspace is usable - if: steps.check-secrets.outputs.skip != 'true' + if: steps.check-secrets.outputs.skip != 'true' && steps.check-paths.outputs.skip != 'true' id: check-workspace env: CODER_URL: ${{ secrets.DOC_CHECK_CODER_URL }} @@ -172,7 +279,7 @@ jobs: echo "Workspace state is usable." - name: Build chat prompt - if: steps.check-secrets.outputs.skip != 'true' + if: steps.check-secrets.outputs.skip != 'true' && steps.check-paths.outputs.skip != 'true' id: extract-context env: PR_NUMBER: ${{ steps.determine-context.outputs.pr_number }} @@ -240,7 +347,7 @@ jobs: } >> "${GITHUB_OUTPUT}" - name: Run doc-check via Coder Agent Chat - if: steps.check-secrets.outputs.skip != 'true' + if: steps.check-secrets.outputs.skip != 'true' && steps.check-paths.outputs.skip != 'true' uses: coder/agents-chat-action@3e20636f47ed88d1486b767ade8cb1e13a1effa7 # v0.5.0 with: coder-url: ${{ secrets.DOC_CHECK_CODER_URL }}