| name | fix-arch |
| description | Audit a feature for Clean Architecture violations and produce a prioritized fix list. Use when generated code may have broken layer rules, missing use cases, or incorrect BLoC patterns. |
fix-arch — Architecture Audit
Scans a feature for violations and produces an actionable fix list.
When to use this skill
- Use this when generated code may have broken Clean Architecture layer rules.
- Use this to check for missing use cases, incorrect imports, unhandled BLoC states, or invalid DI scopes (like lazy singletons for BLoCs).
How to use it
Step 1 — Read the Feature
Read all files in lib/features/{feature}/ recursively. Also read:
lib/core/di/injection_container.dart
lib/app/router/app_router.dart
Step 2 — Run the Checklist
For each item below, mark PASS, FAIL, or N/A.
Layer Violations
Entity Rules
Repository Rules
BLoC / Cubit Rules
DI Rules
Router Rules
Step 3 — Report Format
Output a structured report:
## Architecture Audit: {feature}
### CRITICAL (breaks compile or runtime)
- [ ] {file}:{line} — {violation description} → Fix: {specific fix}
### HIGH (breaks architecture contract)
- [ ] {file}:{line} — {violation description} → Fix: {specific fix}
### MEDIUM (bad practice, won't crash now)
- [ ] {file}:{line} — {violation description} → Fix: {specific fix}
### PASS
- ✓ Layer imports correct
- ✓ Sealed states used
- (list all passing items)
Step 4 — Apply Fixes
If the user says "fix it" or "apply fixes":
- Fix CRITICAL items first — these block compilation
- Fix HIGH items — these break architecture guarantees
- Fix MEDIUM items — these improve long-term maintainability
- Run
flutter analyze after each fix batch
For each fix, explain what rule was violated and why the fix is correct.
Common Violations and Their Fixes
| Violation | Fix |
|---|
Entity has fromJson | Move to model in data/models/ |
BLoC calls _remoteDataSource directly | Add use case, BLoC calls use case |
abstract class Event | Change to sealed class |
default: on sealed switch | Add explicit case for each missing state |
registerLazySingleton<ProductBloc> | Change to registerFactory |
context.read() in initState | Wrap in Future.microtask(() { if (!mounted) return; ... }) |
context.go('/path') | Change to context.goNamed(AppRoutes.xxx) |
state.matchedLocation | Change to state.uri.path |