/flutter:codegen-and-toolchainfrom Flutter Skills
Enforces deterministic build_runner codegen discipline for Flutter/Dart projects: scoped builders, commit-vs-gitignore strategy, CI gates, and analyzer/coverage excludes.
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.
One deterministic codegen pass is the source of truth for every generated file;
run it first, scope it tightly, and decide once whether its output lives in git.
Applies whenever a project uses build_runner or gen-l10n.
Read the reference for the task at hand:
references/codegen-scoping.md — the generator inventory, generate_for:
scoping tables, error-to-fix recovery map.references/commit-vs-gitignore.md — the two committed/gitignored strategies,
their tradeoffs, and the exact CI gate each one requires.references/toolchain-and-workspace.md — SDK pinning, analyzer/coverage
excludes, and the multi-package workspace layering (fenced, opt-in).Run scripts/regen.sh (codegen → format → analyze) before a PR, and
scripts/check-codegen-hygiene.sh to verify excludes and commit-policy parity.
flutter analyze. Generated files may be
absent on a fresh clone or stale after editing an annotation. Analyzing that
tree emits misleading "missing part file" and "undefined class _$Foo"
errors. Regenerate, then analyze — never chase the symptom at the call site.--delete-conflicting-outputs. Without it build_runner
refuses to overwrite an output from a renamed/deleted source and fails with a
wall of "conflicting outputs" text. That is not a bug to investigate.generate_for: in a per-package build.yaml.
A change in one directory must not regenerate the whole tree. Point each glob
at the narrowest directory that owns the annotation.git diff --exit-code as a freshness gate. Either is valid; a
policy without its gate is not (see references/commit-vs-gitignore.md)..fvmrc under FVM, or the tool the repo standardizes
on). A drift here reproduces "works on my machine" format/codegen churn.watch is a local edit-loop tool only. CI and the pre-analyze step always
use the one-shot build command.Run from the repository root:
dart run build_runner build --delete-conflicting-outputs
This regenerates every builder — drift_dev, freezed, json_serializable,
riverpod_generator, mockito — in one pass. gen-l10n runs through the
Flutter tool but is treated identically (regenerated first, same commit policy):
flutter gen-l10n # if not auto-triggered by `flutter pub get` via l10n.yaml
Fresh clone / after pull / after editing any annotation, the fixed order is:
build_runner build --delete-conflicting-outputs → format → analyze → test
Never reorder codegen after analyze. During an active edit session only, a watcher rebuilds affected outputs on save:
dart run build_runner watch --delete-conflicting-outputs
Give every codegen-carrying package (or the single app package) its own
build.yaml, and fence each builder's generate_for: at the narrowest directory
that owns its annotation. An unscoped root config fans out to every annotation in
the tree, so editing one Task model regenerates unrelated Order and Account
outputs. Copy examples/build.yaml; references/codegen-scoping.md has the full
generator-to-suffix table and per-builder globs.
Both strategies are legitimate; they trade different risks (see rule 5). Gitignore
keeps the tree clean but needs a working toolchain to build. Committing survives a
broken future toolchain and makes schema diffs reviewable, but needs a
.gitattributes diff-collapse (examples/gitattributes.example) AND a mandatory
freshness gate — regenerate, then
git diff --exit-code -- '*.g.dart' '*.freezed.dart' '*.drift.dart'. A policy
without its gate is not a policy. Both strategies, their tradeoffs, and the exact
gate each requires: references/commit-vs-gitignore.md.
Committed OR gitignored, every emitted generated suffix must be excluded from
BOTH the analyzer and the lcov coverage filter — verify the suffix the config
actually emits first, do not guess. A missed analyzer glob wastes review on
machine output; a missed (or mis-anchored) lcov glob inflates coverage with
untested code. A migration-test baseline dir that holds generated era-correct data
classes needs the analyzer exclude too — an autofix inside an exported schema
snapshot would corrupt migration verification (see run-migration). The canonical
exclude blocks and the correctly anchored lcov patterns live in
references/toolchain-and-workspace.md.
Only for a repo that has genuinely outgrown one package. A single-app project needs none of this.
resolution: workspace in every
member pubspec plus a workspace: list at the root, producing ONE root
pubspec.lock. Never add a per-package lockfile.melos run gen/format/analyze/test), never for path linking — pub does the
linking. Filter the gen script to packages that depend on build_runner.build_runner once at the workspace root so every member regenerates in
the same pass; running inside one package dir leaves the others stale.--delete-conflicting-outputs — turns a routine rename into a
build wall..g.dart/.drift.dart to silence an error — reverted on the
next build; the real fix is in the annotated source.build.yaml — every trivial edit regenerates the whole
tree and slows every build.[] == []) while proving nothing; fill it or delete it (see run-migration).dart run build_runner build --delete-conflicting-outputs succeeds from a
clean tree, then flutter analyze is clean.build.yaml with scoped
generate_for: globs.analysis_options.yaml
and the lcov coverage filter.watch in CI.run-codegen for the operational, low-freedom "run this exact command"
loop and its troubleshooting table.run-migration for the Drift schema-snapshot and migration-test ritual the
codegen pass produces.persistence-drift for the Drift/DAO data layer these generators feed.lint-and-style-config for the analyzer ruleset and the excludes mirrored
here.ci-pipeline-and-gates for where codegen and the freshness gate sit in the
pipeline.dependency-hygiene for the lockfile and SDK-pinning mechanics.examples/build.yaml (opens in a new tab)examples/gitattributes.example (opens in a new tab)references/codegen-scoping.md (opens in a new tab)references/commit-vs-gitignore.md (opens in a new tab)references/toolchain-and-workspace.md (opens in a new tab)scripts/check-codegen-hygiene.sh (opens in a new tab)scripts/regen.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
build-runner, codegen, flutter-toolchain, dart-codegen, ci-gates
40 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.npx claudepluginhub zakariaf/flutter-skills --plugin flutterOther plugins' skills for the same job