flutter-bloc-development
Build Flutter features using BLoC state management, clean architecture layers, and the project's design system. Apply when creating screens, widgets, or data integrations.
What this skill does
# Flutter BLoC Development
This skill enforces BLoC state management, strict layer separation, and mandatory use of design system constants for all Flutter development in this codebase.
## Decision Tree: Choosing Your Approach
```
User task → What are they building?
│
├─ New screen/feature → Full feature implementation:
│ 1. Create feature folder (lib/[feature]/)
│ 2. Define BLoC (bloc/[feature]_event.dart, _state.dart, _bloc.dart)
│ 3. Create data layer (data/datasources/, data/repositories/, data/models/)
│ 4. Build UI (view/[feature]_page.dart, view/widgets/)
│ 5. Create barrel files ([feature].dart, data/data.dart, view/view.dart)
│
├─ New widget only → Presentation layer:
│ 1. Feature-specific: feature/view/widgets/
│ 2. Shared/reusable: shared/widgets/
│ 3. Use design system constants (NO hardcoded values)
│ 4. Connect to existing BLoC if needed
│
├─ Data integration → Data layer only:
│ 1. Create datasource (feature/data/datasources/)
│ 2. Create repository (feature/data/repositories/)
│ 3. Wire up in existing or new BLoC
│
└─ Refactoring → Identify violations:
1. Check for hardcoded colors/spacing/typography
2. Check for business logic in UI
3. Check for direct SDK calls outside datasources
4. Check for missing Loading state before async operations
5. Check for missing Equatable on Events/States
6. Check for improper error handling (use SnackBar + AppColors.error)
```
## Architecture at a Glance
**Feature-first structure** (official BLoC recommendation):
```
lib/
├── [feature]/ # Feature folder (e.g., earnings/, auth/, trips/)
│ ├── bloc/
│ │ ├── [feature]_bloc.dart
│ │ ├── [feature]_event.dart
│ │ └── [feature]_state.dart
│ ├── data/
│ │ ├── datasources/ # Feature-specific API calls
│ │ ├── repositories/ # Data orchestration
│ │ ├── models/ # Feature-specific DTOs
│ │ └── data.dart # Data layer barrel file
│ ├── view/
│ │ ├── [feature]_page.dart # Main screen
│ │ ├── widgets/ # Feature-specific widgets
│ │ └── view.dart # View barrel file
│ └── [feature].dart # Feature barrel file
├── shared/ # Cross-feature code
│ ├── data/
│ │ ├── datasources/ # Shared API clients (ApiClient, UserDataSource)
│ │ ├── models/ # Shared models (User, ApiResponse)
│ │ └── data.dart # Shared data barrel file
│ ├── widgets/ # Reusable UI components
│ └── utils/ # Design system (colors, spacing, typography)
└── app.dart # App entry point
```
### When to Use Feature vs Shared Data
| Scenario | Location | Example |
|----------|----------|---------|
| API endpoints used by ONE feature | `feature/data/` | `EarningsDataSource` → `/api/earnings/...` |
| API client/service used by MANY features | `shared/data/` | `ApiClient`, `UserDataSource` |
| Models used by ONE feature | `feature/data/models/` | `EarningsSummary` |
| Models used by MANY features | `shared/data/models/` | `User`, `ApiResponse` |
**Barrel Files** — Single import per layer:
```dart
// Feature barrel: earnings/earnings.dart
export 'bloc/earnings_bloc.dart';
export 'bloc/earnings_event.dart';
export 'bloc/earnings_state.dart';
export 'data/data.dart';
export 'view/view.dart';
// Data layer barrel: earnings/data/data.dart
export 'datasources/earnings_datasource.dart';
export 'repositories/earnings_repository.dart';
export 'models/earnings_summary.dart';
// Shared data barrel: shared/data/data.dart
export 'datasources/api_client.dart';
export 'datasources/user_datasource.dart';
export 'models/user.dart';
```
**Key Rules:**
- All state changes flow through BLoC
- No direct backend SDK calls outside datasources
- Zero hardcoded values (colors, spacing, typography)
- Repository pattern for all data access
- Feature-specific code stays in feature folder
- Shared code (used by 2+ features) goes in `shared/`
---
## BLoC Implementation
### Event → State → BLoC (Three Files Per Feature)
**Events** — User actions and system triggers:
```dart
abstract class FeatureEvent extends Equatable {
const FeatureEvent();
@override
List<Object?> get props => [];
}
class FeatureActionRequested extends FeatureEvent {
final String param;
const FeatureActionRequested({required this.param});
@override
List<Object> get props => [param];
}
```
**States** — All possible UI states:
```dart
abstract class FeatureState extends Equatable {
const FeatureState();
@override
List<Object?> get props => [];
}
class FeatureInitial extends FeatureState {}
class FeatureLoading extends FeatureState {}
class FeatureSuccess extends FeatureState {
final DataType data;
const FeatureSuccess(this.data);
@override
List<Object> get props => [data];
}
class FeatureError extends FeatureState {
final String message;
const FeatureError(this.message);
@override
List<Object> get props => [message];
}
```
**BLoC** — Event handlers with Loading → Success/Error pattern:
```dart
class FeatureBloc extends Bloc<FeatureEvent, FeatureState> {
final FeatureRepository _repository;
FeatureBloc({required FeatureRepository repository})
: _repository = repository,
super(FeatureInitial()) {
on<FeatureActionRequested>(_onActionRequested);
}
Future<void> _onActionRequested(
FeatureActionRequested event,
Emitter<FeatureState> emit,
) async {
emit(FeatureLoading());
try {
final result = await _repository.doSomething(event.param);
emit(FeatureSuccess(result));
} catch (e) {
emit(FeatureError(e.toString()));
}
}
}
```
**CRITICAL**: Always emit `Loading` before async work, then `Success` or `Error`. Never skip the loading state.
---
## Data Layer
**Data Flow:**
```
UI Event → BLoC (emit Loading) → Repository → Datasource (SDK)
↓
Response → Repository (map to entity) → BLoC (emit Success/Error) → UI
```
**Datasource** — Backend SDK calls only:
```dart
class FeatureDataSource {
final SupabaseClient _supabase;
FeatureDataSource(this._supabase);
Future<Map<String, dynamic>> fetch() async {
return await _supabase.from('table').select().single();
}
}
```
**Repository** — Orchestration and mapping:
```dart
class FeatureRepository {
final FeatureDataSource _dataSource;
FeatureRepository(this._dataSource);
Future<DomainEntity> fetchData() async {
final response = await _dataSource.fetch();
return DomainEntity.fromJson(response);
}
}
```
---
## Design System (Non-Negotiable)
### Colors
✅ `AppColors.primary`, `AppColors.error`, `AppColors.textPrimary`
❌ `Color(0xFF...)`, `Colors.blue`, inline hex values
### Spacing
✅ `AppSpacing.xs` (4), `AppSpacing.sm` (8), `AppSpacing.md` (16), `AppSpacing.lg` (24), `AppSpacing.xl` (32)
✅ `AppSpacing.screenHorizontal` (24), `AppSpacing.screenVertical` (16)
❌ `EdgeInsets.all(16.0)`, hardcoded padding values
### Border Radius
✅ `AppRadius.sm` (8), `AppRadius.md` (12), `AppRadius.lg` (16), `AppRadius.xl` (24)
❌ `BorderRadius.circular(12)`, inline radius values
### Typography
✅ `AppTypography.headlineLarge`, `AppTypography.bodyMedium`, `theme.textTheme.bodyMedium`
❌ `TextStyle(fontSize: 16)`, inline text styles
---
## UI Patterns
### Screen Template
```dart
GradientScaffold(
body: SafeArea(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(AppSpacing.screenHorizontal),
child: HeaderWidget(),
),
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.screenHorizontal),
child: ContentWidget(),
),
),
Padding(
padding: const EdgeInsets.all(AppSpacing.screenHorizontal),
chiRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.