/flutter:dependency-hygienefrom Flutter Skills
Enforces pubspec/lock discipline for Dart/Flutter projects: caret ranges, committed lockfile, SDK pinning, transitive-tree auditing, and a dependency gate that rejects network/telemetry/crash/ads/heavy-transitive packages.
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.
Every dependency is a permanent liability someone else may have to service. Optimise for resolves and builds years from now, not for latest. This skill governs pubspec/lock mechanics, the gate a new package must pass, and the escape hatch when a critical package rots.
Read the reference for the task at hand:
references/dependency-gate-and-audit.md — the refuse/accept gate, transitive auditing, licence recording, upgrade discipline.references/sdk-pin-and-lint-include.md — recording the SDK version and the silent-lint-disable trap on any SDK bump.references/vendoring-behind-an-interface.md — vendoring a bus-factor-1 native plugin into third_party/ without touching lib/.Run scripts/audit-deps.sh before a PR that changes pubspec.yaml.
pubspec.yaml, exact pins only in pubspec.lock. drift: ^2.31.0, never drift: 2.31.0. The lock pins; ranges only keep resolution solvable. Exact pins in a pubspec manufacture unsolvable conflicts on the next SDK bump and buy nothing the lock is not already delivering.pubspec.lock. This is an application, not a package — the asymmetry that flips the rule. The default Dart .gitignore template lists pubspec.lock; delete that line. The committed lock is the only thing that makes a stranger's git clone resolve the exact versions that were tested on a real device.pubspec.yaml diff without its pubspec.lock delta is incomplete. Run flutter pub get and stage the lock in the same commit — add, upgrade, and remove alike.environment: sdk: a real range so pub can solve; pin the exact tested Flutter version in a committed record CI reads (see reference). The record is what a stranger and CI read; do not confuse a version-manager tool with the file.include: that names a file absent from the resolved linter package emits include_file_not_found — fatal to default dart analyze/flutter analyze, so standard CI catches it. It only goes silent-and-green where warnings are made non-fatal, and even then it is your ruleset's added/promoted rules that stop applying, not the analyzer's built-ins. Verify it after any SDK bump (see reference).scripts/audit-deps.sh (or dart pub deps --json + the audit script) before committing a new dependency.lib/ after removing a dependency. A package deleted from pubspec.yaml but still transitively resolvable keeps compiling today and breaks on the clone that matters. The analyzer catches an unresolved import, not one that resolves by accident.| Do | Never |
|---|---|
Caret range: drift: ^2.31.0 | Exact pin: drift: 2.31.0 |
environment: sdk: ^3.6.0 — a real range | An exact sdk: version |
Commit pubspec.lock | Gitignore pubspec.lock |
The lock is authoritative. Ranges keep the solver able to move on an SDK upgrade; the lock keeps everyone on the versions that were actually verified.
Refuse a package if it — or anything in its transitive tree — does any of:
http, dio, sockets, gRPC) when the product promise is no-network or offline-first.--enable-experiment flag — an abandoned repo that needs an experiment to build stops building.Also weigh, and usually refuse: any bus-factor-1 package not behind an interface; anything whose function is a few hundred lines of first-party Dart; anything that only exists to save typing. Record the licence — a permissive one (MIT, BSD, Apache-2.0) is a precondition for the vendoring escape hatch; a copyleft dependency removes that option. Full checklist in references/dependency-gate-and-audit.md.
dart pub add --dry-run <package> # see what would resolve, resolve nothing
dart pub deps --json > /tmp/deps.json
scripts/audit-deps.sh # walks the resolved set, flags banned patterns
The audit walks the full resolved graph, matches each name against a policy pattern list, marks every hit direct or TRANSITIVE, and separates APK-shipping deps from build/test-only ones (a banned package reachable only from dev_dependencies never reaches the binary and is not a shipping defect). Exit 1 means refuse the dependency or find one that does not pull those in. To learn who introduced a package: dart pub deps | grep -B4 <name>.
Edit the BANNED/ALLOW lists at the top of scripts/audit_deps.py to match your policy; every ALLOW entry needs a written justification beside it.
Run dart pub outdated on your own schedule; there is no bot. Dependabot has never supported pub; Renovate raises PRs a solo repo has no workflow for. Keep their one useful idea by hand: never blind-upgrade a native plugin your app's core capability depends on.
Green CI is not evidence of a native capability. No CI job on a headless emulator can prove the app plays audio, reads a sensor, or talks to a platform channel end-to-end — integration_test can assert a channel call was issued, nothing more. After any bump to a capability-critical native plugin or the SDK itself, run a manual pass on a real device. After any upgrade touching a codegen package (drift, freezed, json_serializable), regenerate and commit — stale generated code is caught by CI, not the analyzer (see run-codegen).
A single-maintainer native plugin whose failure means the app cannot build is the one dependency worth pre-planning for. The mitigation is a thin interface, authored on day one, so vendoring never touches lib/:
// A port the app depends on; the plugin lives behind it. The `Gateway` suffix
// marks a thin wrapper over a SPECIFIC plugin (here flutter_secure_storage) —
// `naming-conventions` owns that Service-vs-Gateway distinction.
abstract interface class SecureStorageGateway {
Future<void> write(String key, String value);
Future<String?> read(String key);
}
Only when the plugin actually breaks — stops building against a Flutter release, or ships a regression upstream will not fix — clone it at the last-good tag into third_party/<plugin>/, point the pubspec at path:, record the SHA and every changed line in a VENDORED.md, confirm the licence permits redistribution, and patch, don't refactor. Full procedure and triggers in references/vendoring-behind-an-interface.md. See examples/vendored_plugin_behind_interface.dart.
Delete the pubspec entry, run flutter pub get, commit the pubspec.lock delta in the same commit — then grep -r "package:<name>" lib/. A transitively-resolvable import compiles today and breaks the clone that matters.
In a Dart pub workspace / monorepo, each package keeps its own pubspec.yaml with ranges, but the workspace resolves one shared lock at the root — audit and commit that root lock. Run the audit against the whole workspace's resolved tree, not one package's. A single package's pubspec cannot show what a sibling drags into the shared resolution. See codegen-and-toolchain for workspace toolchain mechanics.
pubspec.yaml. Turns the next SDK upgrade into an unsolvable-conflict debugging session; the lock already pins.pubspec.lock in an app. A fresh clone resolves whatever pub feels like today, not what was tested.pubspec.yaml to decide if a dep is safe. The banned SDK is on the second hop, invisible there.third_party/ is a line you own forever — patch the break and stop.pubspec.yaml.pubspec.lock delta is staged in the same commit as the pubspec.yaml change.scripts/audit-deps.sh exits 0 (or every hit has a justified ALLOW entry).include: file is confirmed present in the resolved package (references/sdk-pin-and-lint-include.md).grep -r "package:<name>" lib/ is empty.codegen-and-toolchain — workspace linking, SDK pinning at the toolchain level, generated-code commit-vs-gitignore.run-codegen — the deterministic build_runner pass to run after upgrading a codegen package.lint-and-style-config — the strict analysis_options.yaml the version-pinned include: feeds.service-boundary-and-native — the injectable-interface-per-side-effect pattern the vendoring seam relies on.naming-conventions — owns the Service-vs-Gateway boundary-suffix rule; a plugin wrapper like SecureStorageGateway takes the Gateway suffix.ci-pipeline-and-gates — wiring the audit and lock-freshness checks into CI.pubspec.lock and glossary: https://dart.dev/tools/pub/glossary#lockfiledart pub deps: https://dart.dev/tools/pub/cmd/pub-depsdart pub outdated: https://dart.dev/tools/pub/cmd/pub-outdatedexamples/vendored_plugin_behind_interface.dart (opens in a new tab)references/dependency-gate-and-audit.md (opens in a new tab)references/sdk-pin-and-lint-include.md (opens in a new tab)references/vendoring-behind-an-interface.md (opens in a new tab)scripts/audit-deps.sh (opens in a new tab)scripts/audit_deps.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub zakariaf/flutter-skills --plugin flutter40 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./ads-and-iap-monetizationEnforces opt-in, rewarded-first monetization over the service seam — a rewarded view grants exactly one benefit and only on a genuine reward outcome (a sealed Rewarded/Dismissed/NoFill), earn loops capped per day against an injected Clock, the earn control preloaded and hidden unless an ad is loaded so a fresh account never dead-ends on "no ads available" (a Guideline 2.1 risk), interstitials only at a natural break under a count-and-elapsed cap owned by the service so callers stay dumb, no banner on the primary work surface, one non-consumable unlock plus Restore re-checked each launch and committed through the single write path before the UI reacts, one derived isEntitled provider as the only gate, and the entitlement restored BEFORE the ad SDK initializes so a paying user never starts it, resolves consent, or sees a tracking prompt. Use when adding ads, wiring a rewarded earn loop, placing an interstitial, building a paywall, gating an entitlement, or setting up ad units./app-startup-and-bootstrapEnforces a fixed main() cold-launch order — crash-log sink + FlutterError.onError + PlatformDispatcher.onError installed BEFORE any code that can throw, settings/theme read before runApp so the first frame paints correct, real infra constructed in a composition-root bootstrap() and injected via ProviderScope overrideWithValue over throwing placeholder providers, non-blocking warm-up deferred to addPostFrameCallback, exactly two error handlers with NO runZonedGuarded, ProviderException unwrapped before logging, and a WidgetsBindingObserver that flushes durable state on background/resume. Use when editing lib/main.dart, main_<flavor>.dart, bootstrap.dart or app.dart, reordering anything in main(), adding a splash/onboarding/permission gate, restoring theme before first paint, wiring a DB or service into ProviderScope, handling app-lifecycle background/resume flushes, or chasing cold-start latency, ANRs, or first-frame jank./async-safetyEnforces no-silent-failure async discipline in Flutter/Dart — the arrow-callback Future-drop hole no lint catches (`onTap: () => vm.save(x)`), void-returning event handlers, a mounted/ref.mounted guard after EVERY await before touching BuildContext, capturing Navigator/ScaffoldMessenger before the gap, honest `unawaited()` that always ends in catchError, no empty/bare catches, `rethrow` over `throw e`, and disposing every StreamSubscription/StreamController/Timer/sink. Use when writing or reviewing async/await, wiring onTap/onPressed/onSubmitted or any VoidCallback, touching BuildContext after an await, writing initState/dispose/addPostFrameCallback, adding a Timer or Future.delayed, writing a try/catch, or seeing use_build_context_synchronously, cancel_subscriptions, close_sinks, unawaited_futures, or discarded_futures./ci-pipeline-and-gatesEnforces a lean GitHub Actions Flutter CI where every gate maps to one named release-blocking contract — pinned runner + subosito/flutter-action@v2 toolchain, dart format --set-exit-if-changed, flutter analyze --fatal-infos, build_runner and drift schema freshness (git diff --exit-code), flutter test --test-randomize-ordering-seed random, static import/banned-string greps that catch what runtime can't, coverage-as-report-never-a-gate with the upward-lie fixed, verify-never-bless goldens (no --update-goldens in CI), and an honest statement of what CI cannot prove (audio, real fonts, on-device behaviour). Use when editing .github/workflows/*.yml, adding or removing a job or step, wiring a codegen/schema/format/analyze/coverage gate, writing a grep-based policy test or gate script under test/policy or tool/, pinning action versions, or claiming CI proves something it can't.Other plugins' skills for the same job