zakariaf/flutter-skills/project-structure-and-packages
Claude Code and agent skill by zakariaf/flutter-skills
- community
Checking that the SKILL.md file is still in the repository.
Enforces Flutter/Dart project scaffolding where the layout makes defects greppable — a single-package app by default (feature-first under lib/features/, shared foundation split by role in core/ data/ services/ routing/ theme/ l10n/, a thin main.dart that calls bootstrap(), no lib/src in the app), extracting a generically-named pure-Dart package only when a body of logic earns it (public barrel over private lib/src/ for PACKAGES only, meta-only deps as the compile firewall, resolution:workspace member, downward-only dependency DAG), with pubspec treated as the audit artifact and no utils/helpers/common/misc/grab-bag-shared junk-drawer folders. Use when creating any .dart file or directory, deciding where a repository/Notifier/MethodChannel/value-type/token belongs, authoring or fixing a pubspec.yaml, adding a workspace member, writing an import directive, mirroring a test under test/, or reviewing a diff for organisation.
Install
npx vskill@latest install zakariaf/flutter-skills/project-structure-and-packagesSKILL.md
The same SKILL.md was published earlier as zakariaf/flutter-skills/project-structure-and-packages.
Project structure & packages
The layout is a feedback loop, not decoration: structure exists so that "what imports Flutter?", "what has no test?", and "does this feature reach into another?" are answerable by grep and ls, not by trust. Default to one Flutter package (the app), organised feature-first under lib/features/ over a shared foundation. Reach for a second, pure-Dart package only when a body of logic earns the isolation. A pubspec.yaml is the audit artifact — a package cannot import what it does not declare, so the dependency list is the layer boundary.
This skill OWNS the physical directory tree (D1). Other skills reference it rather than drawing their own.
Read the reference for the task at hand:
references/single-package-layout.md— the default one-package feature-first tree, the shared-foundation folders, placement-by-failure, the deliberately-absent list.references/layering-and-dependencies.md— the downward-only DAG, feature isolation, pubspec-as-audit, the compile-firewall insight.references/workspace-and-packages.md— when (and how) to extract a pure-Dart package: barrel-over-src,resolution: workspace, naming the core generically.
Run scripts/check_structure.sh and scripts/check_import_boundaries.sh before a PR. The purity check auto-detects only pure roots named *_core; a pure package with a plain generic name (money, scheduling) must be passed explicitly, e.g. PURE_DIR=packages/money scripts/check_import_boundaries.sh.
Non-negotiable rules
- Single package by default. A small-to-medium app is one Flutter package; its
pubspec.lockis committed (it is an app, not a library). Do not addpackages/, Melos, or a Dart workspace until a body of pure logic genuinely earns isolation (seereferences/workspace-and-packages.md). Multiplying packages before there is anything to multiply buys nothing and costs days. - Feature-first inside `lib/features/`, over a shared foundation. Each screen/surface is a folder under
lib/features/<feature>/(presentation/+<feature>_notifier.dart; optionalapplication/,domain/, rarelydata/). The cross-cutting foundation splits by technical role at the top level —core/(pure),data/(repositories + DB),services/(side-effect ports),routing/,theme/,l10n/— because those files serve every feature.main.dartis a thin entry that callsbootstrap();bootstrap.dartis the composition root;app.dartbuildsMaterialApp.router. - No grab-bags, no unnamed nesting. There is no hard depth cap — feature-first naturally nests (
features/orders/presentation/). The rule is that every folder has a named responsibility: noutils//helpers//common//misc/, no grab-bagshared/.core/is the SANCTIONED pure-foundation home, not a junk drawer. - Place a class in the layer whose failure it owns. Talks to the DB →
data/. Talks to a platform channel →services/native/. A pure value type / calculator / the Clock seam →core/(or a feature'sdomain/if truly feature-local). Everything else → the feature that renders it. This is a deterministic rule, not taste. - `pubspec.yaml` is the audit artifact — declare the audit-minimal dependency set. An unused dependency is a review reject: it muddies the claim the manifest makes. The narrowest dep list keeps each layer boundary provable by reading one file.
- Dependencies point one way, downward only; features never import features.
features → services/data → core. No lower layer imports an upper one; no shared code imports the composition root. A feature folder NEVER imports another feature folder — share viacore/data/servicesor navigate by route (seenavigation-and-routing). A cycle is a design defect: the analyzer resolves the whole graph in one context, so an upward or cross-feature import is an error, not a runtime surprise. - A pure-Dart core depends on `meta` only — the missing Flutter import is a compile firewall. In-app,
lib/core/holds only pure foundation (value objects,Result/Failure, the Clock seam, calculators) and reads no wall clock. Time comes frompackage:clock'sClock(ambientclock, or aClockparam), neverDateTime.now(), never a bespokeClockService— seeservice-boundary-and-native. When such logic is extracted to a package, the empty-of-Flutter manifest makes a strayWidgetorDateTime.now()a build error. - One public barrel over a private `lib/src/` — for PACKAGES only. A shared package exposes exactly one library
lib/<package>.dartthat exports the stable surface; everything else lives underlib/src/, which no other package may import. The app package uses neither barrels norlib/src/: it has no external importers, and barrels add analyzer cost plus circular-import risk for zero benefit. - No junk-drawer folders. No
utils/,helpers/,common/,misc/, or a grab-bagshared/. A helper either lives beside the type it serves (a same-file extension) or is a named service/value type with a real home.core/is explicitly NOT a junk drawer — it is the named pure-foundation layer. - Tests mirror `lib/` 1:1.
test/data/order_repository_test.dartforlib/data/order_repository.dart. "What has no test?" then reduces to a diff of twolsoutputs. Cross-cutting assertions that belong to no single file get their own folder (test/policy/); shared fakes go intest/support/. - One primary declaration per file; filename = that declaration in `snake_case`.
order_repository.dartholdsOrderRepository. The one exception: asealedhierarchy lives in a single file, because that file is the closed set the compiler enforces. - Package imports everywhere; never mix with relative.
always_use_package_imports. Mixingpackage:and relative paths lets the same member resolve two ways, producing two distinct runtime types. Package imports also survive file moves and are greppable.
Default single-package tree
A feature's data/ folder is usually ABSENT — features read the shared repositories in lib/data/. See references/single-package-layout.md for the full tree and the deliberately-absent list.
Placement decision procedure
- A widget or model reused by 2+ features moves DOWN to
lib/core/(pure) orlib/data/, or up to a named shared-widget home — never into one feature's folder that another then imports. - A new surface gets its own folder under
lib/features/even for a single file — consistency beats saving a line. Register its route intorouting/(seescaffold-feature-module,navigation-and-routing). - Read platform/accessibility state (
MediaQuery.textScalerOf) in the widget at build time, not via a helper file or a provider —MediaQueryis already reactive. App state via Riverpod; platform state viaBuildContext. Seeaccessibility-as-code.
When to extract a package (multi-package / workspace)
Extract a pure-Dart package the moment a body of logic satisfies all of: it is genuinely UI-free, it is worth testing headlessly in milliseconds, and the "imports no Flutter" guarantee is worth making a build error. Typical: money/units math, entities, deterministic algorithms. Below that bar it stays in lib/core/.
The root pubspec.yaml lists members under workspace:; there is one committed pubspec.lock at the root. The public barrel lib/domain_core.dart exports the stable surface; internals stay under lib/src/. Full ritual, dependency matrix, and gates in references/workspace-and-packages.md.
When multi-package (workspace) only. Everything in this section —packages/,resolution: workspace, barrels,lib/src/— applies solely once you have decided to split. A single-package app does none of it.
Anti-patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/project-structure-and-packages/SKILL.md
Popularity
- Repository stars
- 22
- Repository forks
- 4
- 7-day trend score
- 16
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/zakariaf/flutter-skills/project-structure-and-packages)