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: guard inbound anchors and page paths with committed compat lists (#50)

Wesam Abousaidf35e8d6e9c60
diff --git a/.github/compat/anchors.txt b/.github/compat/anchors.txt
new file mode 100644
index 0000000..6f63ed4
--- /dev/null
+++ b/.github/compat/anchors.txt
@@ -0,0 +1,307 @@
+# The anchors of README.md, the docs/ pages and mcp-servers/README.md on origin/main at 735d4e1, generated by .github/scripts/generate-compat-lists.mjs.
+# Edit only in pull requests that add Stubs.
+README.md#-choose-your-path
+README.md#-reading-tips
+README.md#-whats-inside
+README.md#-when-to-use-what
+README.md#1-explore--plan--code--commit
+README.md#1-git-worktrees--parallel-branches-parallel-sessions
+README.md#1-install
+README.md#2-authenticate
+README.md#2-general-purpose-subagents--when-one-claude-isnt-enough
+README.md#2-test-driven-workflow-write-tests--code--commit
+README.md#3-run-your-first-prompt
+README.md#3-specialized-subagents--drop-in-role-prompts
+README.md#3-visual-iteration-code--screenshot--iterate--commit
+README.md#4-effort-levels--how-hard-claude-thinks
+README.md#4-optional-generate-a-claudemd
+README.md#5-bonus-steal-this-repos-setup
+README.md#agent-teams-experimental
+README.md#agent-teams-experimental---2026
+README.md#ai-agents
+README.md#available-skills-reference
+README.md#best-practices
+README.md#beyond-one-terminal--the-2026-automation-surface
+README.md#beyond-your-own-skills--the-ecosystem
+README.md#built-in-slash-commands
+README.md#built-in-vs-custom-skills
+README.md#claude-code-everything-you-need-to-know-
+README.md#claude-code-setup
+README.md#claude-commands
+README.md#claude-opus-46-the-latest-powerhouse
+README.md#claude-opus-47-the-latest-flagship
+README.md#claude-skills
+README.md#creating-custom-skills
+README.md#custom-slash-commands
+README.md#day-1-essentials
+README.md#dynamic-workflows
+README.md#effort-levels
+README.md#enable-it
+README.md#execution--debugging
+README.md#faq
+README.md#fast-mode
+README.md#fast-mode-
+README.md#featured-mcp-servers
+README.md#hook-events
+README.md#hook-execution-details-and-debugging
+README.md#hook-input
+README.md#hook-output
+README.md#hooks
+README.md#model-context-protocol-mcp
+README.md#monitoring-and-the-naming-trap
+README.md#more-mcp-servers-worth-knowing
+README.md#orchestrating-specialists-from-the-main-session
+README.md#prompt-engineering-deep-dive
+README.md#references
+README.md#running-agents-in-parallel
+README.md#sdlc
+README.md#security-considerations
+README.md#setting-up-claude-hooks
+README.md#setting-up-hooks
+README.md#skills-best-practices
+README.md#skills-faq
+README.md#staff-a-team-with-the-role-prompts-you-already-have
+README.md#starting-your-own
+README.md#steal-this-setup
+README.md#subagents--running-agents-in-parallel
+README.md#super-claude-framework
+README.md#the-bmad-method--ai-agent-framework
+README.md#the-claude-5-era-todays-model-lineup
+README.md#the-example-that-justifies-the-cost
+README.md#the-mcp-ecosystem-today
+README.md#the-mcp-registry--self-discovering-agents
+README.md#the-nm-problem-mcp-solves
+README.md#three-pillars
+README.md#three-things-that-catch-people-out
+README.md#troubleshooting-skills
+README.md#try-it-in-2-minutes--no-script-required
+README.md#updates--deprecations
+README.md#updates--deprecations-as-of-july-2026
+README.md#updates--deprecations-february-2026
+README.md#using-skills-in-workflow
+README.md#want-more-depth
+README.md#what-are-llms-and-how-do-they-differ-from-ai-tools-like-claude-code
+README.md#what-are-skills
+README.md#what-is-claude-code
+README.md#your-first-skill-in-3-minutes
+docs/agent-teams.md#agent-teams--the-complete-guide
+docs/agent-teams.md#architecture
+docs/agent-teams.md#best-practices
+docs/agent-teams.md#competing-hypotheses--the-scientific-debate
+docs/agent-teams.md#contents
+docs/agent-teams.md#display-modes
+docs/agent-teams.md#enable-it
+docs/agent-teams.md#limitations
+docs/agent-teams.md#models-and-effort
+docs/agent-teams.md#parallel-code-review-with-distinct-lenses
+docs/agent-teams.md#permissions
+docs/agent-teams.md#plan-approval
+docs/agent-teams.md#quality-gates-with-hooks
+docs/agent-teams.md#reuse-your-existing-agent-definitions
+docs/agent-teams.md#see-also
+docs/agent-teams.md#talking-to-teammates
+docs/agent-teams.md#teams-vs-subagents
+docs/agent-teams.md#the-shared-task-list
+docs/agent-teams.md#troubleshooting
+docs/agent-teams.md#two-patterns-that-earn-their-cost
+docs/agent-teams.md#what-teammates-know
+docs/agent-teams.md#your-first-team
+docs/reference/changelog.md#-changed
+docs/reference/changelog.md#-deprecated--removed
+docs/reference/changelog.md#-important-dates
+docs/reference/changelog.md#-new-features
+docs/reference/changelog.md#changelog--claude-code--ecosystem-updates
+docs/reference/changelog.md#commands--cli
+docs/reference/changelog.md#mcp-ecosystem
+docs/reference/changelog.md#models
+docs/reference/changelog.md#orchestration--automation
+docs/reference/changelog.md#skills--plugins
+docs/reference/commands.md#common-built-in-slash-commands
+docs/reference/commands.md#custom-slash-commands-skills
+docs/reference/commands.md#slash-commands--cheatsheet
+docs/reference/effort-levels.md#decision-shortcut
+docs/reference/effort-levels.md#defaults-by-model
+docs/reference/effort-levels.md#effort--intelligence--the-context-quality-trap
+docs/reference/effort-levels.md#known-gotchas
+docs/reference/effort-levels.md#reasoning-effort-levels
+docs/reference/effort-levels.md#see-also
+docs/reference/effort-levels.md#setting-effort
+docs/reference/effort-levels.md#sources
+docs/reference/effort-levels.md#the-plan-with-high--execute-with-low-pattern
+docs/reference/effort-levels.md#the-six-levels
+docs/reference/effort-levels.md#tldr
+docs/reference/effort-levels.md#tokenizer-overhead-on-newer-models
+docs/reference/effort-levels.md#ultracode-is-not-an-api-level
+docs/reference/effort-levels.md#ultrathink-doesnt-change-the-api-effort
+docs/reference/effort-levels.md#what-effort-actually-controls
+docs/reference/effort-levels.md#when-to-use-what
+docs/reference/faq.md#faq--claude-code--claude-plans
+docs/reference/faq.md#fast-mode
+docs/reference/faq.md#models
+docs/reference/faq.md#optimization
+docs/reference/faq.md#pricing--plans
+docs/reference/faq.md#q-api-pricing-pay-as-you-go
+docs/reference/faq.md#q-can-i-use-the-1m-context-window
+docs/reference/faq.md#q-does-ultrathink-actually-raise-effort
+docs/reference/faq.md#q-how-are-tokens-counted
+docs/reference/faq.md#q-how-do-git-worktrees-affect-claude-code-sessions
+docs/reference/faq.md#q-how-do-i-get-fully-separate-claude-code-contexts
+docs/reference/faq.md#q-how-do-i-maximize-my-pro-usage
+docs/reference/faq.md#q-how-many-messages-do-i-get-on-the-pro-plan
+docs/reference/faq.md#q-how-many-reasoning-effort-levels-are-there-and-whats-my-default
+docs/reference/faq.md#q-how-much-code-can-i-work-on-per-5-hour-window
+docs/reference/faq.md#q-pro-vs-max-5x-vs-max-20x
+docs/reference/faq.md#q-what-are-the-claude-subscription-plans
+docs/reference/faq.md#q-what-claude-models-are-available-in-2026
+docs/reference/faq.md#q-what-happens-when-i-run-multiple-claude-code-sessions-in-different-terminals
+docs/reference/faq.md#q-what-is-fast-mode-and-when-should-i-use-it
+docs/reference/faq.md#q-whats-the-difference-between-custom-slash-commands-and-skills
+docs/reference/faq.md#q-why-cant-i-persist-max-or-ultracode-in-settingsjson
+docs/reference/faq.md#reasoning-effort
+docs/reference/faq.md#sessions-terminals--worktrees
+docs/reference/faq.md#skills--commands
+docs/reference/faq.md#tokens--limits
+docs/reference/further-reading.md#agent-development
+docs/reference/further-reading.md#agent-interoperability
+docs/reference/further-reading.md#claude-code-documentation
+docs/reference/further-reading.md#claude-models--api
+docs/reference/further-reading.md#development-tools--adjacent-resources
+docs/reference/further-reading.md#further-reading
+docs/reference/further-reading.md#hooks--automation
+docs/reference/further-reading.md#mcp-server-examples
+docs/reference/further-reading.md#model-announcements-2026
+docs/reference/further-reading.md#model-context-protocol-mcp
+docs/reference/further-reading.md#official
+docs/reference/further-reading.md#official-claude--anthropic-resources
+docs/reference/further-reading.md#workflows--tutorials
+docs/reference/models.md#api-pay-as-you-go
+docs/reference/models.md#claude-fable-5--the-mythos-class
+docs/reference/models.md#claude-fable-5-legacy
+docs/reference/models.md#claude-opus-48--the-opus-flagship
+docs/reference/models.md#claude-opus-48-legacy
+docs/reference/models.md#claude-sonnet-5--the-new-default
+docs/reference/models.md#claude-sonnet-5-legacy
+docs/reference/models.md#fast-mode
+docs/reference/models.md#models--specifications--pricing
+docs/reference/models.md#pricing
+docs/reference/models.md#subscription-plans
+docs/reference/models.md#the-current-lineup-as-of-october-4-2026
+docs/reference/models.md#the-current-lineup-july-2026
+docs/reference/models.md#the-headliners
+docs/skills.md#-do
+docs/skills.md#-dont
+docs/skills.md#-persona--methodology
+docs/skills.md#-quality--review
+docs/skills.md#-skill-installer
+docs/skills.md#-task-management
+docs/skills.md#-workflow--process
+docs/skills.md#advanced-patterns
+docs/skills.md#available-skills-reference
+docs/skills.md#built-in-skills-vs-custom-skills
+docs/skills.md#built-in-vs-custom-skills
+docs/skills.md#claude-skills--the-complete-guide
+docs/skills.md#common-issues
+docs/skills.md#contents
+docs/skills.md#creating-custom-skills
+docs/skills.md#curated-awesome-lists
+docs/skills.md#debugging-tips
+docs/skills.md#edge-cases--gotchas
+docs/skills.md#engineering--development
+docs/skills.md#error-messages
+docs/skills.md#frontmatter-reference
+docs/skills.md#installing-a-community-skill
+docs/skills.md#marketplaces--registries
+docs/skills.md#memory-context--ops
+docs/skills.md#notable-community-skills-by-category
+docs/skills.md#official-anthropic-resources
+docs/skills.md#output-formats--creative
+docs/skills.md#passing-arguments-to-skills
+docs/skills.md#performance-considerations
+docs/skills.md#quality-review--debugging
+docs/skills.md#quickstart-your-first-skill-3-minutes
+docs/skills.md#reasoning--process
+docs/skills.md#recipe-1-complete-feature-development
+docs/skills.md#recipe-2-bug-investigation--resolution
+docs/skills.md#recipe-3-ux-focused-development
+docs/skills.md#research--business
+docs/skills.md#skill--tool-development
+docs/skills.md#skill-file-requirements
+docs/skills.md#skills-best-practices
+docs/skills.md#skills-faq
+docs/skills.md#step-by-step-building-your-first-skill
+docs/skills.md#the-skills-ecosystem
+docs/skills.md#troubleshooting-skills
+docs/skills.md#two-flavors-of-skills
+docs/skills.md#using-skills-in-workflow
+docs/skills.md#using-skills-in-your-workflow
+docs/skills.md#version-requirements
+docs/skills.md#what-are-claude-skills
+docs/skills.md#what-are-skills
+docs/skills.md#where-claude-looks
+docs/skills.md#where-claude-looks-for-name
+docs/skills.md#workflow--collaboration
+docs/workflows.md#1-run-one-that-already-exists
+docs/workflows.md#2-ask-for-one-in-a-single-prompt
+docs/workflows.md#3-let-claude-decide-for-the-whole-session
+docs/workflows.md#approving-the-run
+docs/workflows.md#contents
+docs/workflows.md#controlling-cost
+docs/workflows.md#dynamic-workflows--orchestrating-agents-at-scale
+docs/workflows.md#limits-and-behavior
+docs/workflows.md#model-routing
+docs/workflows.md#passing-input-with-args
+docs/workflows.md#permissions
+docs/workflows.md#prompt-patterns-that-work
+docs/workflows.md#resuming-a-run
+docs/workflows.md#saving-a-workflow-for-reuse
+docs/workflows.md#see-also
+docs/workflows.md#size-guideline
+docs/workflows.md#start-here-deep-research
+docs/workflows.md#the-large-run-warning
+docs/workflows.md#three-ways-to-start-a-workflow
+docs/workflows.md#turning-workflows-off
+docs/workflows.md#watching-a-run
+docs/workflows.md#what-the-script-looks-like
+docs/workflows.md#who-holds-the-plan
+mcp-servers/README.md#additional-resources
+mcp-servers/README.md#agentic-ai-foundation
+mcp-servers/README.md#available-servers
+mcp-servers/README.md#by-use-case
+mcp-servers/README.md#code-development
+mcp-servers/README.md#command-not-found-errors
+mcp-servers/README.md#complete-reinstall
+mcp-servers/README.md#current-mcp-protocol-features
+mcp-servers/README.md#full-server-reinstallation
+mcp-servers/README.md#general-troubleshooting
+mcp-servers/README.md#getting-started
+mcp-servers/README.md#global--s-user
+mcp-servers/README.md#global-installation-recommended
+mcp-servers/README.md#important-notes
+mcp-servers/README.md#installation
+mcp-servers/README.md#installation-scopes
+mcp-servers/README.md#local--s-local
+mcp-servers/README.md#local-installation-project-specific
+mcp-servers/README.md#mcp-registry--ecosystem
+mcp-servers/README.md#mcp-servers-documentation
+mcp-servers/README.md#official-mcp-registry
+mcp-servers/README.md#overview
+mcp-servers/README.md#playwright-connection-failures
+mcp-servers/README.md#playwright-specific-issues
+mcp-servers/README.md#powerful-combinations
+mcp-servers/README.md#prerequisites
+mcp-servers/README.md#research--analysis
+mcp-servers/README.md#sequential-thinking--memory-failures
+mcp-servers/README.md#sequential-thinking--memory-issues
+mcp-servers/README.md#serena-connection-failures
+mcp-servers/README.md#serena-specific-issues
+mcp-servers/README.md#server-comparison
+mcp-servers/README.md#server-shows-failed-to-connect
+mcp-servers/README.md#server-specific-documentation
+mcp-servers/README.md#server-synergies
+mcp-servers/README.md#still-having-issues
+mcp-servers/README.md#troubleshooting
+mcp-servers/README.md#verification
+mcp-servers/README.md#verify-all-servers
+mcp-servers/README.md#verify-installation
+mcp-servers/README.md#verify-prerequisites
+mcp-servers/README.md#web-automation
diff --git a/.github/compat/paths.txt b/.github/compat/paths.txt
new file mode 100644
index 0000000..5d90f91
--- /dev/null
+++ b/.github/compat/paths.txt
@@ -0,0 +1,16 @@
+# The docs/ and mcp-servers/ page paths on origin/main at 735d4e1, generated by .github/scripts/generate-compat-lists.mjs.
+# Edit only in pull requests that add Stubs.
+docs/agent-teams.md
+docs/reference/changelog.md
+docs/reference/commands.md
+docs/reference/effort-levels.md
+docs/reference/faq.md
+docs/reference/further-reading.md
+docs/reference/models.md
+docs/skills.md
+docs/workflows.md
+mcp-servers/README.md
+mcp-servers/memory.md
+mcp-servers/playwright.md
+mcp-servers/sequential-thinking.md
+mcp-servers/serena.md
diff --git a/.github/scripts/check.mjs b/.github/scripts/check.mjs
index 4e07bcc..7834816 100644
--- a/.github/scripts/check.mjs
+++ b/.github/scripts/check.mjs
@@ -7,6 +7,7 @@ import { parseArgs } from 'node:util';
import { resolve } from 'node:path';
import { rules } from './rules/index.mjs';
import { listFiles } from './lib/tree.mjs';
+import { resolveBase } from './lib/git.mjs';
const MODES = ['pr', 'release', 'scheduled'];
@@ -36,7 +37,7 @@ const only = args.only ? args.only.split(',') : null;
for (const name of only ?? []) if (!known.has(name)) usage(`unknown rule: ${name}`);
const root = resolve(args.root);
-const ctx = { root, mode: args.mode, tag: args.tag, files: listFiles(root) };
+const ctx = { root, mode: args.mode, tag: args.tag, files: listFiles(root), base: resolveBase(root, args.base) };
let failed = false;
for (const rule of rules) {
diff --git a/.github/scripts/fixtures/anchored-heading-rename/base/docs/hooks.md b/.github/scripts/fixtures/anchored-heading-rename/base/docs/hooks.md
new file mode 100644
index 0000000..fc5e87a
--- /dev/null
+++ b/.github/scripts/fixtures/anchored-heading-rename/base/docs/hooks.md
@@ -0,0 +1,5 @@
+# Hooks
+
+## Hook events
+
+Text.
diff --git a/.github/scripts/fixtures/anchored-heading-rename/fixture.json b/.github/scripts/fixtures/anchored-heading-rename/fixture.json
new file mode 100644
index 0000000..15337cf
--- /dev/null
+++ b/.github/scripts/fixtures/anchored-heading-rename/fixture.json
@@ -0,0 +1,5 @@
+{
+ "rule": "anchor-diff",
+ "expect": "pass",
+ "about": "A renamed heading keeps its old slug as an <a id> on the line above, so old links still land."
+}
diff --git a/.github/scripts/fixtures/anchored-heading-rename/tree/docs/hooks.md b/.github/scripts/fixtures/anchored-heading-rename/tree/docs/hooks.md
new file mode 100644
index 0000000..ff28b3f
--- /dev/null
+++ b/.github/scripts/fixtures/anchored-heading-rename/tree/docs/hooks.md
@@ -0,0 +1,6 @@
+# Hooks
+
+<a id="hook-events"></a>
+## Events a hook can handle
+
+Text.
diff --git a/.github/scripts/fixtures/baseline-anchor-missing/fixture.json b/.github/scripts/fixtures/baseline-anchor-missing/fixture.json
new file mode 100644
index 0000000..4ea6be8
--- /dev/null
+++ b/.github/scripts/fixtures/baseline-anchor-missing/fixture.json
@@ -0,0 +1,5 @@
+{
+ "rule": "anchor-diff",
+ "expect": "fail",
+ "about": "An anchor in the committed baseline list no longer exists, even with no base to diff against."
+}
diff --git a/.github/scripts/fixtures/baseline-anchor-missing/tree/.github/compat/anchors.txt b/.github/scripts/fixtures/baseline-anchor-missing/tree/.github/compat/anchors.txt
new file mode 100644
index 0000000..1b9867d
--- /dev/null
+++ b/.github/scripts/fixtures/baseline-anchor-missing/tree/.github/compat/anchors.txt
@@ -0,0 +1,3 @@
+# Fixture list
+docs/models.md#pricing
+docs/models.md#model-aliases
diff --git a/.github/scripts/fixtures/baseline-anchor-missing/tree/docs/models.md b/.github/scripts/fixtures/baseline-anchor-missing/tree/docs/models.md
new file mode 100644
index 0000000..b458591
--- /dev/null
+++ b/.github/scripts/fixtures/baseline-anchor-missing/tree/docs/models.md
@@ -0,0 +1,5 @@
+# Models
+
+## Model aliases
+
+Text.
diff --git a/.github/scripts/fixtures/legacy-page-outside-anchor-diff/base/docs/legacy/hooks.md b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/base/docs/legacy/hooks.md
new file mode 100644
index 0000000..adef6d7
--- /dev/null
+++ b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/base/docs/legacy/hooks.md
@@ -0,0 +1,5 @@
+# Previous edition: hooks
+
+## Hook events
+
+Text.
diff --git a/.github/scripts/fixtures/legacy-page-outside-anchor-diff/fixture.json b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/fixture.json
new file mode 100644
index 0000000..1131d0f
--- /dev/null
+++ b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/fixture.json
@@ -0,0 +1,5 @@
+{
+ "rule": "anchor-diff",
+ "expect": "pass",
+ "about": "Pages from the previous edition under docs/legacy/ sit outside the anchor diff, so retiring their sections is allowed."
+}
diff --git a/.github/scripts/fixtures/legacy-page-outside-anchor-diff/tree/docs/legacy/hooks.md b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/tree/docs/legacy/hooks.md
new file mode 100644
index 0000000..713a7a0
--- /dev/null
+++ b/.github/scripts/fixtures/legacy-page-outside-anchor-diff/tree/docs/legacy/hooks.md
@@ -0,0 +1,3 @@
+# Previous edition: hooks
+
+Retired.
diff --git a/.github/scripts/fixtures/removed-stub-path/fixture.json b/.github/scripts/fixtures/removed-stub-path/fixture.json
new file mode 100644
index 0000000..1569aac
--- /dev/null
+++ b/.github/scripts/fixtures/removed-stub-path/fixture.json
@@ -0,0 +1,5 @@
+{
+ "rule": "stub-paths",
+ "expect": "fail",
+ "about": "A page path in the committed list was deleted instead of being left as a Stub."
+}
diff --git a/.github/scripts/fixtures/removed-stub-path/tree/.github/compat/paths.txt b/.github/scripts/fixtures/removed-stub-path/tree/.github/compat/paths.txt
new file mode 100644
index 0000000..41c1eb7
--- /dev/null
+++ b/.github/scripts/fixtures/removed-stub-path/tree/.github/compat/paths.txt
@@ -0,0 +1,3 @@
+# Fixture list
+docs/reference/faq.md
+docs/reference/models.md
diff --git a/.github/scripts/fixtures/removed-stub-path/tree/docs/reference/models.md b/.github/scripts/fixtures/removed-stub-path/tree/docs/reference/models.md
new file mode 100644
index 0000000..7752c4f
--- /dev/null
+++ b/.github/scripts/fixtures/removed-stub-path/tree/docs/reference/models.md
@@ -0,0 +1,3 @@
+# Models
+
+Text.
diff --git a/.github/scripts/fixtures/unanchored-heading-rename/base/docs/hooks.md b/.github/scripts/fixtures/unanchored-heading-rename/base/docs/hooks.md
new file mode 100644
index 0000000..fc5e87a
--- /dev/null
+++ b/.github/scripts/fixtures/unanchored-heading-rename/base/docs/hooks.md
@@ -0,0 +1,5 @@
+# Hooks
+
+## Hook events
+
+Text.
diff --git a/.github/scripts/fixtures/unanchored-heading-rename/fixture.json b/.github/scripts/fixtures/unanchored-heading-rename/fixture.json
new file mode 100644
index 0000000..af5a506
--- /dev/null
+++ b/.github/scripts/fixtures/unanchored-heading-rename/fixture.json
@@ -0,0 +1,5 @@
+{
+ "rule": "anchor-diff",
+ "expect": "fail",
+ "about": "A heading is renamed without keeping its old slug, so links to the old fragment break."
+}
diff --git a/.github/scripts/fixtures/unanchored-heading-rename/tree/docs/hooks.md b/.github/scripts/fixtures/unanchored-heading-rename/tree/docs/hooks.md
new file mode 100644
index 0000000..9d0e5c3
--- /dev/null
+++ b/.github/scripts/fixtures/unanchored-heading-rename/tree/docs/hooks.md
@@ -0,0 +1,5 @@
+# Hooks
+
+## Events a hook can handle
+
+Text.
diff --git a/.github/scripts/generate-compat-lists.mjs b/.github/scripts/generate-compat-lists.mjs
new file mode 100644
index 0000000..0bf2f2a
--- /dev/null
+++ b/.github/scripts/generate-compat-lists.mjs
@@ -0,0 +1,40 @@
+#!/usr/bin/env node
+// Writes .github/compat/anchors.txt and paths.txt from a git ref, normally
+// `main` at the rework baseline. Run once; afterwards only pull requests that
+// add Stubs edit the two lists.
+//
+// node .github/scripts/generate-compat-lists.mjs [--ref main] [--root .]
+import { execFileSync } from 'node:child_process';
+import { mkdirSync, writeFileSync } from 'node:fs';
+import { join, resolve } from 'node:path';
+import { parseArgs } from 'node:util';
+import { pageIds } from './lib/markdown.mjs';
+
+const { ref, root: rootArg } = parseArgs({
+ options: { ref: { type: 'string', default: 'main' }, root: { type: 'string', default: '.' } },
+}).values;
+const root = resolve(rootArg);
+const git = (...args) => execFileSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
+
+const sha = git('rev-parse', '--short', ref).trim();
+const tracked = git('ls-tree', '-r', '--name-only', ref).split('\n').filter(Boolean);
+
+// The pages whose anchors and paths inbound links rely on: README, every docs
+// page, and the MCP servers pages. The specialized-agents folder Stub joins
+// paths.txt in the pull request that creates it.
+const anchorPages = tracked.filter((p) => p === 'README.md' || (p.startsWith('docs/') && p.endsWith('.md')) || p === 'mcp-servers/README.md');
+const pagePaths = tracked.filter((p) => (p.startsWith('docs/') && p.endsWith('.md')) || (p.startsWith('mcp-servers/') && p.endsWith('.md')));
+
+const anchors = new Set();
+for (const page of anchorPages) {
+ for (const id of pageIds(git('show', `${ref}:${page}`))) anchors.add(`${page}#${id}`);
+}
+
+const header = (what) => [
+ `# ${what} on ${ref} at ${sha}, generated by .github/scripts/generate-compat-lists.mjs.`,
+ '# Edit only in pull requests that add Stubs.',
+];
+mkdirSync(join(root, '.github', 'compat'), { recursive: true });
+writeFileSync(join(root, '.github', 'compat', 'anchors.txt'), [...header('The anchors of README.md, the docs/ pages and mcp-servers/README.md'), ...[...anchors].sort()].join('\n') + '\n');
+writeFileSync(join(root, '.github', 'compat', 'paths.txt'), [...header('The docs/ and mcp-servers/ page paths'), ...pagePaths.sort()].join('\n') + '\n');
+console.log(`anchors.txt: ${anchors.size} ids from ${anchorPages.length} pages; paths.txt: ${pagePaths.length} paths (${ref} at ${sha})`);
diff --git a/.github/scripts/lib/git.mjs b/.github/scripts/lib/git.mjs
new file mode 100644
index 0000000..0e76db5
--- /dev/null
+++ b/.github/scripts/lib/git.mjs
@@ -0,0 +1,40 @@
+// Read-only git access for diff-scoped rules: what a file looked like at the
+// base, and which lines a change adds. "Head" is the working tree, so
+// uncommitted and untracked files count as part of the change.
+import { execFileSync } from 'node:child_process';
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+import { isExcluded } from './tree.mjs';
+
+function git(root, args) {
+ return execFileSync('git', args, { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
+}
+
+// The commit a change is compared against: the merge base of `ref` and HEAD,
+// so commits that landed on the base branch later are not counted as removals.
+export function resolveBase(root, ref) {
+ if (!existsSync(join(root, '.git'))) return { sha: null, note: 'not a git repository' };
+ const wanted = ref ?? 'origin/main';
+ try {
+ git(root, ['rev-parse', '--verify', '--quiet', `${wanted}^{commit}`]);
+ } catch {
+ return { sha: null, note: `base ${wanted} not found` };
+ }
+ try {
+ return { sha: git(root, ['merge-base', wanted, 'HEAD']).trim(), ref: wanted };
+ } catch {
+ return { sha: null, note: `no merge base between ${wanted} and HEAD` };
+ }
+}
+
+export function filesAt(root, sha) {
+ return git(root, ['ls-tree', '-r', '--name-only', sha]).split('\n').filter((f) => f && !isExcluded(f));
+}
+
+export function readAt(root, sha, path) {
+ try {
+ return git(root, ['show', `${sha}:${path}`]);
+ } catch {
+ return null;
+ }
+}
diff --git a/.github/scripts/lib/markdown.mjs b/.github/scripts/lib/markdown.mjs
new file mode 100644
index 0000000..0590542
--- /dev/null
+++ b/.github/scripts/lib/markdown.mjs
@@ -0,0 +1,69 @@
+// The fragment ids GitHub gives a Markdown page: heading slugs plus explicit
+// <a id> and <a name> anchors. Headings follow GitHub's rule: the heading's
+// text, lowercased, with everything except letters, marks, digits,
+// underscores, hyphens and spaces removed, and spaces turned into hyphens.
+// A repeated slug gets -1, -2, ...
+
+const FENCE = /^ {0,3}(`{3,}|~{3,})/;
+const ATX = /^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/;
+const SETEXT = /^ {0,3}(=+|-+)[ \t]*$/;
+const ANCHOR = /<a\s[^>]*?\b(?:id|name)\s*=\s*["']([^"']+)["']/gi;
+
+const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
+
+function headingText(raw) {
+ let t = raw;
+ t = t.replace(/`+([^`]*?)`+/g, (_, code) => code.replace(/[*_~\\]/g, (c) => `\u0000${c}`));
+ t = t.replace(/!\[[^\]]*\]\([^)]*\)/g, '');
+ t = t.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1');
+ t = t.replace(/\[([^\]]*)\]\[[^\]]*\]/g, '$1');
+ t = t.replace(/<(https?:[^>]+)>/g, '$1');
+ t = t.replace(/<[^>]+>/g, '');
+ t = t.replace(/(\*\*|__|\*|_|~~)(?=\S)([^]*?\S)\1/g, '$2');
+ t = t.replace(/\\([!-/:-@[-`{-~])/g, '$1');
+ t = t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi, (m, e) => {
+ if (e[0] === '#') return String.fromCodePoint(e[1] === 'x' || e[1] === 'X' ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10));
+ return ENTITIES[e.toLowerCase()] ?? m;
+ });
+ return t.replace(/\u0000/g, '');
+}
+
+export function slug(text) {
+ return headingText(text)
+ .toLowerCase()
+ .replace(/[^\p{L}\p{M}\p{Nd}\p{Pc}\- ]/gu, '')
+ .replace(/ /g, '-');
+}
+
+// Every id on the page, in document order. Heading slugs come first in their
+// own line; explicit anchors are listed where they appear.
+export function pageIds(markdown) {
+ const ids = [];
+ const seen = new Map();
+ const addHeading = (text) => {
+ const base = slug(text);
+ const n = seen.get(base) ?? 0;
+ seen.set(base, n + 1);
+ ids.push(n === 0 ? base : `${base}-${n}`);
+ };
+ let fence = null;
+ let paragraph = null;
+ for (const line of markdown.split(/\r?\n/)) {
+ const f = line.match(FENCE);
+ if (fence) {
+ if (f && f[1][0] === fence[0] && f[1].length >= fence.length && /^\s*[`~]+\s*$/.test(line)) fence = null;
+ continue;
+ }
+ if (f) { fence = f[1]; paragraph = null; continue; }
+ for (const m of line.matchAll(ANCHOR)) ids.push(m[1]);
+ const atx = line.match(ATX);
+ if (atx) { addHeading(atx[2] ?? ''); paragraph = null; continue; }
+ if (paragraph !== null && SETEXT.test(line)) { addHeading(paragraph); paragraph = null; continue; }
+ const plain = line.trim() !== ''
+ && !/^ {0,3}([-*+]|\d+[.)])\s/.test(line)
+ && !/^ {0,3}[>|<]/.test(line)
+ && !/^ {4}/.test(line);
+ paragraph = plain ? (paragraph === null ? line.trim() : `${paragraph} ${line.trim()}`) : null;
+ }
+ return ids;
+}
diff --git a/.github/scripts/rules/anchor-diff.mjs b/.github/scripts/rules/anchor-diff.mjs
new file mode 100644
index 0000000..de49f21
--- /dev/null
+++ b/.github/scripts/rules/anchor-diff.mjs
@@ -0,0 +1,56 @@
+// No change may drop an anchor that inbound links can rely on: every id in the
+// committed baseline list, and every id on the base in README.md and docs/
+// (except previous-edition pages under docs/legacy/), must still exist at
+// head, as a heading slug or an <a id>.
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+import { pageIds } from '../lib/markdown.mjs';
+import { filesAt, readAt } from '../lib/git.mjs';
+import { readText } from '../lib/tree.mjs';
+
+export const id = 'anchor-diff';
+export const modes = ['pr', 'release'];
+
+export const ANCHORS_FILE = '.github/compat/anchors.txt';
+
+const covered = (path) =>
+ (path === 'README.md' || (path.startsWith('docs/') && !path.startsWith('docs/legacy/'))) && path.endsWith('.md');
+
+export function run(ctx) {
+ const required = new Map(); // page -> Set of ids
+ const need = (page, anchor) => {
+ if (!required.has(page)) required.set(page, new Set());
+ required.get(page).add(anchor);
+ };
+
+ if (existsSync(join(ctx.root, ANCHORS_FILE))) {
+ for (const line of readText(ctx.root, ANCHORS_FILE).split('\n')) {
+ if (!line.trim() || line.startsWith('#')) continue;
+ const at = line.indexOf('#');
+ need(line.slice(0, at), line.slice(at + 1));
+ }
+ }
+ if (ctx.base.sha) {
+ for (const page of filesAt(ctx.root, ctx.base.sha).filter(covered)) {
+ for (const anchor of pageIds(readAt(ctx.root, ctx.base.sha, page))) need(page, anchor);
+ }
+ }
+ if (required.size === 0) {
+ return { status: 'skip', summary: `no ${ANCHORS_FILE} and ${ctx.base.note ?? 'no base'}` };
+ }
+
+ const problems = [];
+ let count = 0;
+ for (const [page, anchors] of [...required].sort()) {
+ count += anchors.size;
+ const present = existsSync(join(ctx.root, page)) ? new Set(pageIds(readText(ctx.root, page))) : null;
+ const missing = [...anchors].filter((a) => !present?.has(a)).sort();
+ if (missing.length === 0) continue;
+ problems.push(present
+ ? `${page}: ${missing.length} anchor(s) gone; keep each as <a id="..."></a> above its new heading: ${missing.join(', ')}`
+ : `${page}: page removed, taking ${missing.length} anchor(s); leave a Stub with them: ${missing.join(', ')}`);
+ }
+ const against = ctx.base.sha ? `the baseline list and ${ctx.base.ref ?? ctx.base.sha.slice(0, 7)}` : `the baseline list only (${ctx.base.note})`;
+ if (problems.length) return { status: 'fail', problems };
+ return { status: 'pass', summary: `${count} anchors on ${required.size} pages, against ${against}` };
+}
diff --git a/.github/scripts/rules/index.mjs b/.github/scripts/rules/index.mjs
index 0ae532b..d1b5a34 100644
--- a/.github/scripts/rules/index.mjs
+++ b/.github/scripts/rules/index.mjs
@@ -1,4 +1,6 @@
// Every rule the suite runs, in report order.
import * as internalLinks from './internal-links.mjs';
+import * as anchorDiff from './anchor-diff.mjs';
+import * as stubPaths from './stub-paths.mjs';
-export const rules = [internalLinks];
+export const rules = [internalLinks, anchorDiff, stubPaths];
diff --git a/.github/scripts/rules/stub-paths.mjs b/.github/scripts/rules/stub-paths.mjs
new file mode 100644
index 0000000..c9e80d6
--- /dev/null
+++ b/.github/scripts/rules/stub-paths.mjs
@@ -0,0 +1,21 @@
+// Every page path in the committed list still exists, as the page or its Stub.
+import { existsSync } from 'node:fs';
+import { join } from 'node:path';
+import { readText } from '../lib/tree.mjs';
+
+export const id = 'stub-paths';
+export const modes = ['pr', 'release'];
+
+export const PATHS_FILE = '.github/compat/paths.txt';
+
+export function run(ctx) {
+ if (!existsSync(join(ctx.root, PATHS_FILE))) {
+ return { status: 'fail', problems: [`${PATHS_FILE} is missing`] };
+ }
+ const paths = readText(ctx.root, PATHS_FILE).split('\n').map((l) => l.trim()).filter((l) => l && !l.startsWith('#'));
+ const missing = paths.filter((p) => !existsSync(join(ctx.root, p)));
+ if (missing.length) {
+ return { status: 'fail', problems: missing.map((p) => `${p}: removed; leave a Stub at this path that says where the page went`) };
+ }
+ return { status: 'pass', summary: `${paths.length} paths` };
+}
diff --git a/AGENTS.md b/AGENTS.md
index dc13b7a..c3dde61 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -41,7 +41,7 @@ The bar in brief: to add any other Vendor or Community item, a named lesson must
## Editorial rules
-- Renaming or removing a heading: put `<a id="old-slug"></a>` on the line above the new heading so links to the old slug keep working, then run the heading check in [CONTRIBUTING.md#anchor-compatibility](CONTRIBUTING.md#anchor-compatibility). Headings carry no dates, versions, model names, "new" or year words, stability labels or emoji.
+- Renaming or removing a heading: put `<a id="old-slug"></a>` on the line above the new heading so links to the old slug keep working, and leave a Stub at a moved page's old path ([CONTRIBUTING.md#anchor-compatibility](CONTRIBUTING.md#anchor-compatibility)); the checks' `anchor-diff` and `stub-paths` rules catch a missing one. Headings carry no dates, versions, model names, "new" or year words, stability labels or emoji.
- Anchor date-sensitive claims to a version (`v2.1.x`) or a full date. Hedge third-party estimates and attribute them in the sentence.
- Prefer lists or stacked blocks to tables wider than three short columns. GitHub's file view joins consecutive lines, so end a line with a backslash where a paragraph needs a line break.
- In prose you write, use a comma, colon, parentheses or a new sentence where an em dash (U+2014) would go. Em dashes are fine inside quotations, identifiers and filenames.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a3e371f..5cf82fc 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -276,20 +276,18 @@ The folder layout changes while the guide is reworked into three levels, so this
## Anchor compatibility
-The README and the `docs/` pages have a stable URL fragment per section (e.g., `#claude-skills`, `#hooks`). When you rename or remove a heading:
+Listed anchors and page paths from `main` as it was when the rework started keep resolving: [`.github/compat/anchors.txt`](.github/compat/anchors.txt) lists the anchors of `README.md`, the `docs/` pages and `mcp-servers/README.md`, and [`.github/compat/paths.txt`](.github/compat/paths.txt) the paths of the `docs/` and `mcp-servers/` pages, each of which must stay a page or a Stub. Only pull requests that add Stubs edit the two lists.
+
+When you rename or remove a heading:
1. Add an invisible HTML anchor that preserves the old slug:
```html
<a id="old-slug-here"></a>
### New Heading
```
-2. Run the diff before merging, with `f` set to the file you changed:
- ```bash
- f=README.md
- diff <(git show origin/main:"$f" | awk '/^ *```/{c=!c} !c && /^#+ /' | sort) \
- <(awk '/^ *```/{c=!c} !c && /^#+ /' "$f" | sort)
- ```
- It compares the heading lines outside code blocks. No output means no heading changed. Each line marked `<` is an old heading that needs an anchor from step 1.
+2. Run the [checks](#checks). The `anchor-diff` rule fails, naming each missing id, if an anchor in `anchors.txt`, or an anchor on the base branch in `README.md` or `docs/` (pages under `docs/legacy/` excepted), no longer exists.
+
+When you move or remove a page in `paths.txt`, leave a Stub at the old path: an H1, a line such as `This page moved to [Hooks](../intermediate/05-hooks.md).` (or one saying it was removed in an edition, with a one-clause reason and a link to the CHANGELOG entry), and the old page's anchors as `<a id>` lines. The `stub-paths` rule fails if a listed path is gone.
This keeps inbound links from social posts working even after restructures.