Transparent, reproducible, deliverable Stan workflows — as Agent Skills. 透明、可复现、可交付的科研工作流。
A Claude Code plugin marketplace by wmj.
| Plugin | What it does |
|---|---|
stan-highlight |
Colours Stan code by variable role, the block where each variable is declared, and outputs HTML for slides, Quarto notes and handouts. |
In Claude Code:
/plugin marketplace add perlatex/stan-skills
/plugin install stan-highlight@stan-skills
Then restart Claude Code (or run /reload-plugins). That's it, no dependencies
beyond Python 3.8+.
Use it. The standard request is one sentence:
请使用 stan-highlight 高亮 model.stan,输出 model-highlighted.html
Use stan-highlight to highlight model.stan and write model-highlighted.html
If you leave out the output name, you still get model-highlighted.html next to
model.stan. Other things you can ask:
高亮 model.stan,加上颜色图例
只输出
<pre>片段,我要放进 Quarto 幻灯片
把
models/下所有 Stan 模型做成高亮 HTML,打包成 zip
You can also invoke it explicitly with /stan-highlight:stan-highlight model.stan.
Update later with /plugin marketplace update stan-skills.
Install as a plain skill (no plugin system)
Copy the skill folder into your personal skills directory:
# macOS / Linux
cp -r plugins/stan-highlight/skills/stan-highlight ~/.claude/skills/# Windows (PowerShell)
Copy-Item -Recurse plugins\stan-highlight\skills\stan-highlight $HOME\.claude\skills\The same folder works in other agents that read SKILL.md skills.
| Declared in | Colour |
|---|---|
data |
blue |
transformed data |
#0097A7 |
parameters |
red |
transformed parameters |
orange |
model |
black bold |
generated quantities |
green |
A variable keeps its colour everywhere it is used: N is blue inside
model {} too, so students can trace where every quantity comes from.
These stay plain: comments, strings, types, function names, loop indices, and
the whole functions {} block. Argument names there often reuse names declared
elsewhere, so colouring them would mislead. Locals declared inside model or
generated quantities are coloured only within their own block.
The skill instructs Claude to run a deterministic Python parser
(scripts/highlight_stan.py, standard library only) instead of colouring
tokens by hand. Every run can be verified with --check:
- Round trip: stripping the HTML tags gives back the exact source.
- Completeness: every occurrence of a declared variable is coloured with its block's colour.
- Loop indices: no loop index is ever coloured.
S=plugins/stan-highlight/skills/stan-highlight/scripts/highlight_stan.py
python3 $S model.stan # -> model-highlighted.html
python3 $S model.stan --legend # with colour legend
python3 $S model.stan --fragment -o pre.html # <pre> only, for Quarto / reveal.js
python3 $S models/ -r --zip --check # whole tree -> models-highlighted/ + .zipBatch mode mirrors the folder structure, so many files called model.stan
never overwrite each other.
Styles are inline, so a fragment can be dropped into any HTML/reveal.js output:
```{=html}
<!-- contents of pre.html -->
```or htmltools::includeHTML("pre.html") from an R chunk. PDF/LaTeX output is
not covered yet.
See examples/: a hierarchical linear model and a latent class
model (with a functions block and marginalised discrete class), each with the
.stan source and the highlighted .html.
stan-skills/
├── .claude-plugin/marketplace.json # this repo is a marketplace
├── plugins/
│ └── stan-highlight/
│ ├── .claude-plugin/plugin.json
│ └── skills/stan-highlight/
│ ├── SKILL.md
│ └── scripts/highlight_stan.py
├── examples/
└── docs/screenshot.png
MIT © wmj
