run-codegen

Regenerates Dart build_runner codegen output before running flutter analyze.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter projects using drift, freezed, json_serializable, and riverpod_generator fail analysis with phantom "missing part file" and undefined-class errors whenever generated *.g.dart, *.freezed.dart, or *.drift.dart files are missing or stale after a clone, branch switch, or source edit. ## Core Features & Use Cases - Pinned one-shot codegen command: Runs dart run build_runner build --delete-conflicting-outputs verbatim, always before flutter analyze, clearing stale-output collisions. - Strict guardrails: Never hand-edit generated files, never force-add them to git, and never use build_runner watch in CI or pre-commit hooks. - Multi-package handling: Explains workspace-root versus per-package regeneration and when to use a fan-out wrapper like melos run gen. - Use Case: After switching branches, the analyzer reports undefined freezed classes; run the pinned build_runner command first, then analyze, and the phantom errors disappear. ## Quick Start Regenerate all Dart codegen output with the pinned build_runner build command and then run flutter analyze on my project.

Frequently Asked Questions about run-codegen

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

FAQPage Schema
How do I run build_runner codegen in a Flutter project?

Run `dart run build_runner build --delete-conflicting-outputs` from the package or workspace root. The flag clears stale outputs from renamed or deleted sources, and the command should always run before flutter analyze.

Why does flutter analyze show missing part file errors after git clone?

A fresh clone has no generated *.g.dart, *.freezed.dart, or *.drift.dart files on disk, so the analyzer reports missing parts and undefined classes. Run build_runner build first, then analyze; the errors describe missing output, not real defects.

What causes build_runner conflicting outputs errors?

Conflicting outputs occur when build_runner finds generated files it did not write in the current run, typically leftovers from renamed or deleted sources. Re-running with --delete-conflicting-outputs clears the stale files and completes the build.

Can I use build_runner watch in CI or pre-commit hooks?

No. Watch mode is a local development convenience and is non-deterministic, so CI and pre-commit steps must use the one-shot `build` command. Also stop any running watcher before a one-shot build to avoid output races.

Should generated .g.dart files be edited or committed manually?

Never hand-edit generated files because the next build silently reverts them; fix the annotated source instead. Whether generated code is committed or gitignored is a repo-level decision, so never force-add artifacts past ignore rules.

How does build_runner work in a multi-package Dart workspace?

One invocation regenerates the current package plus its path dependencies, not every workspace sibling. Use a repo-level fan-out wrapper such as `melos run gen` for full multi-package regeneration, or run the command inside one package to scope it.