Skip to content

Claude Code guide in three levels, Beginner to Advanced: hands-on lessons with checked exercises, every volatile fact cited to its source. Independent community guide.

ci: add scheduled link, expiry and drift checks, a glob-based audit and a traffic snapshot (#54)

Wesam Abousaid25979488dfa8
diff --git a/.claude/workflows/stale-docs-audit.js b/.claude/workflows/stale-docs-audit.js
index d1890c9..c5a686c 100644
--- a/.claude/workflows/stale-docs-audit.js
+++ b/.claude/workflows/stale-docs-audit.js
@@ -1,32 +1,31 @@
-// Run with: /stale-docs-audit (audits this repo's default doc set)
+// Run with: /stale-docs-audit (audits README.md, docs/ and the example READMEs)
// /stale-docs-audit on README.md docs/skills.md
+// /stale-docs-audit with args { "dryRun": true } (lists the pages and stops)
//
-// Shape: fan one reader agent per file, then have independent skeptics try to
-// REFUTE each claim before it's reported. The refute-by-default framing is what
-// keeps plausible-but-wrong findings out of the result.
+// Shape: one agent lists the pages, one reader agent per page extracts the
+// claims that can go stale, then independent verifiers check each claim
+// against its authoritative source and sort it as stale, unverifiable or ok.
+// An unverifiable claim is a defect too: cite it or cut it. The result is the
+// body of one tracking issue for the maintainer; nothing edits a page.
export const meta = {
name: 'stale-docs-audit',
- description: "Find version- or date-pinned claims in this repo's docs that no longer match official Claude Code documentation",
+ description: "Sort the volatile claims in this repo's docs as stale, unverifiable or ok against official sources, and draft one tracking issue",
phases: [
- { title: 'Scan', detail: 'one agent per file extracts pinned claims' },
- { title: 'Verify', detail: 'independent skeptics try to refute each claim' },
+ { title: 'Discover', detail: 'list README.md, every docs page and every example README' },
+ { title: 'Scan', detail: 'one agent per page extracts volatile claims' },
+ { title: 'Verify', detail: 'independent verifiers sort each claim' },
],
}
-const DEFAULT_TARGETS = [
- 'README.md',
- 'docs/workflows.md',
- 'docs/agent-teams.md',
- 'docs/skills.md',
- 'docs/reference/changelog.md',
- 'docs/reference/commands.md',
- 'docs/reference/effort-levels.md',
- 'docs/reference/models.md',
- 'docs/reference/faq.md',
-]
+const LIST_PAGES = "git ls-files -- README.md ':(glob)docs/**/*.md' ':(glob)examples/**/README.md'"
+const options = Array.isArray(args) ? { targets: args } : (args ?? {})
-const targets = Array.isArray(args) && args.length ? args : DEFAULT_TARGETS
+const PAGES_SCHEMA = {
+ type: 'object',
+ required: ['paths'],
+ properties: { paths: { type: 'array', items: { type: 'string' } } },
+}
const CLAIMS_SCHEMA = {
type: 'object',
@@ -38,7 +37,7 @@ const CLAIMS_SCHEMA = {
type: 'object',
required: ['claim', 'line'],
properties: {
- claim: { type: 'string', description: 'The pinned claim, quoted from the file' },
+ claim: { type: 'string', description: 'The claim, quoted from the page' },
line: { type: 'integer', description: '1-indexed line the claim appears on' },
},
},
@@ -48,41 +47,78 @@ const CLAIMS_SCHEMA = {
const VERDICT_SCHEMA = {
type: 'object',
- required: ['stale', 'reason'],
+ required: ['verdict', 'reason'],
properties: {
- stale: { type: 'boolean', description: 'True only if the claim is provably wrong today' },
- reason: { type: 'string', description: 'What the current official docs say instead' },
- source: { type: 'string', description: 'URL that settles it' },
- correction: { type: 'string', description: 'Suggested replacement text' },
+ verdict: {
+ type: 'string',
+ enum: ['stale', 'unverifiable', 'ok'],
+ description: 'stale: an authoritative source shows it is wrong today. ok: an authoritative source confirms it. unverifiable: neither.',
+ },
+ reason: { type: 'string', description: 'What the source says, or what you checked and could not find' },
+ source: { type: 'string', description: 'URL that settles it, or the closest page you checked' },
+ correction: { type: 'string', description: 'Suggested replacement text, for a stale claim' },
},
}
-phase('Scan')
-log(`Auditing ${targets.length} file(s).`)
+phase('Discover')
+let pages = options.targets
+if (!pages?.length) {
+ const listed = await agent(
+ `In this repository, run exactly this command and return every path it prints, unchanged:\n\n${LIST_PAGES}`,
+ { label: 'list pages', phase: 'Discover', schema: PAGES_SCHEMA },
+ )
+ pages = listed?.paths ?? []
+}
+log(`Auditing ${pages.length} page(s).`)
+const bucket = (title, items, line) =>
+ `### ${title}\n\n${items.length ? items.map(line).join('\n') : 'None.'}\n`
+
+if (options.dryRun) {
+ return {
+ pages,
+ issueBody: [
+ '## Stale-docs audit (dry run)',
+ '',
+ `Would audit ${pages.length} page(s):`,
+ '',
+ ...pages.map(p => `- \`${p}\``),
+ '',
+ bucket('Stale', [], () => ''),
+ bucket('Unverifiable', [], () => ''),
+ bucket('Ok', [], () => ''),
+ ].join('\n'),
+ }
+}
+
+phase('Scan')
const results = await pipeline(
- targets,
+ pages,
- // Stage 1 — extract only claims that CAN go stale. Prose and opinion are noise here.
+ // Stage 1: extract only the claims that can go stale. Prose and opinion are noise here.
(_, file) => agent(
- `Read ${file} in this repository. Extract every factual claim pinned to a version, ` +
- `date, price, numeric limit, command name, file path, or setting key — the kinds of ` +
- `claim that can silently go stale. Skip prose, opinion, mental models, and advice. ` +
- `Quote each claim verbatim and give its 1-indexed line number.`,
+ `Read ${file} in this repository. Extract every volatile claim: a version or date; a price, ` +
+ `plan availability, or usage or rate limit; a model name, model ID or default; the name or ` +
+ `behavior of a command, flag, setting, environment variable, hook event, tool or frontmatter ` +
+ `field; a stability label; any count or statistic; or a third-party status fact (owner, ` +
+ `license, archived). Skip mental models, analogies and advice. Quote each claim verbatim and ` +
+ `give its 1-indexed line number.`,
{ label: file, phase: 'Scan', schema: CLAIMS_SCHEMA },
),
- // Stage 2 — verify each claim from this file as soon as the file is scanned.
- // No barrier: file B is still scanning while file A's claims are being checked.
+ // Stage 2: verify each claim from this page as soon as the page is scanned.
+ // No barrier: page B is still scanning while page A's claims are being checked.
(scan, file) => parallel(
(scan?.claims ?? []).map(c => () =>
agent(
- `Try to REFUTE this documentation claim from ${file}:\n\n"${c.claim}"\n\n` +
- `Check it against current official sources (code.claude.com/docs, ` +
- `platform.claude.com/docs, anthropic.com/news, the anthropics/claude-code CHANGELOG). ` +
- `Set stale:true ONLY if you can show it is wrong today and cite the source that ` +
- `settles it. If you cannot verify it either way, set stale:false — an unverified ` +
- `claim is not a stale claim, and a false report costs more than a missed one.`,
+ `Check this claim from ${file}:\n\n"${c.claim}"\n\n` +
+ `Use the authoritative source for its domain: code.claude.com/docs for Claude Code behavior; ` +
+ `the anthropics/claude-code CHANGELOG and the npm dist-tags of @anthropic-ai/claude-code for ` +
+ `versions; platform.claude.com/docs for models; claude.com/pricing and support.claude.com plan ` +
+ `articles for plans; modelcontextprotocol.io for MCP; docs.github.com for GitHub; a tool's own ` +
+ `docs for that tool. Answer stale only if the source shows the claim is wrong today, and ok ` +
+ `only if the source confirms it. Otherwise answer unverifiable and say what you checked: the ` +
+ `guide cites or cuts claims nobody can verify.`,
{ label: `${file}:${c.line}`, phase: 'Verify', schema: VERDICT_SCHEMA },
).then(v => ({ file, line: c.line, claim: c.claim, ...v })),
),
@@ -90,12 +126,30 @@ const results = await pipeline(
)
const checked = results.flat().filter(Boolean)
-const stale = checked.filter(r => r.stale)
+const byPlace = (a, b) => a.file.localeCompare(b.file) || a.line - b.line
+const sorted = verdict => checked.filter(r => r.verdict === verdict).sort(byPlace)
+const stale = sorted('stale')
+const unverifiable = sorted('unverifiable')
+const ok = sorted('ok')
+
+log(`${checked.length} claim(s) checked: ${stale.length} stale, ${unverifiable.length} unverifiable, ${ok.length} ok.`)
-log(`${checked.length} claim(s) verified · ${stale.length} confirmed stale.`)
+const where = r => `\`${r.file}:${r.line}\``
+const issueBody = [
+ '## Stale-docs audit',
+ '',
+ `Audited ${pages.length} page(s) and ${checked.length} claim(s): ${stale.length} stale, ${unverifiable.length} unverifiable, ${ok.length} ok.`,
+ '',
+ bucket('Stale', stale, r => `- ${where(r)}: "${r.claim}". ${r.reason}${r.source ? ` Source: ${r.source}` : ''}${r.correction ? ` Suggested: ${r.correction}` : ''}`),
+ bucket('Unverifiable', unverifiable, r => `- ${where(r)}: "${r.claim}". ${r.reason}${r.source ? ` Checked: ${r.source}` : ''}`),
+ '### Ok',
+ '',
+ ok.length ? `<details><summary>${ok.length} claim(s) confirmed</summary>\n\n${ok.map(r => `- ${where(r)}: ${r.source ?? ''}`).join('\n')}\n\n</details>\n` : 'None.\n',
+].join('\n')
return {
- filesAudited: targets.length,
- claimsVerified: checked.length,
- stale: stale.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line),
+ pagesAudited: pages.length,
+ claimsChecked: checked.length,
+ counts: { stale: stale.length, unverifiable: unverifiable.length, ok: ok.length },
+ issueBody,
}
diff --git a/.github/scripts/fixtures/broken-external-link/fixture.json b/.github/scripts/fixtures/broken-external-link/fixture.json
new file mode 100644
index 0000000..475b282
--- /dev/null
+++ b/.github/scripts/fixtures/broken-external-link/fixture.json
@@ -0,0 +1,6 @@
+{
+ "rule": "external-links",
+ "expect": "fail",
+ "mode": "scheduled",
+ "about": "A link whose server refuses the connection (a closed local port, so the result never depends on the network), so the weekly external run reports it."
+}
diff --git a/.github/scripts/fixtures/broken-external-link/tree/README.md b/.github/scripts/fixtures/broken-external-link/tree/README.md
new file mode 100644
index 0000000..4eb9165
--- /dev/null
+++ b/.github/scripts/fixtures/broken-external-link/tree/README.md
@@ -0,0 +1,3 @@
+# Fixture
+
+See [the vendor docs](http://127.0.0.1:9/setup).
diff --git a/.github/scripts/fixtures/stable-release-after-baseline/fixture.json b/.github/scripts/fixtures/stable-release-after-baseline/fixture.json
new file mode 100644
index 0000000..c51eb57
--- /dev/null
+++ b/.github/scripts/fixtures/stable-release-after-baseline/fixture.json
@@ -0,0 +1,7 @@
+{
+ "rule": "drift",
+ "expect": "fail",
+ "mode": "scheduled",
+ "env": { "CHECKS_STABLE_VERSION": "2.1.290" },
+ "about": "npm's stable dist-tag has moved past the frozen baseline, so the weekly drift check reports it."
+}
diff --git a/.github/scripts/fixtures/stable-release-after-baseline/tree/CHANGELOG.md b/.github/scripts/fixtures/stable-release-after-baseline/tree/CHANGELOG.md
new file mode 100644
index 0000000..c4349f6
--- /dev/null
+++ b/.github/scripts/fixtures/stable-release-after-baseline/tree/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Changelog
+
+## Unreleased
+
+Baseline: Claude Code v2.1.285 (stable), frozen on 2026-10-05.
diff --git a/.github/scripts/fixtures/stable-release-matches-baseline/fixture.json b/.github/scripts/fixtures/stable-release-matches-baseline/fixture.json
new file mode 100644
index 0000000..e6b9a99
--- /dev/null
+++ b/.github/scripts/fixtures/stable-release-matches-baseline/fixture.json
@@ -0,0 +1,7 @@
+{
+ "rule": "drift",
+ "expect": "pass",
+ "mode": "scheduled",
+ "env": { "CHECKS_STABLE_VERSION": "2.1.285" },
+ "about": "npm's stable dist-tag still equals the frozen baseline."
+}
diff --git a/.github/scripts/fixtures/stable-release-matches-baseline/tree/CHANGELOG.md b/.github/scripts/fixtures/stable-release-matches-baseline/tree/CHANGELOG.md
new file mode 100644
index 0000000..c4349f6
--- /dev/null
+++ b/.github/scripts/fixtures/stable-release-matches-baseline/tree/CHANGELOG.md
@@ -0,0 +1,5 @@
+# Changelog
+
+## Unreleased
+
+Baseline: Claude Code v2.1.285 (stable), frozen on 2026-10-05.
diff --git a/.github/scripts/rules/drift.mjs b/.github/scripts/rules/drift.mjs
new file mode 100644
index 0000000..b8a86b9
--- /dev/null
+++ b/.github/scripts/rules/drift.mjs
@@ -0,0 +1,53 @@
+// Flags a new `stable` Claude Code release after the frozen baseline in the
+// CHANGELOG's Unreleased entry, so the owner can check it for removals,
+// renames or default changes to what the lessons teach. Weekly and scheduled
+// only. CHECKS_STABLE_VERSION overrides the npm lookup.
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+import { readText } from '../lib/tree.mjs';
+import { compareVersions } from '../lib/stamps.mjs';
+
+export const id = 'drift';
+export const modes = ['scheduled'];
+
+const DIST_TAGS = 'https://registry.npmjs.org/-/package/@anthropic-ai/claude-code/dist-tags';
+const CHANGELOG_RAW = 'https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md';
+const CHANGELOG_PAGE = 'https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md';
+
+async function stableVersion() {
+ if (process.env.CHECKS_STABLE_VERSION) return process.env.CHECKS_STABLE_VERSION;
+ const res = await fetch(DIST_TAGS, { signal: AbortSignal.timeout(20_000) });
+ if (!res.ok) throw new Error(`npm dist-tags returned ${res.status}`);
+ return (await res.json()).stable;
+}
+
+// The official CHANGELOG's version headings between two versions, newest first.
+async function releasesBetween(from, to) {
+ if (process.env.CHECKS_STABLE_VERSION) return [];
+ try {
+ const res = await fetch(CHANGELOG_RAW, { signal: AbortSignal.timeout(20_000) });
+ if (!res.ok) return [];
+ return [...(await res.text()).matchAll(/^## (\d+\.\d+\.\d+)\b/gm)]
+ .map((m) => m[1])
+ .filter((v) => compareVersions(v, from) > 0 && compareVersions(v, to) <= 0);
+ } catch {
+ return [];
+ }
+}
+
+export async function run(ctx) {
+ const changelog = existsSync(join(ctx.root, 'CHANGELOG.md')) ? readText(ctx.root, 'CHANGELOG.md') : '';
+ const m = changelog.match(/^Baseline: Claude Code v(\d+\.\d+\.\d+) \(stable\)/m);
+ if (!m) return { status: 'fail', problems: ['CHANGELOG.md has no "Baseline: Claude Code vX.Y.Z (stable)" line'] };
+ const baseline = m[1];
+ const stable = await stableVersion();
+ if (compareVersions(stable, baseline) <= 0) return { status: 'pass', summary: `stable is v${stable}; baseline v${baseline}` };
+ const releases = await releasesBetween(baseline, stable);
+ return {
+ status: 'fail',
+ problems: [
+ `stable is now v${stable}; the baseline is v${baseline}`,
+ `Read the Claude Code CHANGELOG (${CHANGELOG_PAGE}) from v${baseline} to v${stable}${releases.length ? ` (${releases.join(', ')})` : ''} for anything that removes, renames or changes the default of something a lesson teaches. Only those changes are pulled in early, each as its own pull request.`,
+ ],
+ };
+}
diff --git a/.github/scripts/rules/external-links.mjs b/.github/scripts/rules/external-links.mjs
new file mode 100644
index 0000000..0c0dfab
--- /dev/null
+++ b/.github/scripts/rules/external-links.mjs
@@ -0,0 +1,11 @@
+// Links to other sites still resolve. Weekly and scheduled only: other sites
+// throttle and flake, so this opens an issue instead of blocking a pull
+// request. A 429 (rate limited) counts as alive.
+import { lychee } from './internal-links.mjs';
+
+export const id = 'external-links';
+export const modes = ['scheduled'];
+
+export function run(ctx) {
+ return lychee(ctx, ['--accept', '100..=103,200..=299,429', '--max-concurrency', '8', '--max-retries', '2']);
+}
diff --git a/.github/scripts/rules/index.mjs b/.github/scripts/rules/index.mjs
index 38087ef..5d5c464 100644
--- a/.github/scripts/rules/index.mjs
+++ b/.github/scripts/rules/index.mjs
@@ -11,5 +11,7 @@ import * as lessonLint from './lesson-lint.mjs';
import * as staticValidation from './static-validation.mjs';
import * as inertness from './inertness.mjs';
import * as smokeTests from './smoke-tests.mjs';
+import * as externalLinks from './external-links.mjs';
+import * as drift from './drift.mjs';
-export const rules = [internalLinks, anchorDiff, stubPaths, stamps, editionGate, expiry, emDash, images, lessonLint, staticValidation, inertness, smokeTests];
+export const rules = [internalLinks, anchorDiff, stubPaths, stamps, editionGate, expiry, emDash, images, lessonLint, staticValidation, inertness, smokeTests, externalLinks, drift];
diff --git a/.github/scripts/rules/internal-links.mjs b/.github/scripts/rules/internal-links.mjs
index c1bbb23..129215e 100644
--- a/.github/scripts/rules/internal-links.mjs
+++ b/.github/scripts/rules/internal-links.mjs
@@ -7,12 +7,16 @@ export const id = 'internal-links';
export const modes = ['pr', 'release'];
export function run(ctx) {
+ return lychee(ctx, ['--offline', '--include-fragments']);
+}
+
+// Runs lychee over every Markdown page in the tree with the given options.
+export function lychee(ctx, options) {
const pages = ctx.files.filter((f) => f.endsWith('.md'));
if (pages.length === 0) return { status: 'pass', summary: 'no Markdown files' };
- const lychee = process.env.LYCHEE || 'lychee';
const result = spawnSync(
- lychee,
- ['--no-progress', '--offline', '--include-fragments', '--format', 'json', '--root-dir', ctx.root, ...pages],
+ process.env.LYCHEE || 'lychee',
+ ['--no-progress', ...options, '--format', 'json', '--root-dir', ctx.root, ...pages],
{ cwd: ctx.root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
);
if (result.error?.code === 'ENOENT') {
diff --git a/.github/scripts/test/checks.test.mjs b/.github/scripts/test/checks.test.mjs
index b2159fe..71bfc1c 100644
--- a/.github/scripts/test/checks.test.mjs
+++ b/.github/scripts/test/checks.test.mjs
@@ -23,6 +23,7 @@ for (const name of readdirSync(fixturesDir).sort()) {
base: tree.base,
tag: spec.tag,
today: spec.today,
+ env: spec.env,
});
if (spec.expect === 'fail') {
assert.notEqual(code, 0, output);
diff --git a/.github/scripts/test/harness.mjs b/.github/scripts/test/harness.mjs
index 9051780..78fa175 100644
--- a/.github/scripts/test/harness.mjs
+++ b/.github/scripts/test/harness.mjs
@@ -61,12 +61,12 @@ export async function materialize(fixtureDir, spec) {
// `today` pins the date that date-based rules compare against, so fixtures
// keep their verdict as time passes.
-export function runChecks(root, { only, mode = 'pr', base, tag, today } = {}) {
+export function runChecks(root, { only, mode = 'pr', base, tag, today, env: extra } = {}) {
const args = [checkScript, '--root', root, '--mode', mode];
if (only) args.push('--only', only);
if (base) args.push('--base', base);
if (tag) args.push('--tag', tag);
- const env = { ...process.env };
+ const env = { ...process.env, ...extra };
if (today) env.CHECKS_TODAY = today;
const result = spawnSync(process.execPath, args, { encoding: 'utf8', env });
return { code: result.status, output: `${result.stdout}${result.stderr}` };
diff --git a/.github/scripts/test/traffic-snapshot.test.mjs b/.github/scripts/test/traffic-snapshot.test.mjs
new file mode 100644
index 0000000..128ed88
--- /dev/null
+++ b/.github/scripts/test/traffic-snapshot.test.mjs
@@ -0,0 +1,71 @@
+// The owner-run traffic snapshot, run against a stand-in for the gh CLI that
+// returns canned API responses.
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, dirname } from 'node:path';
+import { spawnSync } from 'node:child_process';
+import { fileURLToPath } from 'node:url';
+
+const script = join(dirname(fileURLToPath(import.meta.url)), '..', 'traffic-snapshot.sh');
+const repo = 'owner/guide';
+
+const responses = {
+ [`api repos/${repo}/traffic/popular/paths`]: [
+ { path: `/${repo}`, title: 'guide', count: 2400, uniques: 800 },
+ { path: `/${repo}/tree/main/docs/beginner`, title: 'beginner', count: 150, uniques: 60 },
+ { path: `/${repo}/blob/main/docs/beginner/README.md`, title: 'README', count: 50, uniques: 20 },
+ { path: `/${repo}/blob/main/CONTRIBUTING.md`, title: 'CONTRIBUTING', count: 30, uniques: 10 },
+ ],
+ [`api repos/${repo}/traffic/popular/referrers`]: [
+ { referrer: 'Google', count: 500, uniques: 300 },
+ { referrer: 'github.com', count: 200, uniques: 120 },
+ { referrer: 'Bing', count: 20, uniques: 9 },
+ ],
+ [`api repos/${repo}`]: { stargazers_count: 2345 },
+};
+
+function fakeGh(dir) {
+ const table = JSON.stringify(responses);
+ const body = `#!/usr/bin/env node
+const args = process.argv.slice(2).filter((a) => !a.startsWith('-H') && !a.startsWith('Accept:') && a !== '--paginate');
+const key = args.join(' ');
+const table = ${table};
+if (key.startsWith('api repos/${repo}/stargazers')) {
+ const now = Date.now();
+ const day = 86400000;
+ process.stdout.write(JSON.stringify([{ starred_at: new Date(now - 2 * day).toISOString() }, { starred_at: new Date(now - 10 * day).toISOString() }]));
+ process.stdout.write(JSON.stringify([{ starred_at: new Date(now - 90 * day).toISOString() }]));
+} else if (key.startsWith('issue list')) {
+ process.stdout.write(JSON.stringify([{ number: 7 }, { number: 9 }]));
+} else if (key in table) {
+ process.stdout.write(JSON.stringify(table[key]));
+} else {
+ process.stderr.write('unexpected gh call: ' + key + '\\n');
+ process.exit(1);
+}
+`;
+ writeFileSync(join(dir, 'gh'), body);
+ chmodSync(join(dir, 'gh'), 0o755);
+}
+
+test('the traffic snapshot records a level path missing from the top 10 as below the 10th', () => {
+ const dir = mkdtempSync(join(tmpdir(), 'fake-gh-'));
+ try {
+ fakeGh(dir);
+ const result = spawnSync('bash', [script, repo], { encoding: 'utf8', env: { ...process.env, PATH: `${dir}:${process.env.PATH}` } });
+ assert.equal(result.status, 0, result.stderr);
+ const out = result.stdout;
+ assert.match(out, /Repo root: 800 unique visitors/);
+ assert.match(out, /Beginner: 80 unique visitors \(10% of the root\)/);
+ assert.match(out, /Intermediate: below the 10th/);
+ assert.match(out, /Advanced: below the 10th/);
+ assert.doesNotMatch(out, /Intermediate: 0\b/);
+ assert.match(out, /Stars: 2345 total, \+2 in the last 30 days/);
+ assert.match(out, /Search referrers: Google \(300 unique\), Bing \(9 unique\)/);
+ assert.match(out, /Lesson-feedback issues opened in the last 14 days: 2/);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/.github/scripts/tracking-issue.sh b/.github/scripts/tracking-issue.sh
new file mode 100755
index 0000000..7f76704
--- /dev/null
+++ b/.github/scripts/tracking-issue.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# Opens the tracking issue with this exact title, or updates the open one, so
+# a scheduled check never piles up duplicates and never opens a pull request.
+#
+# tracking-issue.sh "<title>" <check-output-file>
+#
+# Needs gh and jq, with GH_TOKEN allowed to write issues. RUN_URL, when set,
+# links the run that found the problem.
+set -euo pipefail
+
+title=$1
+output=$2
+body=$(mktemp)
+{
+ echo "A scheduled check found problems${RUN_URL:+ in [this run]($RUN_URL)}. The issue is updated in place while it stays open."
+ echo
+ echo '```text'
+ cat "$output"
+ echo '```'
+} > "$body"
+
+number=$(gh issue list --state open --limit 200 --json number,title \
+ | jq -r --arg t "$title" '[.[] | select(.title == $t) | .number] | first // empty')
+if [ -n "$number" ]; then
+ gh issue edit "$number" --body-file "$body"
+ gh issue comment "$number" --body "Still failing${RUN_URL:+ in [this run]($RUN_URL)}."
+else
+ gh issue create --title "$title" --body-file "$body"
+fi
diff --git a/.github/scripts/traffic-snapshot.sh b/.github/scripts/traffic-snapshot.sh
new file mode 100755
index 0000000..711218f
--- /dev/null
+++ b/.github/scripts/traffic-snapshot.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+# Prints a snapshot of how visitors reach the guide, for the maintainer to
+# keep every two weeks:
+# - root-to-level click-through, from the repo page to each level's pages;
+# - the star total and the stars added in the last 30 days;
+# - search engines among the top referrers;
+# - lesson-feedback issues opened in the last 14 days.
+#
+# .github/scripts/traffic-snapshot.sh [owner/repo] >> snapshots.md
+#
+# Run it yourself, signed in to gh with push access: the traffic API needs a
+# permission the Actions token cannot get. GitHub reports only the top 10
+# paths and referrers over 14 days, so a level outside them is recorded as
+# "below the 10th", not as zero. Needs gh and jq.
+set -euo pipefail
+
+repo=${1:-wesammustafa/Claude-Code-Everything-You-Need-to-Know}
+today=$(jq -nr 'now | strftime("%Y-%m-%d")')
+since30=$(jq -nr '(now - 30 * 86400) | strftime("%Y-%m-%dT%H:%M:%SZ")')
+since14=$(jq -nr '(now - 14 * 86400) | strftime("%Y-%m-%d")')
+
+paths=$(gh api "repos/$repo/traffic/popular/paths")
+referrers=$(gh api "repos/$repo/traffic/popular/referrers")
+stars=$(gh api "repos/$repo" | jq '.stargazers_count')
+recent_stars=$(gh api -H 'Accept: application/vnd.github.star+json' --paginate "repos/$repo/stargazers?per_page=100" \
+ | jq -s --arg since "$since30" '[add[] | select(.starred_at >= $since)] | length')
+feedback=$(gh issue list --repo "$repo" --label lesson-feedback --state all --search "created:>=$since14" --limit 1000 --json number \
+ | jq 'length')
+
+# Unique visitors to the repo root, and to a level's folder and index page.
+root_uniques=$(jq --arg p "/$repo" '[.[] | select((.path | ascii_downcase) == ($p | ascii_downcase)) | .uniques] | add // 0' <<<"$paths")
+level() {
+ jq -r --arg base "/$repo" --arg level "$1" --argjson root "$root_uniques" '
+ [.[] | select((.path | ascii_downcase) as $p
+ | ($p == (($base + "/tree/main/docs/" + $level) | ascii_downcase))
+ or ($p == (($base + "/blob/main/docs/" + $level + "/README.md") | ascii_downcase)))
+ | .uniques]
+ | if length == 0 then "below the 10th"
+ else (add) as $u
+ | "\($u) unique visitors" + (if $root > 0 then " (\(($u * 1000 / $root | round) / 10)% of the root)" else "" end)
+ end' <<<"$paths"
+}
+
+search=$(jq -r '[.[] | select(.referrer | test("google|bing|duckduckgo|yahoo|baidu|yandex|ecosia|brave|kagi"; "i"))
+ | "\(.referrer) (\(.uniques) unique)"] | if length == 0 then "none in the top 10" else join(", ") end' <<<"$referrers")
+
+cat <<REPORT
+## Traffic snapshot, $today ($repo)
+
+Unique visitors over the last 14 days. GitHub reports the top 10 paths and referrers only.
+
+- Repo root: $root_uniques unique visitors
+- Beginner: $(level beginner)
+- Intermediate: $(level intermediate)
+- Advanced: $(level advanced)
+- Stars: $stars total, +$recent_stars in the last 30 days
+- Search referrers: $search
+- Lesson-feedback issues opened in the last 14 days: $feedback
+REPORT
diff --git a/.github/workflows/drift-weekly.yml b/.github/workflows/drift-weekly.yml
new file mode 100644
index 0000000..f5920bb
--- /dev/null
+++ b/.github/workflows/drift-weekly.yml
@@ -0,0 +1,34 @@
+name: Weekly version drift
+
+# Runs the drift check in scheduled mode. On a problem it opens, or updates,
+# one tracking issue titled "New Claude Code stable release". It never opens a pull request.
+on:
+ schedule:
+ - cron: "0 7 * * 1"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ issues: write
+
+jobs:
+ drift:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: lts/*
+ - name: Run the check
+ id: check
+ run: |
+ set +e
+ node .github/scripts/check.mjs --mode scheduled --only drift > "$RUNNER_TEMP/check.txt" 2>&1
+ echo "code=$?" >> "$GITHUB_OUTPUT"
+ cat "$RUNNER_TEMP/check.txt"
+ - name: Open or update the tracking issue
+ if: steps.check.outputs.code != '0'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+ run: .github/scripts/tracking-issue.sh "New Claude Code stable release" "$RUNNER_TEMP/check.txt"
diff --git a/.github/workflows/expiry-daily.yml b/.github/workflows/expiry-daily.yml
new file mode 100644
index 0000000..24e0c75
--- /dev/null
+++ b/.github/workflows/expiry-daily.yml
@@ -0,0 +1,34 @@
+name: Daily expiry markers
+
+# Runs the expiry check in scheduled mode. On a problem it opens, or updates,
+# one tracking issue titled "Expired facts in the guide". It never opens a pull request.
+on:
+ schedule:
+ - cron: "0 5 * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ issues: write
+
+jobs:
+ expiry:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: lts/*
+ - name: Run the check
+ id: check
+ run: |
+ set +e
+ node .github/scripts/check.mjs --mode scheduled --only expiry > "$RUNNER_TEMP/check.txt" 2>&1
+ echo "code=$?" >> "$GITHUB_OUTPUT"
+ cat "$RUNNER_TEMP/check.txt"
+ - name: Open or update the tracking issue
+ if: steps.check.outputs.code != '0'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+ run: .github/scripts/tracking-issue.sh "Expired facts in the guide" "$RUNNER_TEMP/check.txt"
diff --git a/.github/workflows/links-weekly.yml b/.github/workflows/links-weekly.yml
new file mode 100644
index 0000000..7b949e0
--- /dev/null
+++ b/.github/workflows/links-weekly.yml
@@ -0,0 +1,36 @@
+name: Weekly external links
+
+# Runs the external-links check in scheduled mode. On a problem it opens, or updates,
+# one tracking issue titled "Broken external links". It never opens a pull request.
+on:
+ schedule:
+ - cron: "0 6 * * 1"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ issues: write
+
+jobs:
+ external-links:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: lts/*
+ - name: Install lychee
+ run: .github/scripts/install-lychee.sh
+ - name: Run the check
+ id: check
+ run: |
+ set +e
+ node .github/scripts/check.mjs --mode scheduled --only external-links > "$RUNNER_TEMP/check.txt" 2>&1
+ echo "code=$?" >> "$GITHUB_OUTPUT"
+ cat "$RUNNER_TEMP/check.txt"
+ - name: Open or update the tracking issue
+ if: steps.check.outputs.code != '0'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+ run: .github/scripts/tracking-issue.sh "Broken external links" "$RUNNER_TEMP/check.txt"
diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml
deleted file mode 100644
index 57446bf..0000000
--- a/.github/workflows/links.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-name: Check links
-
-# Pull requests run the offline link check in checks.yml. This weekly run
-# still checks external links.
-on:
- schedule:
- - cron: "0 6 * * 1" # Mondays 06:00 UTC
- workflow_dispatch:
-
-jobs:
- lychee:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: Check links
- uses: lycheeverse/lychee-action@v2
- with:
- # 403/429: docs sites throttle bots; GitHub blob anchors aren't real HTML anchors
- args: >-
- --no-progress
- --accept 200,201,204,301,302,403,429
- --exclude-path .claude
- "**/*.md"
- fail: true
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2b1e16f..27f0d8a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -227,6 +227,23 @@ Each rule has known-bad fixtures under `.github/scripts/fixtures/`, one folder p
node --test '.github/scripts/test/**/*.test.mjs'
```
+## Maintainer routine
+
+Scheduled checks keep watch between editions. Each opens or updates one tracking issue and never opens a pull request:
+
+| Workflow | Runs | Issue |
+|---|---|---|
+| Weekly external links | Mondays | Broken external links |
+| Daily expiry markers | Daily | Expired facts in the guide |
+| Weekly version drift | Mondays | New Claude Code stable release |
+
+Every month, the maintainer:
+
+1. Runs the stale-docs audit in a Claude Code session at the repo root, `/stale-docs-audit`, and files the `issueBody` it returns as one issue. It sorts every volatile claim in README, the docs pages and the example READMEs as stale, unverifiable or ok.
+2. Runs `gh workflow list --all` and turns any disabled scheduled workflow back on with `gh workflow enable <workflow>`. In a public repository, GitHub disables scheduled workflows after 60 days without repository activity ([Disabling and enabling a workflow](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/disable-and-enable-workflows)).
+
+Every two weeks, the maintainer runs `.github/scripts/traffic-snapshot.sh` and keeps its output. It records how many visitors go from the repo page to each level, the stars added in the last 30 days, search referrers and lesson-feedback issues. It needs the maintainer's own `gh` login, because the traffic API needs push access, and it records a level outside GitHub's top 10 paths as "below the 10th" ([Repository traffic](https://docs.github.com/en/rest/metrics/traffic)).
+
## Doc style guide
The guide is moving to lessons in three levels: Beginner, Intermediate and Advanced. New pages follow these rules. Pages from the previous edition are brought in line when they are rewritten.