Project guidance for Claude Code (CLI, IDE, and the GitHub Action). The same conventions apply to GitHub Copilot --- see .github/copilot-instructions.md, which is the source of truth for style.
pds holds the probability prerequisites for the Morrison-Lab data science courses, as Quarto fragments. It renders on its own as a website, and course sites such as mlds link to its pages by URL, so a page's path and its #id anchors are an interface: renaming either breaks those links. The scaffolding came from the UCD-SERG qwt template.
Authoritative style guide: UCD-SERG Lab Manual (source: https://github.com/UCD-SERG/lab-manual).
-
index.qmd,appendix-*.qmd, and the top-level topic pages --- Quarto source pages. The topic pages are listed in reading order in_quarto-website.yml, in a docked sidebar and in matching navbar dropdowns:- Foundations:
notation.qmd,probability-basics.qmd,random-variables.qmd,independence.qmd - Moments:
expectation.qmd,entropy.qmd,variance-covariance.qmd - Distributions:
distributions.qmd,multivariate-gaussian.qmd,limit-theorems.qmd
The navbar's
leftmenus mirror the sidebar'scontentsone-for-one, so a page added, renamed, or moved must be edited in both. - Foundations:
-
_notation.qmd,_subfiles/--- the fragments the topic pages include -
references.qmd--- standalone reference page; excluded from the default website render (!references.qmdin_quarto-website.yml), so it isn't part of the normal site build -
_quarto.yml,_quarto-website.yml--- Quarto project + website config -
pds--- a self-referential symlink (pds -> .), so include paths written aspds/...(the paths a host site that keeps a copy of this repo at its root would use) also resolve when this repo renders standalone. This creates an unboundedpds/pds/pds/...path loop;_quarto-website.yml's!pds/render exclusion keeps Quarto's own render-list glob from walking into it, but the symlink is not otherwise sandboxed --- avoid recursive/symlink-following operations (find -L,rsync -a --copy-links, unscopedgrep -r) rooted at the repo root; scope such commands to real subdirectories instead. lintr cannot be pointed away from it via.lintr.R'sexclusionsfield:lintr::normalize_exclusions()always resolves exclusion paths withnormalize_path(), which follows symlinks, so any exclusion namingpds(the directory, or a file under it) collapses onto the exact same absolute path as the real file it aliases and silently excludes that real file too --- there is no exclusions-list syntax that can single out the symlinked duplicate without also matching the original.lint-project.yamlandlint-changed-files.yamlinsteadrm -f pdsright after checkout, before invoking lintr, so its directory walk never sees the symlink at all. -
_extensions/--- vendored Quarto extensions -
latex-macros/--- git submodule for shortcode/macro definitions (see.gitmodules) -
R/,man/,DESCRIPTION,NAMESPACE--- the project is also a small R package -
references.bib--- BibTeX bibliography -
offwhite.scss,theme-picker.html--- the website's Light / Off-white / Parchment / Dark theme dropdown (saved underlds-theme, withmln-themeread as a legacy fallback, shared with the slides and the other sites on this origin) -
styles.css--- website styling;styles-reveal.scss,qwt-reveal-toggle.html(the same dropdown for slides), and therevealjs-*.luafilters drive the reveal.js slide output -
assets/,images/--- static image and asset files (site pages, docs, CI/PR screenshots) -
.github/workflows/--- CI workflow definitions -
.github/scripts/--- helper scripts used by workflows -
.github/instructions/--- path-scoped Copilot rules that attach by file glob (see.github/copilot-instructions.md) -
CONTRIBUTING.md--- contributor guide -
_site/,_freeze/,.quarto/--- build artifacts (do not edit by hand)
Mirrors .github/copilot-instructions.md. Key points:
- Lists of 3+ items: use bullet lists rather than comma-separated prose. Always leave a blank line before a markdown bullet list (especially in
.qmdfiles). - Code chunks: HTML output folds code by default:
_quarto-website.ymlsetscode-fold: true(withcode-tools: true, so readers can show all code at once), as rme does. Keep the default when the output (plot, table) is the point and the code is incidental. Set#| code-fold: falseon tutorial code, short examples, code that is the main focus, and chunks where the console output is the main content. - R style: respect
.lintr.R. Runlintr::lint_dir()before declaring R changes done. - No nested calls in R:
lint-changed-lines.yamllints the R code and R chunks that a PR adds or edits, withlms::default_linters(nested_calls = TRUE). Itsnested_calls = TRUEsetting enforces the lab's no-nested-calls rule. The linters also flag base R functions that have tidyverse replacements. Run the same linters on a file before pushing withlintr::lint("file.qmd", linters = lms::default_linters(nested_calls = TRUE)). - Definitions and results: one term per
#def-div, aliases ("also called") in the same div, in bold and in the title, and a second new term in its own div that links to the first; one result per theorem-type div. See "Definitions and results" in.github/copilot-instructions.md. - Useful resources: a course, book or video that covers a topic pds teaches goes in the Further reading section of the matching page,
even when lds already lists it in a directory (Ezra, 2026-10-15).
Link the resource, and adapt it with attribution only when its license allows adapting.
See
track-useful-resources. - Quarto chunks: prefer chunk options as YAML-style
#|directives, not as inliner, opt = valarguments.
- Don't edit generated files:
README.mdis built fromREADME.Rmd;_site/and_freeze/are build outputs. - Local preview:
quarto preview(live reload). Full build:quarto render. When verifying a single edited page, render just that page (quarto render <file>.qmd --to html) rather than the whole site --- the/rendercommand is for the full build. - Submodules:
latex-macros/is the only git submodule (see.gitmodules). Rungit submodule update --init --recursiveafter cloning. - Spell check: words go in
inst/WORDLIST(see.github/workflows/check-spelling.yaml). Update the wordlist instead of disabling the check. - Link check: tuned in
lychee.toml; prefer fixing broken links over adding exceptions. - Other CI checks: workflows also verify bibliography DOIs (
check-bibliography-dois.yml) and flag non-standard characters (check-non-standard-chars.yaml). Fix the flagged source rather than relaxing the check. - Dependencies: Dependabot auto-updates the
latex-macrossubmodule and GitHub Actions (see.github/dependabot.yml); don't bump those by hand unless a PR needs it. - Rendering in a cloud session:
random-variables.qmdneeds theqnppackage.remotes::install_github("Morrison-Lab/qnp")fails there with "unknown package", sogit cloneqnp and install it withremotes::install_local(). Installlmsthe same way, from a clone ofMorrison-Lab/pscat thelms-refinlint-changed-lines.yaml. - Moving an example to another page:
inline R on the old page that reads the example's variables then fails.
Put the shared code in an
_*.Rfile under_subfiles/, show it in the example with#| file: pds/_subfiles/<path>.R, and rerun it on the other page in an#| include: falsechunk with the samefileoption (pds#495). - Running the gha checks locally: pds has no local runner.
lds's
.github/workflows/cluster-checks.ymlhas onerun-check.sh <check> <ENV>=... -- python3 ...line per gha check, which gives each check's environment variables; set the base ref toorigin/mainand run them in a full (not shallow) clone. Each check'saction.ymlalso names its variables (*_BASE_REF,*_GLOBS,*_FAIL, andTERM_LINKS_TERMS_DIRSpointing at an mds clone), so a short loop over a gha clone'scheck-*/action.ymlthat sets them can run every check in one pass (pds#526). Commit first, because the checks diffHEAD. Check out the submodule first (git submodule update --init --depth 1 latex-macros): without it,check-fform-paren,check-macro-expansionsandcheck-tautological-equationsskip with a warning instead of running (pds#530).check-linksfails in such a loop only because its lychee step is not a Python step; check new links instead by fetching each published page and searching it forid="<anchor>"(pds#535). To run lds's lines unchanged, make.terms-from/Morrison-Lab/hold clones of mds, sds and mcs and a link to this checkout;.gitignorekeeps it out of commits.check-term-linksreports only a few findings per run, so re-run it after each fix until it passes (pds#531 took five runs). - Cross-page references: pds has no
site-xrefsfilter, so@idresolves only to an id on the same page. Reference an id on another page with a link,[text](page.qmd#id), and when a div moves to another page, rewrite the old page's@idreferences to it as links (pds#526). A bare[text](#id)also breaks when the id is on another page. When moving a section, repoint links by id with a script, not by hand: map each page's ids from its include tree, then give every link into or out of the moved subfiles the page that holds its id. Run once onmain, the same map found 12 links naming the wrong page (pds#542, pds#543, pds#544). Expectcheck-term-linksandcheck-restated-resultsto re-check the moved lines; a solution whose theorem follows later takes<!-- restated-ok: reason -->. - Re-running the Claude review: pds has no
/reviewcomment trigger, so a/reviewcomment starts nothing. To review an unchanged head again, for example after an anchor it links to goes live, post@claude reviewor re-run the lastClaude Code Reviewrun in full (re-running only the failed jobs reuses the old workflow version) (pds#524). - Rendering
variance-covariance.qmdalso needsreticulateandreadr; installing theImportsandSuggestsinDESCRIPTIONfromhttps://packagemanager.posit.co/cran/__linux__/noble/latestcovers them.
- Keep PRs scoped --- bug fixes shouldn't smuggle in refactors.
-
Plan for these slips that cost review rounds on new result and definition divs
(pds#409, pds#413, pds#414, 2026-11-10; pds#490, 2026-11-23):
- The Claude review rule: a new
#prp-,#thm-,#lem-,#cor-or#def-div needs a worked#exm-div after it. A remark between them does not count, and the review is NOT_CLEAN without the example. -
check-avoided-wordsfails a trailing(@prp-x)crossref. Write "As @prp-x shows, ..." or make the whole claim the link text. -
check-term-linksflags an ordinary word that is also a defined term, such as "terms" in "In practical terms". Reword it rather than link it. - The
check-term-linksopt-out pragma must carry a reason, as in<!-- check-term-links: allow: reason -->. It must also sit on the same line as the term it excuses: on a line of its own it suppresses nothing, and the check fails it asstale-allow(pds#520). -
check-definite-antecedentsfails a bare demonstrative such as "That is why"; name the referent ("This one-variable case is why"). To run it locally, setODA_BASE_REF=origin/mainandODA_GLOBS='*.qmd', not aCDA_orDA_prefix, which it ignores and then skips the run (pds#520). -
check-equation-labelsfails any new display equation without an{#eq-...}label, in examples as well as results (pds#526). -
check-term-linksreads "is positive definite" as one defined phrase: link the whole phrase,[is positive definite](...), not "positive definite" alone (pds#526). -
check-term-linksalso reads a bold list label in a solution or proof, such as**Symmetry:**, as a first use of a defined term: link the label, or excuse it with the pragma above (pds#535). "Finite" for a value has no definition to link; write "is a real number" or "is less than$\infty$ " instead. - The lms linters flag
rep(c(...))inside a data frame (nested calls) and a hardcodedlabs(fill = "..."). Build a small table withdplyr::tribble(), and give a column the name its legend should show, such as~`mass function`. Do not reach forlabelled::set_variable_labels(): the preview build does not install packages fromSuggests, so the page fails to render (pds#535). -
check-result-titlesneeds a result's title to be a declarative sentence, and it reads a verb after "that" as part of a subordinate clause, not as the main verb. "The probability that they all occur is a product ..." fails; "The probability of an intersection is a product ..." passes. Put the main verb in a clause of its own.
- The Claude review rule: a new
-
A mechanical split of a multi-div subfile stays a pure move
(Ezra, 2026-11-09, pds#368 and pds#369).
A pure movement PR is exempt from the PR size cap,
which gha's
check-pr-sizeand ai-config's push hook set at 40 files and 1200 lines, doubled from 20 and 600 (Ezra, 2026-11-28: "double the cap on pr size" and "pure movement prs are exempt from the cap"), and the body still says "mechanical, content-identical" so a reviewer knows to diff the moved text. New content that a check forces (a result div, an example) is not a move and loses the exemption: put it in a small stacked PR, and exempt the moved text from the check with<!-- def-equiv-ok: reason -->, listed in the body. Put that comment below the####title line, never above it: above it, the div renders with no title. Touching a subfile re-checks its old text, so expectcheck-term-linksandcheck-definition-equationsto flag lines you only moved.check-result-definition-linksre-checks a moved result div the same way: exempt it with<!-- check-result-definition-links: allow: reason -->below the title line, and list it in the body. -
A small edit to a multi-div subfile starts with a split.
check-one-div-per-subfilefails any PR that adds a line to a subfile with more than one top-level div (a proof stays with its claim). So a small edit to such a file goes as two stacked PRs, the mechanical split first and the edit on the split files second (the split of_def-pdf-pmf-cdf.qmdin pds#426, then the interval edit in pds#425). Put a> [!IMPORTANT]alert on the second PR naming the first, and merge the first with a merge commit, not a squash, because squashing it givesmaindifferent commits from the branch stacked on it. Check that the split is a pure move by rendering the page before and after and diffing the<body>(as in pds#426). -
Keep
main's lines in a merge resolution, and rewrite them in the next commit (pds#524).check-merge-dropsruns withfail: trueand reads only merge commits. It reports a linemainadded that the merge drops, unless a new line at least 0.6 word-similar replaces it, and a short line rewritten as a link (as in @def-mahalanobis,) scores below that. So keep the line as is in the merge, then make the rewrite in an ordinary commit whose message says why. A PR that conflicts withmaingets nopull_requestchecks at all (gha#859), so a head with only CodeQL check runs is a sign to rungit merge-tree --write-tree origin/main <branch>. - Write commit messages and PR descriptions explaining the why, not just the what.
- Don't bypass CI failures (spell check, link check, lint, bibliography DOIs, non-standard chars) --- fix the underlying issue.
- Don't commit
_site/or_freeze/changes unless that is genuinely the intent of the PR.
The lab's cross-repository rules live in Morrison-Lab/ai-config,
which .claude/settings.json enables as the ai-config@Morrison-Lab plugin.
Enabling is not installing: a local session needs claude plugin install ai-config@Morrison-Lab once.
When the plugin is not loaded (for example, in a session rooted above this checkout),
read the rules from a clone of ai-config before content work, in particular:
shared/writing/--- definitions, derivation steps, fact-checking, cross-references, plain proseshared/coding/--- R style, ASCII punctuation in sourceskills/quarto-authoring/references/divs-and-spans.md--- no theorem-type div nested inside another
This repository is the canonical home for the probability prerequisites
that Morrison-Lab/rme carries as appendices
(probability.qmd and sec-CLT.qmd).
rme will drop those appendices and point readers here
(rme#1204).
- rme is a good first place to look for content, not an authority on content or style: much of it predates the lab's style rules. Check what you port, fix what is wrong, and bring it up to the current rules.
- Keep rme's
#ids, so rme's links can be repointed by changing only the path.
- Reformatting unrelated files.
- Inventing URLs or citations --- only use sources actually present in
references.bibor explicitly provided.
This repository follows the maintainer's cross-project agent rules in Morrison-Lab/ai-config. If your harness has not already loaded them (Claude Code loads them through the ai-config plugin), read AGENTS.md before starting work, and follow it alongside this file. This file's own instructions add to those rules, and win only where they are more specific.