Logo Codegen And Toolchain

Codegen And Toolchain

Cộng đồng
zakariaf
codegen-and-toolchain

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.

Add to TypingMind

Tổng quan

Nhà phát hànhzakariaf
Kho mãFlutter-Skills
Tên kỹ năngcodegen-and-toolchain
Sao
64
Bản fork
15
Tệp đi kèm
7
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 7 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được zakariaf công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Codegen And Toolchain trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/zakariaf/Flutter-Skills/tree/main/skills/codegen-and-toolchain
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zakariaf/Flutter-Skills.git /tmp/Flutter-Skills
mkdir -p .claude/skills
cp -r /tmp/Flutter-Skills/skills/codegen-and-toolchain .claude/skills/codegen-and-toolchain
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Codegen And Toolchain trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Codegen And Toolchain ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Codegen And Toolchain với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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

Non-negotiable rules

  1. Codegen runs FIRST, before 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.
  2. Always pass --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.
  3. Never hand-edit a generated file. The next build silently reverts it and takes your edit with it. Change the annotated source and rerun codegen.
  4. Scope every builder with 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.
  5. Decide commit-vs-gitignore ONCE, back it with the matching CI gate. Gitignored → CI regenerates first, before analyze. Committed → CI regenerates then runs git diff --exit-code as a freshness gate. Either is valid; a policy without its gate is not (see references/commit-vs-gitignore.md).
  6. Mirror generated-file globs into the analyzer AND coverage excludes. A glob that lints machine output wastes review; a glob missing from lcov inflates coverage. Exclude the emitted suffix — verify it, do not guess.
  7. Pin the SDK; local must equal CI. The CI Flutter/Dart version must match the pinned local version (.fvmrc under FVM, or the tool the repo standardizes on). A drift here reproduces "works on my machine" format/codegen churn.
  8. watch is a local edit-loop tool only. CI and the pre-analyze step always use the one-shot build command.

The canonical command

Run from the repository root:

bash
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):

bash
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:

bash
dart run build_runner watch --delete-conflicting-outputs

Scoping builders with build.yaml

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.

Commit vs gitignore: pick one, wire its gate

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.

Analyzer and coverage excludes

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.

When multi-package (workspace)

Only for a repo that has genuinely outgrown one package. A single-app project needs none of this.

  • Link members with a native Dart pub workspace: resolution: workspace in every member pubspec plus a workspace: list at the root, producing ONE root pubspec.lock. Never add a per-package lockfile.
  • If you layer Melos on top, use it for script orchestration only (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.
  • Run build_runner once at the workspace root so every member regenerates in the same pass; running inside one package dir leaves the others stale.

Anti-patterns

  • Analyzing before regenerating — every downstream error is a phantom; fix the order, not the code.
  • Omitting --delete-conflicting-outputs — turns a routine rename into a build wall.
  • Hand-editing .g.dart/.drift.dart to silence an error — reverted on the next build; the real fix is in the annotated source.
  • Committing generated code with no freshness gate — output silently drifts from source and reviewers trust a lie.
  • One unscoped root build.yaml — every trivial edit regenerates the whole tree and slows every build.
  • Coverage/analyzer glob that matches the wrong suffix — fails silently in the analyzer, loudly in lcov 2.x, and quietly inflates coverage.
  • CI Flutter version ≠ pinned local version — reproducible format/codegen churn nobody can explain.
  • A generated migration test left with empty data lists — passes vacuously ([] == []) while proving nothing; fill it or delete it (see run-migration).

Definition of done

  • dart run build_runner build --delete-conflicting-outputs succeeds from a clean tree, then flutter analyze is clean.
  • Every codegen-carrying package has a build.yaml with scoped generate_for: globs.
  • The commit-vs-gitignore decision is made and its CI gate exists (freshness diff, or codegen-first).
  • The emitted generated suffixes are excluded from BOTH analysis_options.yaml and the lcov coverage filter.
  • SDK is pinned and the CI toolchain version matches it.
  • No generated file is hand-edited; no watch in CI.

Related skills

  • See run-codegen for the operational, low-freedom "run this exact command" loop and its troubleshooting table.
  • See run-migration for the Drift schema-snapshot and migration-test ritual the codegen pass produces.
  • See persistence-drift for the Drift/DAO data layer these generators feed.
  • See lint-and-style-config for the analyzer ruleset and the excludes mirrored here.
  • See ci-pipeline-and-gates for where codegen and the freshness gate sit in the pipeline.
  • See dependency-hygiene for the lockfile and SDK-pinning mechanics.

References

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Codegen And Toolchain làm được gì?

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

Vì sao nên dùng Codegen And Toolchain trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Codegen And Toolchain là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Codegen And Toolchain trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/zakariaf/Flutter-Skills/tree/main/skills/codegen-and-toolchain. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Codegen And Toolchain?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Codegen And Toolchain với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Codegen And Toolchain với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Codegen And Toolchain có miễn phí không?

Có. Kỹ năng này được zakariaf phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇