/flutter:ci-pipeline-and-gatesfrom Flutter Skills
Enforces a lean GitHub Actions Flutter CI where every gate maps to one named release-blocking contract. Use when editing workflow YAML, adding/removing jobs, wiring codegen/schema/format/analyze/coverage gates, writing grep-based policy tests, or pinning action versions.
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.
A CI gate is not a decorative green check — it converts one release-blocking contract into a check a build either passes or fails, without trusting a human. Keep the pipeline lean: one workflow file for most single-package apps, every job pinned, every gate traceable to a named contract, and an honest note wherever CI cannot prove the thing that actually matters.
Read the reference for the task at hand:
references/workflow-skeleton.md — the copy-paste single-file ci.yml: pinned runner + toolchain, freshness gates, format/analyze, randomized tests, host-sqlite, coverage-strip, and the release-build job.references/policy-grep-gate.md — the grep-based invariant gate: the three-criteria bar, strip-comments-first, anchor-to-structure, accumulate-and-fail-once, write-the-reason-for-a-stranger.Run scripts/ci-gates.sh and scripts/banned-strings.sh before a PR to reproduce the static gates locally.
runs-on: ubuntu-24.04 (never -latest — image drift moves lcov/toolchain versions with no diff to review) and subosito/flutter-action@v2 with an explicit flutter-version or flutter-version-file, channel: stable. A floating SDK silently re-renders goldens and perturbs determinism. Bump the version only in a dedicated PR.# VERIFY: next to a version you haven't confirmed rather than guessing @v7.dart format --output=none --set-exit-if-changed . and flutter analyze --fatal-infos. --fatal-infos is load-bearing: an info left unfixed is a warning that gets ignored next. See lint-and-style-config.git diff --exit-code the outputs; a nonzero diff fails with a message telling the author to regenerate and commit. This is the entire mitigation for committing generated code, and the one gate that catches "changed the schema, forgot to migrate". See run-codegen, run-migration.flutter test --test-randomize-ordering-seed random is free detection of inter-test state leakage. On Linux, flutter test runs in a plain Dart VM where sqlite3_flutter_libs does nothing — install host sqlite3 before a suite that opens a real DB, or it fails for a reason that looks like a broken repo.references/policy-grep-gate.md). It proves properties of the source graph a passing test never can (an import that isn't reached at runtime, a manifest attribute). Two out of three criteria means code review, not a grep.flutter test --coverage omits files no test imports, so an untested file scores zero denominator lines, not 0% — one tested file can report ~100%. Include untested files, then strip generated code from lcov.info. See testing-strategy.--update-goldens, no dart format --fix, no committing regenerated code from CI — a gate that fixes the thing it checks asserts nothing. Regeneration is a local, human-reviewed act. Goldens run on the pinned runner and CI only compares. See widget-golden-and-a11y-testing.continue-on-error: true on a gate, never merge on a skipped gate, never // ignore: a static finding. And state plainly what CI cannot prove — audio output, real-font rendering, true on-device behaviour — so the manual on-device pass is treated as a load-bearing release artifact, not a chore.One file, .github/workflows/ci.yml, is enough for most apps. Pin everything; keep the fast feedback in one job.
name: ci
on:
push: { branches: [main] }
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-24.04 # pinned, not -latest — rule 2
timeout-minutes: 20
steps:
- uses: actions/checkout@v4 # VERIFY: confirm current major
- uses: subosito/flutter-action@v2 # v2 is current; there is no v3
with:
channel: stable
flutter-version: '3.29.0' # pin, or flutter-version-file: .fvmrc
cache: true
- run: flutter pub get
- run: dart format --output=none --set-exit-if-changed .
- run: flutter analyze --fatal-infos
- run: flutter test --test-randomize-ordering-seed random --reporter expanded
The full skeleton — freshness gates, host-sqlite, coverage strip, and the release-build job — is in references/workflow-skeleton.md.
This is why committing *.g.dart / *.freezed.dart / *.drift.dart is safe, and how you catch a schema change with no migration.
- name: Generated code is up to date
run: |
dart run build_runner build --delete-conflicting-outputs
if ! git diff --exit-code -- '*.g.dart' '*.freezed.dart' '*.drift.dart'; then
echo "::error::Generated code is stale. Run build_runner and commit the result."
exit 1
fi
- name: Schema dumps are up to date
run: |
dart run drift_dev schema dump lib/data/app_database.dart drift_schemas/
if ! git diff --exit-code -- drift_schemas/; then
echo "::error::drift_schemas/ is stale — you changed the schema without"
echo "::error::bumping schemaVersion and dumping. Shipping this means NO"
echo "::error::MIGRATION RUNS and existing rows fail to load."
exit 1
fi
Check which suffix your codegen actually emits (.drift.dart modern vs .g.dart legacy part-file) before editing a pattern — don't guess. Never weaken a freshness gate to a warning or run it only on tags.
Some contracts are invisible to every test — a banned import that isn't reached at runtime, a config attribute. Grep them. Strip comments first (a rule's own explanation contains its needle), anchor to a structure (an import URI, an XML element), accumulate every offender, and fail once with the full list and a reason a stranger would understand.
// test/policy/banned_imports_test.dart — match the import URI, not the file.
import 'dart:io';
import 'package:test/test.dart';
void main() {
test('lib/ imports nothing that can reach the network or phone home', () {
const banned = <String>[
'package:http/', 'package:dio/',
'package:firebase_core/', 'package:sentry_flutter/',
];
final importUri =
RegExp(r'''^\s*import\s+['"]([^'"]+)['"]''', multiLine: true);
final lineComment = RegExp(r'//[^\n]*');
final offenders = <String>[];
for (final f in Directory('lib').listSync(recursive: true).whereType<File>()) {
if (!f.path.endsWith('.dart') || f.path.endsWith('.g.dart')) continue;
final code = f.readAsStringSync().replaceAll(lineComment, '');
for (final m in importUri.allMatches(code)) {
final uri = m.group(1)!;
if (banned.any(uri.startsWith)) offenders.add('${f.path}: $uri');
}
}
expect(offenders, isEmpty,
reason: 'These imports break the no-network promise.\n${offenders.join('\n')}');
});
}
The criteria and pitfalls for authoring these are in references/policy-grep-gate.md; examples/policy_grep_test.dart is a complete file. The same technique as a shell gate lives in scripts/banned-strings.sh for a pre-PR check outside the Dart suite.
Fix the upward lie before quoting any number, then strip generated code.
# REQUIRED first: include untested files so the denominator is honest —
# a generated test that imports every lib/ file (see workflow-skeleton.md),
# otherwise one tested file can report ~100%. Collect coverage in the same
# randomized run; do not run the suite twice.
- run: flutter test --coverage --test-randomize-ordering-seed random
- name: Strip generated code from coverage
run: |
lcov --remove coverage/lcov.info \
'lib/**/*.g.dart' 'lib/**/*.freezed.dart' 'lib/**/*.drift.dart' \
-o coverage/lcov.info --ignore-errors unused # lcov 2.x errors on unused patterns
# Publish for transparency. Do NOT add a min-coverage threshold.
Instead of a global threshold, hold a handful of named files whose bug is unrecoverable (migrations, a money/units core, a repository write path) at their floor by reading the diff — not by counting lines for a metric already known to lie. See testing-strategy for the file-level-floor rationale.
If you run goldens in CI, run them on the pinned runner and only compare. CI must never --update-goldens — that makes the gate assert nothing. Cross-OS/font drift is real; goldens made on one host fail on another, so either pin the runner and accept it as authoritative, or keep goldens out of CI and rely on layout-invariant widget tests plus the on-device pass. See widget-golden-and-a11y-testing for the two-lane golden strategy.
Only if the repo is a real Dart pub workspace / Melos monorepo — not a single-package app:
dart pub get at root pulls all members); run codegen at the root before analyze (see run-codegen).package:flutter); this is the one place the static gate reads a resolved dependency graph rather than source text.flutter-version in one env: entry referenced by every job so a bump is one edit.Do not present any of this as required for a small app — it is overhead a single package does not need.
ubuntu-latest / floating SDK. Image and toolchain drift move under the workflow with no diff to review, turning a green build into a lie.@v7 you didn't verify silently fails or changes behaviour; mark # VERIFY: and confirm instead.--update-goldens, dart format writing fixes, committing regenerated code — the gate then asserts nothing.contains grep. Hits the rule's own comment and string literals — strip comments and anchor to a structure, or it cries wolf and gets deleted.expect inside the offender loop. Reports offender #1 and hides the rest; accumulate and fail once.continue-on-error: true on a gate, merging on a skipped gate, or // ignore: on a static finding — a suppressed gate is exactly the leak it exists to catch.default: on a sealed type, an overflow modifier) — false positives get the directory deleted; that's code review, not a gate.runs-on: ubuntu-24.04 (or an explicit image) and subosito/flutter-action@v2 with an explicit flutter-version/flutter-version-file and channel: stable; unverified action versions carry # VERIFY:.dart format --set-exit-if-changed and flutter analyze --fatal-infos run and block.git diff --exit-code, failing with an actionable message.--test-randomize-ordering-seed random; any native host dep (e.g. sqlite3) is installed before the suite that needs it.continue-on-error, uses --update-goldens, or mutates the repo.run-codegen — the deterministic build_runner pass whose output the freshness gate diffs.run-migration — the schema-snapshot ritual the schema-freshness gate protects.lint-and-style-config — the analysis_options.yaml the analyze gate runs, and the --fatal-infos promotion.testing-strategy — the file-level coverage floors and fakes-over-mocks doctrine behind the coverage rule.widget-golden-and-a11y-testing — the two-lane golden strategy and why CI only verifies, never blesses.codegen-and-toolchain — SDK pinning, per-package build.yaml, and analyzer/coverage excludes referenced by the gates.dependency-hygiene — the committed lockfile and version-pinned lint include the gates assume.design-review-workflow — the once-per-app manual QA sweep that covers what CI cannot prove.run-goldens-rebaseline — the local, human-reviewed blessing ritual CI must never perform.release-and-store-shipping — what happens after the gates are green: the signed artifact, archived symbols, store declarations, and staged rollout.matchesGoldenFile (goldens are OS/font/version-sensitive; --update-goldens). https://api.flutter.dev/flutter/flutter_test/matchesGoldenFile.htmldart test runner flags (--test-randomize-ordering-seed). https://dart.dev/tools/dart-testlcov.info, stripping generated files, the untested-file lie). https://codewithandrea.com/articles/flutter-test-coverage/What 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./codegen-and-toolchainEnforces a deterministic build_runner codegen discipline: run one pinned `dart run build_runner build --delete-conflicting-outputs` pass BEFORE `flutter analyze` (never after), fence every builder with `generate_for:` globs in a per-package `build.yaml`, make one deliberate commit-vs-gitignore decision for `*.g.dart`/`*.freezed.dart`/`*.drift.dart` and back it with the matching CI gate (freshness diff if committed, codegen-first if gitignored), mirror the generated-file globs into the analyzer AND coverage excludes, pin the SDK, and never hand-edit generated output. Use when editing build.yaml, analysis_options.yaml, pubspec.yaml, .gitignore, .gitattributes, or CI workflows; wiring drift_dev/freezed/json_serializable/riverpod_generator/ gen-l10n/mockito codegen; fixing "missing part file", "undefined class _$Foo", or "conflicting outputs" errors; deciding whether to commit generated code; or scoping builders so one edit does not regenerate everything.Other plugins' skills for the same job