Skip to content

About

A scalable, feature-first architecture blueprint for Flutter applications. Built with clean code principles, clean separation of concerns, and structured by individual feature modules for ultimate maintainability.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Flutter Feature-Based Architecture Skill

An AI agent coding skill (compatible with Gemini, Codex, Claude, OpenCode, and other developer agents) for designing, implementing, refactoring, and reviewing Flutter applications built with feature-based vertical slices, handwritten Riverpod 3 providers, and componentized UI.

The skill favors architecture that is easy to navigate and maintain without relying on code generation.

Visual Hierarchy

The diagram below shows how app composition, shared infrastructure, feature slices, and Riverpod state flow fit together—and why the boundaries give coding agents predictable, low-context work units.

Feature-first Flutter architecture and agent benefits

Example Feature Slice

The orders/ example shows the exact feature-local nesting from data to UI, plus the event, state, repository, and shared-client boundaries. It also highlights the handwritten Riverpod, mutation, and pagination patterns the skill can implement.

Handwritten orders feature slice and supported capabilities

What It Covers

  • Feature-first organization under lib/features/
  • Shared cross-feature code under lib/core/
  • Handwritten Riverpod 3 Provider, Notifier, and AsyncNotifier patterns
  • Handwritten immutable models, serialization, copyWith, and value equality
  • Thin ConsumerWidget pages composed from named StatelessWidget components
  • Repository and provider dependency boundaries
  • Async loading, error, mutation, refresh, and pagination behavior
  • Architecture consistency reviews

Core Conventions

The skill applies these defaults to new code while preserving coherent local project conventions:

  • Target Riverpod 3.x.
  • Keep providers handwritten and apply .autoDispose on provider declarations.
  • Avoid legacy StateProvider, StateNotifierProvider, and ChangeNotifierProvider in new code.
  • Do not introduce riverpod_annotation, freezed, json_serializable, build_runner, generated part declarations, .g.dart, or .freezed.dart files.
  • Keep each feature independent from sibling features.
  • Move code to core/ only when it is genuinely app-wide or shared by multiple features.
  • Keep business logic and async orchestration outside widgets.
  • Replace private widget-returning helpers such as _buildHeader() with named widget classes.
  • Preserve loaded data during mutations through optimistic updates or explicit mutation state.

Installation

Copy the skill directory into your agent's customization root (either global or workspace-scoped).

Option 1: Global Installation

Copy the skill directory to your global agent configurations root. Depending on your agent, the target path may vary:

  • Gemini / Antigravity:
    mkdir -p ~/.gemini/config/skills
    cp -R flutter-feature-based-architecture ~/.gemini/config/skills/
  • Codex:
    mkdir -p ~/.codex/skills
    cp -R flutter-feature-based-architecture ~/.codex/skills/
  • Claude / OpenCode / Others:
    mkdir -p ~/.agents/skills
    cp -R flutter-feature-based-architecture ~/.agents/skills/

Option 2: Workspace-scoped Installation

Copy the skill directory to your workspace's local .agents directory to make it active for that repository:

mkdir -p .agents/skills
cp -R flutter-feature-based-architecture .agents/skills/

The installed path should contain the skill files directly (e.g. .agents/skills/flutter-feature-based-architecture/SKILL.md).

Usage

This skill is automatically discovered and loaded by agent platforms supporting customizations (such as Gemini, Codex, Claude, OpenCode, etc.). Once installed:

  • The agent will automatically trigger the skill when answering questions or performing tasks involving feature-based Flutter organization, Riverpod architecture, handwritten providers, shared core/ code, or removal of private UI build helpers.
  • You can also explicitly instruct the agent to use it in your prompt, for example: "Use the flutter-feature-based-architecture skill to review this Flutter project..."

Recommended Project Shape

lib/
├── app/
├── core/
│   ├── components/
│   ├── providers/
│   ├── repositories/
│   ├── routes/
│   └── theme/
├── features/
│   └── orders/
│       ├── data/
│       │   ├── models/
│       │   └── repositories/
│       ├── providers/
│       └── views/
│           └── components/
└── main.dart

This is a default for new work, not a requirement to rename an existing project that already follows a coherent equivalent structure.

Repository Structure

flutter-feature-based-architecture/
├── SKILL.md
└── references/
    ├── handwritten-feature-example.md
    └── pagination-async-notifier-example.md

The documentation visuals are available at docs/images/feature-first-architecture-agent-hierarchy.png and docs/images/sample-feature-capabilities.png.

Riverpod Version and Code Generation

The examples target flutter_riverpod 3.0.0 or later within the 3.x release line. They use the public handwritten provider APIs and do not require annotations or generated source files.

Existing projects may still contain legacy providers or generated code. The skill preserves compatible existing architecture when necessary but does not expand that surface in unrelated new work.

Validation

The skill package passes the skill-creator structural validator. Its Riverpod examples were also assembled in a temporary Flutter package pinned to flutter_riverpod 3.0.0 and checked with:

fvm dart analyze

The analyzer completed with no issues.

When changing the examples, validate them against Riverpod 3.0 before publishing so the minimum supported API remains accurate.

About

A scalable, feature-first architecture blueprint for Flutter applications. Built with clean code principles, clean separation of concerns, and structured by individual feature modules for ultimate maintainability.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors