# codegen-and-toolchain

> Claude/Codex skill by [@zakariaf](https://omgskills.com/library/zakariaf/index.md) · 61 stars · Updated 2026-09-23

Enforces 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.

Tags: agent-skills, ai-agents, best-practices, claude-code, codex, coding-agent, cursor, dart, dartlang, developer-tools, drift, flutter, flutter-architecture, github-copilot, go-router, llm, material-design, mvvm, riverpod, skills

## Install

```sh
git clone https://github.com/zakariaf/Flutter-Skills /tmp/Flutter-Skills && ln -s /tmp/Flutter-Skills/skills/codegen-and-toolchain ~/.claude/skills/codegen-and-toolchain
```

## From README

Codegen and toolchain 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 buildrunner or gen-l10n. Read the reference for the task at hand: references/codegen-scoping.md — the generator inventory, generatefor: 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. Non-negotiable rules Codegen runs FIRST, before flutter analyze. Generated files may be absent on a fresh clone or stale after editing an annotation.

## Links

- HTML page: https://omgskills.com/library/zakariaf/flutter-skills/skills/codegen-and-toolchain/
- GitHub: https://github.com/zakariaf/Flutter-Skills
- Author: [@zakariaf](https://omgskills.com/library/zakariaf/index.md)

## More from this repo

- [accessibility-as-code](https://omgskills.com/library/zakariaf/flutter-skills/skills/accessibility-as-code/index.md) — Enforces accessibility as a correctness property authored into each widget — Semantics(button/label) or...
   - [@zakariaf](https://omgskills.com/library/zakariaf/index.md) · 61 stars
- [adaptive-layout](https://omgskills.com/library/zakariaf/flutter-skills/skills/adaptive-layout/index.md) — Enforces adapting layout by available CONSTRAINTS/size, never device or platform checks — LayoutBuilder +...
   - [@zakariaf](https://omgskills.com/library/zakariaf/index.md) · 61 stars
- [ads-and-iap-monetization](https://omgskills.com/library/zakariaf/flutter-skills/skills/ads-and-iap-monetization/index.md) — Enforces opt-in, rewarded-first monetization over the service seam — a rewarded view grants exactly one benefit and...
   - [@zakariaf](https://omgskills.com/library/zakariaf/index.md) · 61 stars
