Add or update reference images

VerifiedSafe

Workflow for adding reference-image tests in Lodestone or updating reference images after an intended rendering change.

Sby Skills Guide Bot
TestingIntermediate
10/21/2026
Claude CodeCodexCursor
#reference-images#rendering#doctest#lavapipe#visual-regression

Recommended for

Automated summary

This skill explains how to add a reference-image rendering test in the Lodestone project, or to deliberately update reference images after an intended rendering change.

Strengths

  • Provides a concrete C++ test template (doctest, `ReferenceImages` suite, `Testing::CheckReferenceImage`) that can be adapted directly
  • Documents the regeneration workflow precisely with `LS_UPDATE_REFERENCE_IMAGES=1` and `ctest -L render -R`, including the PowerShell variant
  • States a clear safety rule: never regenerate an image just to make a failing test pass, and always inspect the new image before committing
  • Explains failure triage using the generated `.actual.png` and `.difference.png` files and the CI artifact download

Limitations

  • Heavily tied to the Lodestone repository (paths like `Tests/Render`, `Tests/ReferenceImages`, Git LFS, pinned lavapipe) and not reusable as-is elsewhere
  • Not usable on macOS: creating or checking reference images requires Windows or Linux with lavapipe
  • Visual verification stays manual — nothing automatically proves the new image is correct
When to use it

Use it when a rendering feature needs image coverage, or when a reference-image test fails because rendering was intentionally changed.

When not to use it

Do not use it to force a passing test whose failure points to a genuine rendering bug, nor for non-graphical tests or projects outside Lodestone.

Security analysis

Safe
Quality score88/100

The skill is documentation for a normal rendering-test workflow. It involves standard build/test commands, Git LFS reference images, and optional CI artifact download, but contains no destructive, exfiltrating, obfuscated, or safety-disabling instructions. It explicitly warns against regenerating images just to make tests pass and scopes image updates to specific tests.

No concerns found

How this analysis is made

Examples

Add a reference-image test
Add a reference-image test for our new soft-shadow rendering in Tests/Render, using a fixed 256x256 offscreen target, fixed camera and seed, then generate and inspect the image before committing it.
Triage a failing reference image
My 'SoftShadows' reference-image test is failing after I changed shadow sampling. Look at the .actual.png and .difference.png in build/debug/RenderOutput and help me decide whether the code or the reference image is wrong.
Regenerate after intended change
I intentionally changed the tone mapping, so the reference images need updating. Walk me through running only the affected render tests with LS_UPDATE_REFERENCE_IMAGES=1 and writing the commit message.

name: update-reference-images description: Add a reference-image test to Lodestone, or deliberately update reference images after an intended rendering change. Use when a rendering feature needs image coverage, or a reference-image test fails because rendering was meant to change.

Add or Update Reference Images

Reference images are the expected output of rendering tests, compared on lavapipe at the Mesa version pinned in tools/lavapipe.env (see docs/Testing.md#reference-images and docs/Decisions/0009-lavapipe.md). They live in Tests/ReferenceImages and are stored with Git LFS.

Never regenerate a reference image to make a failing test pass. Update one only when rendering is meant to change, and only after confirming the new image is right. If a test fails and the change wasn't meant to alter rendering, the code is wrong, not the image.

Prerequisites

lavapipe must be available, or reference-image tests are skipped: on Windows CMake downloads it; on Linux build it with tools/build-lavapipe.sh and reconfigure. macOS can't create or check reference images - use Windows or Linux.

Add a reference-image test

  1. Write the test in Tests/Render (in LodestoneRenderTests), in the ReferenceImages test suite so it's left out where lavapipe isn't available:
    TEST_CASE("Shadows soften with distance" * doctest::test_suite("ReferenceImages"))
    {
    	// Render offscreen into a texture, then:
    	const auto image = ReadTexture(nvrhiDevice, target);
    	REQUIRE_MESSAGE(image.has_value(), fmt::format("{}", image.error()));
    	Testing::CheckReferenceImage("SoftShadows", *image);
    	CHECK(device->GetValidationErrorCount() == 0);
    }
    
    Use small, fixed image sizes (256x256 is plenty for most features), and a fixed camera, time and random seed, so the image is deterministic.
  2. Keep the default tolerance (ImageTolerance) unless the feature needs another, and say why in a comment if it does.
  3. Generate the image (below), look at it, and commit it with the test.

Generate or update images

  1. Build, then run the rendering tests with LS_UPDATE_REFERENCE_IMAGES=1. Limit the run to the tests whose images should change:
    cmake --build --preset debug
    LS_UPDATE_REFERENCE_IMAGES=1 ctest --preset debug -L render -R "<test name pattern>"
    
    In PowerShell: $env:LS_UPDATE_REFERENCE_IMAGES = '1', run ctest, then Remove-Item Env:LS_UPDATE_REFERENCE_IMAGES.
  2. Look at every new or changed image in Tests/ReferenceImages (git status). Check it shows exactly what the feature should render - this is the only review the image gets.
  3. Run the rendering tests again without the variable; they must pass.
  4. Commit the images with the code change. The commit message says which images changed and why (for a Mesa update: the old and new versions).

When a reference-image test fails

The test writes <name>.actual.png and <name>.difference.png (mismatched pixels in red) to build/<preset>/RenderOutput; CI uploads the same files as an artifact (gh run download <run id>). Look at both before deciding whether the code or the image is wrong.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/add-or-update-reference-images-mvda8720' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-or-update-reference-images-mvda8720/download' --output '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md.part' && mv '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md.part' '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Prerequisites

lavapipe must be available, or reference-image tests are skipped: on Windows CMake downloads it; on Linux build it with tools/build-lavapipe.sh and reconfigure. macOS can't create or check reference images - use Windows or Linux.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && test -s '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/update-reference-images' && cp -R '.skill-downloads/add-or-update-reference-images-mvda8720' '.claude/skills/update-reference-images'

Cursor
test -f '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && test -s '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/update-reference-images' && cp -R '.skill-downloads/add-or-update-reference-images-mvda8720' '.cursor/skills/update-reference-images'

Codex
test -f '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && test -s '.skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/update-reference-images' && cp -R '.skill-downloads/add-or-update-reference-images-mvda8720' '.agents/skills/update-reference-images'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/add-or-update-reference-images-mvda8720'

openskills read 'add-or-update-reference-images-mvda8720'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/add-or-update-reference-images-mvda8720/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills