/flutter:seeded-determinism-and-golden-vectorsfrom Flutter Skills
Enforces reproducible derived content as a pure function of a key, with rules for seed generation, PRNG ownership, and golden-vector fingerprint tables. Use when generating content from seeds or dates, versioning generators, or debugging cross-device output differences.
Ships in Flutter Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Some output must be a pure function of a key: the daily pick every user compares with their friends, a procedurally generated layout, a shareable result someone else can verify. It has to come out identical on every device, in every timezone, on the platform build you ship next year — with no server to arbitrate. That is a stronger property than "the tests pass", and it needs its own discipline plus a frozen oracle to keep it.
testing-strategy owns how you test pure logic (seeded fuzz against an independent oracle, injected
Clock). This skill owns what makes the output reproducible in the first place, and the committed
vector table that pins it.
A golden vector is not a golden image. Vectors are data fingerprints for a pure generator,
asserted by dart test with no widget binding; reference PNGs of rendered UI belong to
widget-golden-and-a11y-testing, and re-blessing them is the separate ritual in
run-goldens-rebaseline. The two share only the word "golden" and the rule that a gate must never
regenerate what it checks.
The key is injected, never read. A generator takes its key as an argument — a date string, an
id, a sequence number. Nothing reachable from it calls DateTime.now(). Wall-clock time enters
the app exactly once, through the injected Clock at the composition root
(value-objects-money-and-units owns that rule). WHY: a generator that reads a clock is
untestable and un-golden-able, and its output cannot be reproduced from a bug report.
A calendar-day key is a civil date, not an instant. "The 4th of July" is a date-only value —
store and pass it as one (an ISO YYYY-MM-DD string or a day serial), never as a DateTime
instant. An event timestamp is still a UTC instant; a day identity is not a moment in time at
all. WHY: an instant makes every read timezone-dependent, so two devices disagree about which
content is "today's".
One day definition, used everywhere it is compared. If content is derived from a UTC day while a streak, deadline, or "already seen" check uses local midnight, the two disagree for hours every day near the boundary. Pick local or UTC deliberately, name it once, and route every comparison through that one definition.
Entropy has exactly one source: a seed you derived. No ambient Random()/Random.secure()
anywhere on the generation path — not even for a "harmless" tiebreak or shuffle. Every draw is an
explicit call on the seeded generator you threaded in, and the order of draws is part of the
contract: reordering two draws changes every output after it.
Derive the seed with a specified hash and a mix step. Hash the key string (FNV-1a-64 is
small, specified and easy to reimplement), XOR in a per-feature and per-mode salt, then pass the
result through an avalanche/mix step (SplitMix64) before drawing from it. WHY: consecutive keys
differ by one byte, and without a mix step that correlation shows up as visibly similar output on
consecutive days — the bug users notice first. See references/seed-derivation.md.
Own the PRNG; do not depend on an unspecified one. dart:math's Random(seed) is reproducible
within a given runtime, but its algorithm is an implementation detail with no documented stability
guarantee across SDK versions or platforms. Output a user will compare with another user's must not
rest on that. SplitMix64 is eight lines; write it, test it against published vectors, and freeze it.
Salt per feature and per mode. Two features seeded from the same date must not draw the same sequence, or their outputs correlate visibly. One salt constant per feature, frozen forever once shipped.
Regenerate derived content; never store it. Persist the key, the generatorVersion, and
the outcome (what the user did). The content itself is key → generator → content, rebuildable
forever. WHY: storing it doubles the source of truth and makes history un-migratable. Derived
aggregates are likewise recomputed on read — persistence-drift owns that rule.
A shipped generator is frozen. The moment users have seen output for a key, that output is what that key means. An improvement ships as a new version with a cutover key, with the old version kept in the binary to reproduce everything before it. Never edit a shipped generator in place: it silently rewrites what the past was, and every stored outcome now refers to content that no longer exists.
Pin the contract with golden vectors. A committed table of (key, params) → fingerprint rows,
plus whatever derived metrics the UI shows, asserted exactly. Store a fingerprint (a stable
hash of the canonical serialization), not the whole artifact, so the table stays small and a real
change is a one-line diff a reviewer can actually see. == for integers and fingerprints;
tolerance only for a deliberately calibrated float.
Compute every expected value from an independent oracle. A fixture generated by the
implementation under test enshrines that implementation's bugs — including the one you are about
to introduce. Derive vector rows from a separate, simpler, slower implementation, or by hand.
(testing-strategy owns the independent-oracle principle for fuzz loops; this is its frozen-table
half.)
Regeneration is explicit, reviewed, and never automatic. Vectors are refreshed only by a
deliberate local command whose diff a human reads in the pull request. CI verifies and never
blesses — a pipeline that regenerates its own expectations is a gate that checks nothing, the
same failure as running --update-goldens in CI.
Measured, then labeled — never marketed as a proof. Where a generated artifact carries a derived label (a difficulty, a quality tier, a size class), the metric is computed and the label is a frozen threshold table over it. Assert that the mapping is monotonic and that the thresholds have not moved; do not describe a calibration as proven, and never re-label content that already shipped.
/// FNV-1a-64 over the key's UTF-8 bytes. Small, specified, trivially portable.
int fnv1a64(String key) {
var hash = 0xcbf29ce484222325;
for (final byte in utf8.encode(key)) {
hash = (hash ^ byte) * 0x100000001b3; // 64-bit wrap-around is intended
}
return hash;
}
/// The one entropy source. SplitMix64 — eight lines, published test vectors,
/// and yours forever, unlike an SDK-internal generator.
class SeededRng {
SeededRng(this._state);
int _state;
int nextInt64() {
_state += 0x9e3779b97f4a7c15;
var z = _state;
z = (z ^ (z >>> 30)) * 0xbf58476d1ce4e5b9;
z = (z ^ (z >>> 27)) * 0x94d049bb133111eb;
return z ^ (z >>> 31);
}
/// Uniform in [0, max). Draw order is part of the contract — never reorder.
int nextInt(int max) => nextInt64().toUnsigned(63) % max;
}
/// The only place the calendar meets a generator. `isoDay` is a civil date
/// ("2026-07-04") supplied by the caller — the generator never reads a clock.
SeededRng seedFor(String isoDay, {required int featureSalt, int modeSalt = 0}) =>
SeededRng(fnv1a64(isoDay) ^ featureSalt ^ modeSalt);
⚠️ If the app also builds for web, 64-bit integer arithmetic does not behave this way — Dart
integers compile to JavaScript doubles there. Either restrict this code to native targets or
implement the hash and PRNG in 32-bit halves. See references/seed-derivation.md.
// One row per pinned key. Computed ONCE from an independent oracle (rule 11) and
// refreshed only by `dart run tool/update_vectors.dart` (rule 12).
const dailyPickVectors = <DailyPickVector>[
DailyPickVector('2026-01-01', 0x9f3ac1e0, 12, 'year boundary'),
DailyPickVector('2026-07-04', 0x2b7708d4, 3, 'mid-year'),
DailyPickVector('2026-12-31', 0x84ce11a9, 7, 'year end'),
];
test('the generator reproduces every frozen vector', () {
for (final v in dailyPickVectors) {
final pick = generateDailyPick(v.isoDay);
expect(pick.fingerprint(), equals(v.fingerprint), reason: v.note);
expect(pick.items.length, equals(v.itemCount), reason: v.note);
}
});
Cover the boundaries a bug would hide behind: the first and last key you support, a leap day, a month/year rollover, and at least one historical key so a regression that rewrites the past fails loudly.
DateTime.now() inside a generator or a seed helper — the output stops being reproducible and
cannot be regenerated from a bug report.DateTime instant used as a day identity — every read becomes timezone-dependent.Random() for a "harmless" tiebreak — one call and the whole contract is gone.Random(seed), identityHashCode, or hash-set iteration order for anything a user
sees — no documented stability guarantee; sort by an explicit key before drawing.(key, generatorVersion, outcome) and regenerate.hash(key) ^ featureSalt ^ modeSalt through a mix step, into a PRNG the repo owns.(key, generatorVersion); only the key, version and outcome persist.generatorVersion is stored with every outcome; a generator change ships as a new version with
a cutover, and the previous version stays able to reproduce history.scripts/check-determinism-bans.sh is green over the generator's package/directory.testing-strategy for seeded fuzz loops, the independent-oracle principle, and injecting
Clock — this skill's tests are that shape.value-objects-money-and-units for canonical storage and the injected Clock seam.persistence-drift for storing the key/version/outcome and recomputing derived aggregates.project-structure-and-packages for keeping the generator in a Flutter-free package where these
bans are mechanically enforceable.widget-golden-and-a11y-testing for reference images of rendered UI, and
run-goldens-rebaseline for the ritual that re-blesses them — a different tier from these vectors.ci-pipeline-and-gates for running the vector check and the ban grep as gates.dart3-idioms-and-coding-standards for the immutable value types the generator returns.dart:math Random (seeded construction): https://api.dart.dev/stable/dart-math/Random-class.htmlint as JS double, >>>, overflow): https://dart.dev/guides/language/numbersidentityHashCode: https://api.dart.dev/stable/dart-core/identityHashCode.htmlpackage:test: https://pub.dev/packages/testWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub zakariaf/flutter-skills --plugin flutter40 skills in this plugin
/accessibility-as-codeEnforces accessibility as a correctness property authored into each widget — Semantics(button/label) or ExcludeSemantics on every node, a11y state read from MediaQuery not app state, never MediaQuery.withClampedTextScaling / textScaleFactor / FittedBox / TextOverflow.ellipsis to fit a label, non-color redundant channels (icon+label+shape+text) for every state, contrast against composited backgrounds (4.5:1 body / 3:1 large), 44px single-tap targets, OrdinalSortKey traversal, and honoring boldText / reduce-motion. Use when adding a GestureDetector/InkWell or any tap target, adding an Icon or Image, reaching for withClampedTextScaling/FittedBox/ellipsis/textScaleFactor to make text fit, encoding state via color, sizing type, ordering focus traversal, or reviewing any View for screen-reader/switch/low-vision support./adaptive-layoutEnforces adapting layout by available CONSTRAINTS/size, never device or platform checks — LayoutBuilder + MediaQuery.sizeOf/paddingOf/viewInsetsOf (not .of) for narrow rebuilds, Material 3 window size classes (compact <600, medium 600-840, expanded 840-1200, large >1200) as the breakpoint vocabulary, navigation affordance chosen by width (NavigationBar → NavigationRail → NavigationDrawer), list-detail single-pane-vs-two-pane, readable max-width via ConstrainedBox, Flexible/Expanded/FractionallySizedBox over fixed widths, SafeArea + display cutouts + keyboard insets, never lock orientation, foldable/hinge awareness via MediaQuery.displayFeatures, and golden-matrix verification across sizes. Use when building responsive or adaptive UI, tablet/desktop/foldable support, master-detail or two-pane screens, a NavigationRail-vs-BottomNav shell, breakpoints, LayoutBuilder, MediaQuery sizing, SafeArea/cutouts, or fixing overflow at large widths./ads-and-iap-monetizationEnforces opt-in, rewarded-first monetization over the service seam — a rewarded view grants exactly one benefit and only on a genuine reward outcome (a sealed Rewarded/Dismissed/NoFill), earn loops capped per day against an injected Clock, the earn control preloaded and hidden unless an ad is loaded so a fresh account never dead-ends on "no ads available" (a Guideline 2.1 risk), interstitials only at a natural break under a count-and-elapsed cap owned by the service so callers stay dumb, no banner on the primary work surface, one non-consumable unlock plus Restore re-checked each launch and committed through the single write path before the UI reacts, one derived isEntitled provider as the only gate, and the entitlement restored BEFORE the ad SDK initializes so a paying user never starts it, resolves consent, or sees a tracking prompt. Use when adding ads, wiring a rewarded earn loop, placing an interstitial, building a paywall, gating an entitlement, or setting up ad units./app-startup-and-bootstrapEnforces a fixed main() cold-launch order — crash-log sink + FlutterError.onError + PlatformDispatcher.onError installed BEFORE any code that can throw, settings/theme read before runApp so the first frame paints correct, real infra constructed in a composition-root bootstrap() and injected via ProviderScope overrideWithValue over throwing placeholder providers, non-blocking warm-up deferred to addPostFrameCallback, exactly two error handlers with NO runZonedGuarded, ProviderException unwrapped before logging, and a WidgetsBindingObserver that flushes durable state on background/resume. Use when editing lib/main.dart, main_<flavor>.dart, bootstrap.dart or app.dart, reordering anything in main(), adding a splash/onboarding/permission gate, restoring theme before first paint, wiring a DB or service into ProviderScope, handling app-lifecycle background/resume flushes, or chasing cold-start latency, ANRs, or first-frame jank./async-safetyEnforces no-silent-failure async discipline in Flutter/Dart — the arrow-callback Future-drop hole no lint catches (`onTap: () => vm.save(x)`), void-returning event handlers, a mounted/ref.mounted guard after EVERY await before touching BuildContext, capturing Navigator/ScaffoldMessenger before the gap, honest `unawaited()` that always ends in catchError, no empty/bare catches, `rethrow` over `throw e`, and disposing every StreamSubscription/StreamController/Timer/sink. Use when writing or reviewing async/await, wiring onTap/onPressed/onSubmitted or any VoidCallback, touching BuildContext after an await, writing initState/dispose/addPostFrameCallback, adding a Timer or Future.delayed, writing a try/catch, or seeing use_build_context_synchronously, cancel_subscriptions, close_sinks, unawaited_futures, or discarded_futures./ci-pipeline-and-gatesEnforces a lean GitHub Actions Flutter CI where every gate maps to one named release-blocking contract — pinned runner + subosito/flutter-action@v2 toolchain, dart format --set-exit-if-changed, flutter analyze --fatal-infos, build_runner and drift schema freshness (git diff --exit-code), flutter test --test-randomize-ordering-seed random, static import/banned-string greps that catch what runtime can't, coverage-as-report-never-a-gate with the upward-lie fixed, verify-never-bless goldens (no --update-goldens in CI), and an honest statement of what CI cannot prove (audio, real fonts, on-device behaviour). Use when editing .github/workflows/*.yml, adding or removing a job or step, wiring a codegen/schema/format/analyze/coverage gate, writing a grep-based policy test or gate script under test/policy or tool/, pinning action versions, or claiming CI proves something it can't.Other plugins' skills for the same job