Skip to content

feat(docs): CI gate to keep llm-guide.md in sync with token registry - #383

Merged
jackgranatowski merged 2 commits into
mainfrom
claude/tender-rubin-q7jjo5
Jun 23, 2026
Merged

feat(docs): CI gate to keep llm-guide.md in sync with token registry#383
jackgranatowski merged 2 commits into
mainfrom
claude/tender-rubin-q7jjo5

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds scripts/check-llm-guide.js — a two-tier validation script:
    • Hard fail: any --sf-* name in docs/llm-guide.md that isn't a live token in token-registry.json (catches renames and deletions — stale guide references break CI immediately)
    • Warning only: PUBLIC/PUBLIC-ADVANCED knob tokens absent from the guide (surfaces coverage gaps without blocking merges — the guide is intentionally curated)
  • Wires the script into the artifacts-freshness CI job and npm run check:llm-guide
  • Fixes 5 stale token refs caught by the new gate: --sf-color-code-block-{bg,text}, --sf-field-{border-color,text-color}, --sf-section-pad-xl-plus
  • Adds a mandatory LLM guide sync section to CLAUDE.md documenting which changes require a guide update and how to verify locally

Test plan

  • npm run check:llm-guide passes locally with exit 0
  • CI Verify all generated artifacts job passes
  • Renaming a token in a CSS source and running the check produces a hard failure naming the stale ref

🤖 Generated with Claude Code

https://claude.ai/code/session_01GBbqrooCfW68LAjUMuNnYY


Generated by Claude Code


Summary by cubic

Adds a CI gate to keep docs/llm-guide.md in sync with the live token set, now defined as token-registry.json plus any --sf-* declarations in core/ and optional/ CSS. Blocks stale refs and warns on missing PUBLIC knobs; restores scoped override tokens in the guide.

  • New Features

    • scripts/check-llm-guide.js: hard-fails token names not found in the union of the registry and CSS-declared tokens; warns on undocumented PUBLIC/PUBLIC-ADVANCED knob tokens.
    • CI: wired into artifacts-freshness; added npm script check:llm-guide.
  • Migration

    • When changing tokens or CSS, review and update docs/llm-guide.md (see “LLM guide sync” in CLAUDE.md).
    • Run npm run check:llm-guide locally; CI fails on stale refs.

Written for commit a3dd3e4. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation

    • Updated API reference guide with clarified token definitions and practical usage examples.
  • Chores

    • Added automated CI verification to ensure documentation stays consistent with the latest API tokens.

Adds scripts/check-llm-guide.js with two checks:
- Hard fail: any --sf-* name in the guide that is not a live token in
  token-registry.json (catches renames/deletions immediately).
- Warning: PUBLIC/PUBLIC-ADVANCED knob tokens absent from the guide
  (surfaces coverage gaps without blocking CI).

Wires the script into the artifacts-freshness CI job and npm run
check:llm-guide. Fixes five stale token references caught by the new
gate (--sf-color-code-block-{bg,text}, --sf-field-{border,text}-color,
--sf-section-pad-xl-plus). Adds a mandatory "LLM guide sync" section
to CLAUDE.md documenting the qualitative update obligation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBbqrooCfW68LAjUMuNnYY
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds scripts/check-llm-guide.js, a Node.js CI script that validates docs/llm-guide.md token references against token-registry.json and docs/api-index.json, hard-failing on stale references and warning on undocumented public knobs. The script is wired as an npm script, added to the artifacts-freshness CI job, and documented in CLAUDE.md. Five stale token references in docs/llm-guide.md are also corrected.

Changes

LLM Guide Token Freshness Check

Layer / File(s) Summary
check-llm-guide.js validation script
scripts/check-llm-guide.js
New script reads docs/llm-guide.md, token-registry.json, and docs/api-index.json; builds a live token set (excluding removed entries); extracts --sf-* references from the guide via regex; exits with code 1 on stale references; and prints warnings for undocumented PUBLIC/PUBLIC-ADVANCED knob tokens.
npm script, CI step, and CLAUDE.md docs
package.json, .github/workflows/ci.yml, CLAUDE.md
package.json adds the check:llm-guide script entry. ci.yml inserts a node scripts/check-llm-guide.js step in the artifacts-freshness job. CLAUDE.md adds the command to the Key scripts list and introduces a mandatory LLM guide sync section.
Stale token reference corrections in docs/llm-guide.md
docs/llm-guide.md
Five targeted edits remove or correct token references that the new script would flag: auto-contrast wildcard narrowed to --sf-color-text--on-{family}, code-block override tokens removed, heading alias pattern made explicit, form field scoped overrides removed, and best-practices wrong example changed to a non---sf- token.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • codeslash-dev/SLASHED#70: Adds the --sf-field-required-marker token declaration in core/tokens.css, which is directly related to the form field token corrections made in docs/llm-guide.md in this PR.
  • codeslash-dev/SLASHED#211: Also modifies the artifacts-freshness CI job in .github/workflows/ci.yml by adding a Node-based freshness verification step (scripts/check-artifacts.js), the same pattern used here.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(docs): CI gate to keep llm-guide.md in sync with token registry' directly and specifically describes the main change: adding a CI gate to validate the llm-guide.md against the token registry. It accurately captures the core objective of the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/tender-rubin-q7jjo5

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee0fd8c3b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +45 to +46
const liveTokens = new Set(
registry.tokens.filter((t) => !t.removed).map((t) => t.name),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include live scoped tokens outside the registry

Using token-registry.json as the sole source of live tokens makes the new gate reject supported scoped override hooks that are not catalogued there. For example, core/tokens.css lists --sf-color-code-block-bg, --sf-color-code-block-text, --sf-field-border-color, and --sf-field-text-color as PUBLIC scoped override tokens, and core/base.css/optional/forms.css still consume them, but they are absent from the registry; this already forced their removal from the LLM guide and will block re-documenting those supported APIs. The live set needs to include these non-registered public hooks or the registry generator needs to catalogue them before this hard-fail check runs.

Useful? React with 👍 / 👎.

Comment on lines +60 to +64
const TOKEN_RE = /--sf-[a-z0-9_-]+/g;
const guideRefs = new Set(
[...guideText.matchAll(TOKEN_RE)]
.map((m) => m[0])
.filter((name) => !name.endsWith('-')),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expand shorthand token references before validation

The extractor only records the first fully prefixed token, so existing guide shorthand such as --sf-animation-fade-in / -fade-out, --sf-grid-min-xs / -s / -m, and --sf-safe-top / -bottom leaves the suffixed tokens out of both the stale-token check and the coverage calculation. If one of those documented shorthand tokens is renamed or removed, CI still passes because the reference is never validated, while the warning list also incorrectly reports several documented knobs as missing.

Useful? React with 👍 / 👎.

The stale check incorrectly excluded --sf-field-border-color,
--sf-field-text-color, --sf-color-code-block-bg, and
--sf-color-code-block-text — these are real PUBLIC scoped override hooks
declared and consumed in core/states.css, optional/forms.css, and
core/base.css, but absent from token-registry.json (the registry only
covers catalogued tokens, not all framework-level properties).

Fix: extend the live token set to also include any --sf-* custom property
that appears as a declaration in core/ or optional/ CSS files. This
ensures scoped override hooks that haven't yet been added to the registry
don't trigger false stale failures.

Also re-adds the four scoped override tokens to docs/llm-guide.md with
accurate descriptions of their scoping purpose.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBbqrooCfW68LAjUMuNnYY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants