Skip to content
Skills Library
Programming · Testing

using-metal-validation

/using-metal-validation

ALWAYS use when a user wants to enable, configure, or run Metal validation — API validation (MTL_DEBUG_LAYER) for CPU-side API misuse, shader validation (MTL_SHADER_VALIDATION) for GPU-side memory errors, or the load/store-action visual indicators. Trigger when working with Metal validation (MTL_DEBUG_LAYER, MTL_SHADER_VALIDATION, the validation layer, API validation, MTL_DEBUG_LAYER_VALIDATE_LOAD_ACTIONS, MTL_DEBUG_LAYER_VALIDATE_STORE_ACTIONS, per-pipeline validation, MTL4PipelineOptions.shaderValidation, validation perf hit), or when encountering symptoms like shader validation errors not a

Author
apple ↗
Licence
Apache-2.0
Last repository change
07.06.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 07.06.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

ALWAYS use when a user wants to enable, configure, or run Metal validation — API validation (MTL_DEBUG_LAYER) for CPU-side API misuse, shader validation (MTL_SHADER_VALIDATION) for GPU-side memory errors, or the load/store-action visual indicators. Trigger when working with Metal validation (MTL_DEBUG_LAYER, MTL_SHADER_VALIDATION, the validation layer, API validation, MTL_DEBUG_LAYER_VALIDATE_LOAD_ACTIONS, MTL_DEBUG_LAYER_VALIDATE_STORE_ACTIONS, per-pipeline validation, MTL4PipelineOptions.shaderValidation, validation perf hit), or when encountering symptoms like shader validation errors not a

Original author description

ALWAYS use when a user wants to enable, configure, or run Metal validation — API validation (MTL_DEBUG_LAYER) for CPU-side API misuse, shader validation (MTL_SHADER_VALIDATION) for GPU-side memory errors, or the load/store-action visual indicators. Trigger when working with Metal validation (MTL_DEBUG_LAYER, MTL_SHADER_VALIDATION, the validation layer, API validation, MTL_DEBUG_LAYER_VALIDATE_LOAD_ACTIONS, MTL_DEBUG_LAYER_VALIDATE_STORE_ACTIONS, per-pipeline validation, MTL4PipelineOptions.shaderValidation, validation perf hit), or when encountering symptoms like shader validation errors not a

How it works

  1. Overview
  2. Step 1: Read the man page
  3. Step 2: Quick-start
  4. Step 3: Things easy to miss
Original SKILL.md headings · 37 lines, 240 words
SKILL.md preview
---
name: using-metal-validation
description: ALWAYS use when a user wants to enable, configure, or run Metal validation — API validation (MTL_DEBUG_LAYER) for CPU-side API misuse, shader validation (MTL_SHADER_VALIDATION) for GPU-side memory errors, or the load/store-action visual indicators. Trigger when working with Metal validation (MTL_DEBUG_LAYER, MTL_SHADER_VALIDATION, the validation layer, API validation, MTL_DEBUG_LAYER_VALIDATE_LOAD_ACTIONS, MTL_DEBUG_LAYER_VALIDATE_STORE_ACTIONS, per-pipeline validation, MTL4PipelineOptions.shaderValidation, validation perf hit), or when encountering symptoms like shader validation errors not appearing, fuchsia color render artifacts, the red/white checkerboard, or zerofill output. Do NOT trigger for general rendering bug diagnosis where validation isn't the relevant tool.
---

# Using Metal Validation

## Overview

Metal provides two validation modes, both configured via environment variables read at `MTLDevice` creation:

- **API validation** (`MTL_DEBUG_LAYER`) — CPU-side. Cheap; enable broadly during development.
- **Shader validation** (`MTL_SHADER_VALIDATION`) — GPU-side. Potentially significant perf cost; enable selectively or per-pipeline.

Env vars must be set **before** any `MTLDevice` is created. Changes after device creation have no effect.

## Step 1: Read the man page

The man page is the authoritative reference for all env vars, their valid mode values, and pipeline scoping syntax. Read it before configuring anything beyond the quick-start:

```sh
man MetalValidation | col -b
```

## Step 2: Quick-start

```sh
open -a MyGame.app \
    --env MTL_DEBUG_LAYER=1 \
    --env MTL_SHADER_VALIDATION=1 \
    --env MTL_SHADER_VALIDATION_REPORT_TO_STDERR=1
```

## Step 3: Things easy to miss

The man page documents every variable, but a few workflow points are easy to miss:

- **Launch `.app` bundles via `open --env`, instead of invoking the binary inside the bundle directly** (e.g., `MyGame.app/Contents/MacOS/MyGame`). Use `open -a MyGame.app --env KEY=VALUE` (one `--env` per variable) for every run that needs validation.
- **Shader validation errors go to the system log by default, NOT stderr.** Without `MTL_SHADER_VALIDATION_REPORT_TO_STDERR=1`, errors are invisible from a terminal-launched build. Always pair the two.
- **Per-pipeline scoping for ship-grade builds.** If global `MTL_SHADER_VALIDATION=1` is too expensive, set `MTL4PipelineOptions.shaderValidation = MTLShaderValidationEnabled` on the descriptor for shaders under active iteration. Env-var allow-list / deny-list (`MTL_SHADER_VALIDATION_ENABLE_PIPELINES` / `_DISABLE_PIPELINES`) is the equivalent for pre-Metal-4 codebases.

Versions

The database has no other skills named using-metal-validation.

Database snapshot: 13.11.2026 · package version 2899f09896de (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100creating-metal4-shader-pipelines
    ALWAYS use when creating Metal pipeline state objects with Metal 4 descriptors (MTL4RenderPipelineDescriptor, MTL4ComputePipelineDescriptor, MTL4MeshRenderPipelineDescriptor) via MTL4Compiler. Covers function descriptors, function constant specialization, flexible/unspecialized…
  • 90gpu-rendering-guide
    Use when designing the architecture of a low-level GPU renderer on any explicit API (Vulkan/D3D12/Metal/WebGPU): render/frame graphs, shader/permutation systems, the descriptor/binding model, explicit GPU↔CPU synchronization, command recording and frames-in-flight, and GPU…
  • 100shader-effects-qa
    Use to validate visual shader effects, screenshots, color correctness, regressions and GPU budgets; not write base GLSL pipelines.
  • 100glsl-to-metal
    Convert GLSL fragment shaders and Shadertoy effects into Metal for iOS and macOS, using SwiftUI stitchable shaders where suitable and a Metal renderer when needed. Use for shader ports or explicitly requested reconstructions of web shader effects.
  • 95translating-to-metal4-api
    ALWAYS use as the Metal 4 API reference and cross-API translation map when porting graphics code to Metal 4 — translating Metal 3, D3D12, or Vulkan calls, looking up any MTL4 / Metal 4 API or renamed type, finding the Metal 4 equivalent of a source-API call, or learning what the…
  • 100metal-game-rendering-workflow
    Guide native Apple game and custom-renderer work with Metal 3 and Metal 4. Use when Codex owns MTKView, CAMetalLayer, drawable presentation, render passes, command encoding, MSL shaders, pipeline states, GPU resources, Metal capability fallback, GPU capture, or renderer…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.