# alt-text

Adopt this skill: https://proskills.md/skills/other/posit-dev-skills-alt-text

Page: https://proskills.md/skills/other/posit-dev-skills-alt-text
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: alt-text/SKILL.md
size: 6862
sha: 433c74af4135af7f0d809cace0ab3eb49e47f56f
upstream: https://github.com/posit-dev/skills/blob/main/alt-text/SKILL.md

````text
---
name: alt-text
description: >
  Generate and improve accessible alt text for data visualizations and images
  in R packages and Quarto documents. Use when the user wants to add, improve,
  or audit alt text for figures in a pkgdown site or .qmd files. Activate for
  requests that mention fig-alt, fig.alt, figure descriptions, or alt text in
  the context of an R package or Quarto document.
metadata:
  author: Emil Hvitfeldt (@emilhvitfeldt)
  version: "1.0"
license: MIT
---

# Write Accessible Alt Text

Generate accessible alt text for data visualizations and images in this project.

ARGUMENTS
- label: (optional) specific figure label or chunk to target
- file: (optional) specific file to process

## Detect project type

Before proceeding, identify the project context and read the relevant reference.
Check for a `_pkgdown.yml` file in the project root to detect a pkgdown site:

```bash
ls _pkgdown.yml 2>/dev/null && echo "pkgdown" || echo "not pkgdown"
```

- **pkgdown site** (`_pkgdown.yml` present) → read `references/pkgdown.md`
- **Quarto documents** (no `_pkgdown.yml`, `.qmd` files present) → read `references/quarto.md`

If the context is still ambiguous, ask the user which format they are working in.

## Key advantage: source code access

Unlike typical alt text scenarios where you only see an image, **we have access to the code that generates each chart**. Use this to extract precise details:

**From plotting code:**
- Variable mappings → exact variable names for axes
- Color/fill mappings → what color encodes
- Plot type functions → scatter, histogram, line chart, etc.
- Trend lines or fitted curves → overlaid statistical fits
- Faceting/subplots → number of panels and what varies
- Color scales → encoding scheme (sequential, diverging, categorical)
- Axis labels and titles → customized labels

**From data generation code:**
- Random distributions → expected distribution shape
- Transformations → what was done to data
- Feature engineering → preprocessing applied
- Filtering/subsetting → what subset is shown

**From surrounding prose:**
- Text before/after the chunk explains the **purpose** and **key insight**
- Chapter context tells you what the figure is meant to teach
- This is often the best source for the "key insight" part of alt text

## Three-part structure (Amy Cesal's formula)

1. **Chart type** — first words identify the format
2. **Data description** — axes, variables, what is shown
3. **Key insight** — the pattern or takeaway (often found in surrounding text)

## Relationship to captions

Read the caption (`fig-cap`, `fig.cap`) first. Alt text should **complement, not duplicate** it:
- If the caption states the insight, alt text can focus on describing the visual structure
- If the caption is generic, alt text should include the key insight
- Together they should give a complete understanding

## Content rules

**Include:**
- Chart type as first words
- Axis labels and what they represent
- Specific values/ranges when code reveals them (e.g., "peaks between 25–50")
- Number of panels/facets
- What color/size encodes if used
- The key pattern that supports the surrounding point

**Exclude:**
- "Image of…" or "Chart showing…" (screen readers announce this)
- Decorative color descriptions (unless color encodes data)
- Information already in the caption
- Implementation details (package names, function internals)

## Length guidelines

| Complexity | Sentences | When to use                                  |
|------------|-----------|----------------------------------------------|
| Simple     | 2–3       | Single geom, no facets, obvious pattern      |
| Standard   | 3–4       | Multiple geoms or color encoding             |
| Complex    | 4–5       | Faceted, multiple overlays, nuanced insight  |

## Quality checklist

- [ ] Starts with chart type (Scatter chart, Histogram, Faceted bar chart, etc.)
- [ ] Names the axis variables
- [ ] Includes specific values/ranges from code when informative
- [ ] States the key insight from surrounding prose
- [ ] Complements (not duplicates) the caption
- [ ] Would make sense to someone who cannot see the image
- [ ] Uses plain language (avoid jargon like "geom" or "aesthetic")

## Template patterns

**Scatter chart:**
```
Scatter chart. [X var] along the x-axis, [Y var] along the y-axis.
[Shape: linear/curved/clustered]. [Specific pattern, e.g., "peaks when X is 25–50"].
[Any overlaid fits or annotations].
```

**Histogram:**
```
Histogram of [variable]. [Shape: right-skewed/bimodal/normal/uniform].
[If transformed: "after [transformation], the distribution [result]"].
[Notable features: outliers, gaps, multiple modes].
```

**Bar chart:**
```
Bar chart. [Categories] along the x-axis, [measure] along the y-axis.
[Key comparison: which is highest/lowest, relative differences].
[Pattern: increasing/decreasing/grouped].
```

**Tile/raster chart:**
```
Tile chart [or heatmap]. [Row variable] along the y-axis, [column variable] along the x-axis.
Color encodes [what value]. [Pattern: where values are high/low].
[If faceted: "N panels showing [what varies]"].
```

**Faceted chart:**
```
Faceted [chart type] with [N] panels, one per [faceting variable].
[What's constant across panels]. [What changes/varies].
[Key comparison or insight across panels].
```

**Correlation heatmap:**
```
Correlation [matrix/heatmap] of [what variables]. [Arrangement].
[Overall pattern: mostly positive/negative/mixed].
[Notable clusters or strong/weak pairs].
[If relevant: contrast with expected behavior].
```

**Before/after comparison:**
```
[N] [chart type]s arranged [vertically/in grid]. [Top/Left] shows [original].
[Bottom/Right] shows [transformed]. [Key difference/similarity].
[If overlay: "[color] curve shows [reference]"].
```

**Line chart with overlays:**
```
[Line/Scatter] chart with overlaid [fits/curves]. [Axes].
[Number] of [lines/fits] shown: [list what each represents].
[Which fits well vs. poorly and why].
```

## Example

**Code context:**
```r
plotting_data |>
  ggplot(aes(value)) +
  geom_histogram(binwidth = 0.2) +
  facet_grid(name~., scales = "free_y") +
  geom_line(aes(x, y), data = norm_curve, color = "green4")
```

**Surrounding prose says:** "Normalization doesn't make data more normal"

**Caption:** "Normalization doesn't make data more normal. The green curve indicates the density of the unit normal distribution."

**Good alt text:**
```
Faceted histogram with two panels stacked vertically. Top panel shows
original data with a bimodal distribution. Bottom panel shows the same
data after z-score normalization, retaining the bimodal shape. A green
normal distribution curve overlaid on the bottom panel clearly does not
match the data, demonstrating that normalization preserves distribution
shape rather than creating normality.
```
````

## File: alt-text/references/pkgdown.md
size: 4807
sha: cf8fe85d261c322e1ca3543d3bdb3e0f9b724729
upstream: https://github.com/posit-dev/skills/blob/main/alt-text/references/pkgdown.md

`````text
# Alt Text in pkgdown Sites

This reference covers how to find images and add alt text across a pkgdown site.

## Where images appear

| Location | Image type | Can have alt text? |
|----------|------------|-------------------|
| `vignettes/*.Rmd` or `vignettes/*.qmd` | code-generated plots | Yes — `fig.alt` chunk option |
| `vignettes/*.Rmd` | static images via `knitr::include_graphics()` | Yes — `fig.alt` chunk option |
| `README.Rmd` / `README.md` | code-generated plots | Yes — `fig.alt` chunk option |
| `README.Rmd` / `README.md` | markdown images `![](path)` | Yes — fill in the bracket |
| `README.Rmd` / `README.md` | HTML `<img src=...>` tags | Yes — add `alt="..."` attribute |
| `R/*.R` `@examples` | code-generated plots | **No — pkgdown limitation** |

There is currently no way to add alt text to plots generated in `@examples` blocks.
Focus effort on vignettes and README.

## Step 1 — Find missing alt text

### Find chunks missing fig.alt in vignettes

```bash
# Find chunks that already have fig.alt (to see what's covered)
grep -rn "fig\.alt\|fig-alt" vignettes/

# Find all plot-producing chunks — each one needs a fig.alt
grep -rn "ggplot\|geom_\|autoplot\|include_graphics" vignettes/
```

Compare the two lists to identify chunks with plots but no `fig.alt`.

### Find static images missing alt text

```bash
# Markdown images with empty alt: ![](path)
grep -rn "!\[\](" vignettes/ README.md README.Rmd

# All markdown images — review each for descriptive alt text
grep -rn "!\[" vignettes/ README.md README.Rmd

# HTML <img> tags — check each for a non-empty alt attribute
grep -rn "<img" vignettes/ README.md README.Rmd
```

Package logos are commonly written as HTML `<img>` tags at the top of
`README.Rmd`. Check that the `alt` attribute is present and descriptive:

```html
<!-- Missing alt -->
<img src='man/figures/logo.png' align="right" height="139" />

<!-- Fixed -->
<img src='man/figures/logo.png' align="right" height="139"
  alt="Package hex logo: a blue hexagon with the package name." />
```

## Step 2 — Audit quality of existing alt text

When alt text already exists, leave it alone unless it has a concrete problem.
Only rewrite alt text that fails one of these checks:

**Relative references** — alt text must be self-contained. Fix phrases like:
- "A plot identical to the one above…" → describe the plot fully
- "The same data as shown above…" → name the data explicitly

**Missing key information** — fix if alt text omits chart type, axis labels, or
the key pattern.

**Grammar and spelling errors** — alt text is read aloud by screen readers.

## Step 3 — Add fig.alt to Rmd chunks

The `fig.alt` chunk option works for both code-generated plots and static
images loaded with `knitr::include_graphics()`.

### Hashpipe syntax (preferred)

```r
#| fig.alt: >
#|   Scatter chart of bill length vs. bill depth for 344 penguins
#|   across three species. Gentoo penguins form a distinct cluster
#|   at higher bill depth. Adelie and Chinstrap overlap but separate
#|   along the bill length axis, with Chinstrap skewing higher.
plot_code_here()
```

### Knitr chunk option syntax

````markdown
```{r penguin-scatter, fig.alt="Scatter chart of bill length vs. bill depth..."}
plot_code_here()
```
````

### Multiple plots in one chunk

When a chunk produces multiple plots, `fig.alt` accepts a vector — one string
per plot, in order:

```r
#| fig.alt:
#|   - "Histogram of bill length. Right-skewed distribution with a peak at 45–50mm."
#|   - "Histogram of bill depth. Bimodal distribution with peaks at 15mm and 18mm."
```

## Step 4 — Add alt text to static markdown images

For `![](path)` images, fill in the bracket:

```markdown
<!-- Before -->
![](man/figures/logo.png)

<!-- After -->
![A hexagonal logo with a blue background and white text reading 'pkgdown'.](man/figures/logo.png)
```

For purely decorative images, leave the bracket empty intentionally and add a
comment:

```markdown
<!-- Decorative banner, intentionally no alt text -->
![](man/figures/decorative-banner.png)
```

## Step 5 — Verify

Because pkgdown does not warn about missing alt text in vignettes, verify by
re-running the same grep from Step 1 and confirming every plot-producing chunk
now has a `fig.alt`:

```bash
# Should list every chunk with a plot
grep -rn "ggplot\|geom_\|autoplot\|include_graphics" vignettes/

# Should now match the same chunks
grep -rn "fig\.alt\|fig-alt" vignettes/
```

For the home page, `build_site()` will warn if any README images are still
missing alt text.

## Quarto vignettes (`.qmd`)

For vignettes using Quarto format, use `fig-alt` (hyphen) instead of `fig.alt` (dot):

```r
#| fig-alt: >
#|   Scatter chart of bill length vs. bill depth for 344 penguins
#|   across three species.
```
`````

## File: alt-text/references/quarto.md
size: 1846
sha: 4ee83c025be06c3f4db2350fdd8b9a7c82c045b7
upstream: https://github.com/posit-dev/skills/blob/main/alt-text/references/quarto.md

````text
# Alt Text in Quarto Documents

This reference covers how to find figures and add alt text in `.qmd` files.

## Finding figures

```bash
# List all figure labels with file and line number
grep -n "#| label: fig-" *.qmd

# Find figures in a specific file
grep -n "#| label: fig-" my-document.qmd

# Find a specific figure
grep -rn "#| label: fig-splines-predictor-outcome" *.qmd
```

## For each figure

1. **Locate** — use grep to find file and line number
2. **Read context** — read ~50 lines around the chunk (prose before + code + prose after)
3. **Extract details** — note `fig-cap`, ggplot code, data generation, surrounding explanation
4. **Draft alt text** — apply the three-part structure from the main skill
5. **Verify** — check against the quality checklist

## Adding fig-alt

Use the hashpipe syntax inside the code chunk:

```r
#| label: fig-penguin-scatter
#| fig-cap: "Bill length vs. bill depth for 344 penguins."
#| fig-alt: >
#|   Scatter chart of bill length vs. bill depth for 344 penguins
#|   across three species. Gentoo penguins form a distinct cluster
#|   at higher bill depth. Adelie and Chinstrap overlap but separate
#|   along the bill length axis, with Chinstrap skewing higher.
plot_code_here()
```

Note: use `fig-alt` (hyphen) in `.qmd` files.

## Auditing existing alt text

When alt text already exists, leave it alone unless it fails one of these checks:

**Relative references** — alt text must be self-contained. Fix phrases like:
- "A plot identical to the one above…" → describe the plot fully
- "Much like the first one…" → stand-alone description

**Missing key information** — fix if alt text omits:
- Chart type as the first words
- Axis labels and what they represent
- The key pattern or takeaway

**Grammar and spelling errors** — alt text is read aloud by screen readers.
````

## File: README.md
upstream: https://github.com/posit-dev/skills/blob/main/README.md

````text
# Posit Agent Skills

A collection of Agent Skills from Posit!

[Agent Skills](https://agentskills.io) are an open standard for extending coding agents with specialized knowledge and workflows. Skills are automatically activated by your coding assistant based on your task, and work across many harnesses — including Posit Assistant, Claude Code, Codex, Cursor, Cline, and more. If you use Posit Assistant, see the [Posit Assistant skills documentation](https://assistant.posit.co/docs/features/skills.md).

## Available Skills

### Posit Developer

General-purpose developer skills useful across any language, project type, or context.

- **[critical-code-reviewer](./posit-dev/critical-code-reviewer/)** - Conduct rigorous, adversarial code reviews identifying security holes, lazy patterns, edge case failures, and bad practices across Python, R, JavaScript/TypeScript, SQL, and front-end code
- **[describe-design](./posit-dev/describe-design/)** - Research a codebase and create architectural documentation describing how features or systems work, with Mermaid diagrams and stable code references suitable for humans and AI agents
- **[new-work](./posit-dev/new-work/)** - Create a todo tracking document for a new feature, bug, or task; keeps it updated with decisions, plans, and progress for the rest of the session
- **[review-testing](./posit-dev/review-testing/)** - Review test code for quality, design, and completeness after implementing a feature or fixing a bug, covering assertion completeness, mocking boundaries, fixture design, test smells, and coverage gaps
- **[working-on](./posit-dev/working-on/)** - Set an existing tracking document as the source of truth for the current session, keeping it updated with decisions and progress

### GitHub

Skills for GitHub pull request workflows — creating PRs, addressing review feedback, and resolving threads.

- **[pr-create](./github/pr-create/)** - Creates a pull request from current changes, monitors GitHub CI, and debugs any failures until CI passes
- **[pr-threads-address](./github/pr-threads-address/)** - Review all unresolved PR review threads, address them by making necessary code changes, and commit the changes appropriately
- **[pr-threads-resolve](./github/pr-threads-resolve/)** - Bulk resolve unresolved PR review threads

### Open Source

Skills for open-source R and Python package developers, streamlining common workflows like releases, changelogs, and contributor acknowledgments.

- **[create-release-checklist](./open-source/create-release-checklist/)** - Create a release checklist and GitHub issue for an R package, with automatic version calculation and customizable checklist generation
- **[release-post](./open-source/release-post/)** - Create professional package release blog posts following Tidyverse or Shiny blog conventions, with support for both R and Python packages

### R Package Development

R package development skills for working with the r-lib ecosystem and modern R package workflows.

- **[r-tidyverse-style](./r-lib/r-tidyverse-style/)** - Review and clean up R package code using the tidyverse style guide, separating mechanical style changes from behavior-sensitive refactors
- **[r-testthat](./r-lib/r-testthat/)** - Best practices for writing R package tests using testthat 3+, including test structure, expectations, fixtures, snapshots, mocking, and BDD-style testing
- **[r-cli](./r-lib/r-cli/)** - Comprehensive guidance for using the cli R package for command-line interface styling, semantic messaging, and user communication with inline markup, progress indicators, and theming
- **[r-cran-extrachecks](./r-lib/r-cran-extrachecks/)** - Prepare R packages for CRAN submission by checking for common ad-hoc requirements not caught by `devtools::check()`, including documentation standards, DESCRIPTION field formatting, and URL validation
- **[r-lifecycle](./r-lib/r-lifecycle/)** - Manage R package lifecycle according to tidyverse principles using the lifecycle package, covering deprecation workflows, function/argument renaming, superseding, and experimental stages
- **[r-package-development](./r-lib/r-package-development/)** - R package development with devtools, testthat, and roxygen2, covering key commands, coding conventions, testing, documentation, and NEWS.md practices
- **[r-mirai](./r-lib/r-mirai/)** - Async, parallel, and distributed computing in R using mirai, covering explicit dependency passing, daemon setup, parallel mapping with `mirai_map()`, Shiny integration, remote/HPC launchers, and migration from future/parallel
- **[alt-text](./alt-text/)** - Generate and improve accessible alt text for data visualizations and images in pkgdown sites and Quarto documents, covering vignette code chunks (`fig.alt`), static markdown images, and multi-plot chunks

### ggsql

Skills for writing ggsql queries — a grammar of graphics for SQL.

- **[ggsql](./ggsql/ggsql/)** - Write ggsql queries — a grammar of graphics for SQL. Use when the user wants to create, modify, or understand a ggsql visualization query

### Shiny

Skills for Shiny app development in both R and Python.

- **[brand-yml](./brand-yml/)** - Create and apply brand.yml files for consistent styling across Shiny apps, with support for bslib (R) and ui.Theme (Python), including automatic brand discovery and theming functions for plots and tables
- **[shiny-bslib](./shiny/shiny-bslib/)** - Build modern Shiny dashboards using bslib with Bootstrap 5 layouts, cards, value boxes, navigation, theming, and modern inputs. Includes migration guide from legacy Shiny patterns
- **[shiny-bslib-theming](./shiny/shiny-bslib-theming/)** - Comprehensive theming for Shiny apps using bslib, covering bs_theme(), Bootswatch themes, custom colors, typography, Bootstrap Sass variables, custom Sass/CSS rules, dark mode, dynamic theming, and R plot theming

### Quarto

Skills for Quarto document creation and publishing.

- **[brand-yml](./brand-yml/)** - Create and apply brand.yml files for consistent styling across Quarto projects, supporting HTML documents, dashboards, RevealJS presentations, Typst PDFs, and websites with automatic brand discovery and theme layering
- **[authoring](quarto/README.md#quarto-authoring-skill)** - Comprehensive guidance for Quarto document authoring and R Markdown migration. Write new Quarto documents with best practices, convert R Markdown files, migrate bookdown/blogdown/xaringan/distill projects, and use Quarto-specific features like hashpipe syntax, cross-references, callouts, and extensions
- **[alt-text](./alt-text/)** - Generate and improve accessible alt text for figures in Quarto documents using Amy Cesal's three-part formula (chart type, data description, key insight). Supports code-generated plots and static images

### Connect

Skills for deploying and managing content on Posit Connect.

- **[deploy-to-connect](./connect/deploy-to-connect/)** - Deploy or publish Python and R content to a Posit Connect server using rsconnect-python or the R rsconnect package. Covers interactive apps and dashboards, web APIs, rendered documents, and prepared bundles/manifests

## Installation

### Using `npx skills add` (Any Agent)

Install skills from this repository into any supported coding agent (Claude Code, Codex, Cursor, Cline, and [many more](https://github.com/vercel-labs/skills)) using the `npx skills add` CLI:

```bash
# List available skills without installing
npx skills add posit-dev/skills --list

# Install skills via an interactive menu
npx skills add posit-dev/skills --all

# Install specific skills by category name
npx skills add posit-dev/skills --skill cli --skill lifecycle

# Install to Claude Code only, globally
npx skills add posit-dev/skills --agent claude-code --global
```

### Posit Assistant

Install skills into your Posit Assistant skills directory:

```bash
# User-level, shared with other harnesses that follow the Agent Skills spec
npx skills add posit-dev/skills --agent posit-assistant

# Or copy skills
````
