codegen-and-toolchain

Enforces deterministic build_runner codegen ordering, scoping, and commit policy for Dart projects.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/zakariaf/NearlyStop --skill codegen-and-toolchain-zakariaf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: codegen-and-toolchain
Source: https://github.com/zakariaf/NearlyStop/tree/main/.claude/skills/codegen-and-toolchain
Command: npx skills add https://github.com/zakariaf/NearlyStop --skill codegen-and-toolchain-zakariaf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Flutter and Dart projects using build_runner generators (freezed, json_serializable, drift_dev, riverpod_generator, mockito) hit phantom analyzer errors, conflicting-output build failures, stale generated code, and inflated coverage when codegen order, builder scoping, and commit policy are not disciplined. This Skill enforces one deterministic codegen pass with the correct CI gates. ## Core Features & Use Cases - Fixed codegen-first ordering: Runs dart run build_runner build --delete-conflicting-outputs before flutter analyze, eliminating misleading "missing part file" and "undefined class _$Foo" errors. - Builder scoping and policy gates: Fences every builder with generate_for: globs in per-package build.yaml files, and backs the commit-vs-gitignore decision with the matching CI gate (freshness diff or codegen-first). - Toolchain parity and excludes: Pins the SDK so local equals CI, and mirrors generated-file suffixes into both analyzer and lcov coverage excludes. - Use Case: After renaming a model, your build fails with "conflicting outputs" and the analyzer reports undefined _$Task classes. This Skill regenerates with --delete-conflicting-outputs first, then analyzes a clean tree. ## Quick Start Ask the AI to set up the build_runner codegen discipline for your Flutter project, including scoped build.yaml files, analyzer and coverage excludes, and the CI freshness gate.

Frequently Asked Questions about codegen-and-toolchain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix "missing part file" and "undefined class _$Foo" errors in Flutter?

Run `dart run build_runner build --delete-conflicting-outputs` before `flutter analyze`. These errors appear when generated files are absent on a fresh clone or stale after editing an annotation; regenerate first, never hand-create the file.

Should I commit or gitignore generated .g.dart files in Dart?

Both strategies are valid. Gitignoring keeps diffs clean but requires codegen to run first in CI; committing survives toolchain breakage but needs a .gitattributes linguist-generated marker plus a CI freshness gate running `git diff --exit-code` after regeneration.

How do I scope build_runner builders with build.yaml?

Give each codegen-carrying package its own build.yaml and fence every builder with `generate_for:` globs pointing at the narrowest directory owning the annotation. An unscoped root config regenerates the whole tree on every edit.

Why does build_runner fail with "conflicting outputs"?

A leftover generated file from a renamed or deleted source blocks the build. Pass `--delete-conflicting-outputs` so build_runner overwrites stale outputs; this is routine, not a bug to investigate.

Does generated Dart code need to be excluded from coverage?

Yes. Strip `*.g.dart`, `*.freezed.dart`, and `*.drift.dart` from lcov with suffix-anchored unanchored patterns, and mirror the same globs in analysis_options.yaml excludes. A missed glob inflates coverage with untested machine output.

When should I use a Dart pub workspace with Melos?

Only when a project has genuinely outgrown one package. Use `resolution: workspace` for path linking with one root pubspec.lock, and layer Melos only for script orchestration, never for linking. Run build_runner once at the workspace root.