flutter-golden-testing

A workflow for Flutter golden tests, which compare a widget's rendered image with a saved reference image. It uses the Alchemist package and stores reference PNG files near the tests.

In plain words
What is it for?
Use it to create or update visual regression tests for Flutter widgets, including their test files, dependencies, mocks, and golden images.
Why use it?
It provides the setup and test structure needed to catch unintended visual changes in Flutter widgets. It also covers fonts, animations, and network images that can make image comparisons unreliable.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/anoopsg/agent_rules/flutter-golden-testing
Any agent
npx skills add anoopsg/agent_rules --skill flutter-golden-testing
Clone the repo
git clone --depth 1 https://github.com/anoopsg/agent_rules

Made for: Claude Code, Codex.

Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 546 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00025 $0.00546
Opus 5 $0.00013 $0.00273
Sonnet 5 $0.00005 $0.00109
Haiku 4.5 $0.00003 $0.00055

Measured 2d ago against content hash e8f8241f2a67, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

flutter-golden-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/exclusive/skills/flutter-golden-testing/SKILL.md · 42 lines

How it starts

The opening of the file, as written. The whole thing — 42 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Flutter Golden Testing Skill

This skill outlines the step-by-step process for implementing and updating golden tests for Flutter widgets.

Step 1: Validation & Setup

  1. Check Dependencies: Ensure alchemist is present in the dev_dependencies of pubspec.yaml. If it is missing, install it:
    flutter pub add --dev alchemist
    
  2. Directory Structure: Create a goldens/ directory adjacent to your target test file to store the generated .png reference files.

Step 2: Test Scaffolding

Create the test file named [widget_name]_test.dart (or [widget_name]_golden_test.dart).

  1. Imports: Import the necessary packages (package:flutter_test/flutter_test.dart and package:alchemist/alchemist.dart).
  2. Setup Fonts/Assets: Call loadAppFonts() (if applicable) before running the tests to prevent text from rendering as the Ahem font.

Step 3: Implementation

Implement the test using alchemist APIs instead of the standard testWidgets.

  1. Use goldenTest: Define your test using the goldenTest function.
  2. Mock Externalities:
    • Disable or replace infinite animations (e.g., CircularProgressIndicator).
    • Mock network image requests (e.g., using mocktail_image_network or network_image_mock).
  3. Matrix Testing: Use GoldenTestGroup and GoldenTestScenario to lay out all possible widget states (e.g., loading, success, error) and variations (light/dark mode, text scaling) within a single test execution.

Step 4: Generation and Verification

  1. Generate Goldens: Run the following command to generate or update the reference images:
    flutter test --update-goldens
    
  2. Verify Output: Check that the .png files were correctly generated in the goldens/ directory.
  3. Gitignore Failures: Ensure **/failures/ is in the project's .gitignore so test failure artifacts are not accidentally committed.

Step 5: Updating Existing Goldens

If you are modifying an existing widget that already has golden tests, run the update command (flutter test --update-goldens) to regenerate the images. Never modify the .png files manually.

Read the full file on GitHub · 42 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 42 lines · 25 tokens per session scan A e8f8241f2a67

Subscribe to this mod's changes

flutter-golden-testing is a skill published in the GitHub repository anoopsg/agent_rules (2 stars, last pushed 1mo ago), licensed MIT. It adds 25 tokens to every session and 546 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

technical-debt

Technical debt inventory, prioritization, and audit for PHP/Laravel (MySQL) and Node/TypeScript/React projects. Use when assessing code health, identifying refactoring candidates, planning debt paydown, or auditing a codebase for accumulated debt. Triggers on "audit technical debt", "find tech debt", "debt inventory"…

AsyrafHussin/agent-skills · 109 tokens

code-slop

Detect AI-generated code patterns ("slop") in PHP/Laravel and TypeScript/React source — comment narration, generic naming, premature interfaces, defensive overdose, mock-everything tests, and the absence of human "scars". Use when reviewing AI-assisted PRs, auditing code for taste/quality (not metrics — that's…

AsyrafHussin/agent-skills · 110 tokens

git-workflow

Git best practices, branching strategies, commit conventions, and PR workflows. Use when reviewing git history, writing commits, setting up branching strategy, or improving git practices. Triggers on "git best practices", "commit message", "branching strategy", or "PR workflow".

AsyrafHussin/agent-skills · 59 tokens

laravel-inertia-react

Laravel + Inertia.js + React integration patterns. Use when building Inertia page components, handling forms with useForm, managing shared data, or implementing persistent layouts. Triggers on tasks involving Inertia.js, page props, form handling, or Laravel React integration.

AsyrafHussin/agent-skills · 59 tokens

laravel-owasp-security

OWASP Top 10 security audit and secure coding guidelines for Laravel + React/Inertia.js applications. Use when auditing for vulnerabilities ("run OWASP audit", "security review", "check my app security") or writing secure Laravel code involving auth, payments, file uploads, or API design. Triggers on security-related…

AsyrafHussin/agent-skills · 87 tokens

project-docs

Project documentation lifecycle for PHP/Laravel and Node/TypeScript/React projects — bootstrapping essential docs, naming and folder conventions, freshness, and cleanup of AI-generated junk and stale files. Use when starting a new project, setting up docs/ structure, auditing markdown files, cleaning up the docs…

AsyrafHussin/agent-skills · 115 tokens