ワンクリックで
flutter-code-review
针对 Flutter 项目的深度工程化审查工具。用于检测架构异味、强制执行 SOLID 原则、优化状态管理流向以及确保代码的可测试性和可维护性。当用户请求 Review、重构或优化 Dart 代码时触发。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
针对 Flutter 项目的深度工程化审查工具。用于检测架构异味、强制执行 SOLID 原则、优化状态管理流向以及确保代码的可测试性和可维护性。当用户请求 Review、重构或优化 Dart 代码时触发。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
PocketMind 本地无头浏览器爬取架构,适用于小红书/知乎抓取、后台爬虫服务、MethodChannel、Cookie 管理与 MetadataManager 协作场景。
Use when implementing or debugging PocketMind mobile chat flows, including note-scoped sessions, global multi-session switching, sync gating, stream send behavior, and dialog interaction regressions.
PocketMind 后端 notes->resource_records->context_catalog 一致性改造专项 Skill。当用户讨论 resource_records 真相层、context_catalog 索引层、Outbox/Projector、检索 fallback、SessionCommit 长事务、transcript 重复同步或相关回归测试时必须触发。
Use when you need to understand or modify PocketMind note save to resource indexing flow, including outbox, MQ hint/DLQ compensation, projector consumption, and consistency boundaries.
PocketMind 移动端笔记同步架构专项 Skill。当涉及以下问题时必须触发:预览字段(previewTitle等)被同步覆盖、多端一致性与离线冲突问题、同步链路改造(Pull/Push)、UI层违规调用底层Provider、抓取/轮询等写入未进入同步队列、或维护同步守卫测试。
设计、重构和实现 PocketMind 项目中的整体上下文架构(Context Architecture),用于统一规划和落地 resources、user memories、agent memories、tenant skills、session、retrieval、ingestion、storage 与现有 Note/Chat/Asset 的边界。当用户要求为 PocketMind 新增长期记忆、重构 AI 上下文体系、借鉴 OpenViking 的上下文类型/层级/URI/存储/检索/会话思想,或需要分阶段实施 Context Service 时使用。
| name | flutter-code-review |
| description | 针对 Flutter 项目的深度工程化审查工具。用于检测架构异味、强制执行 SOLID 原则、优化状态管理流向以及确保代码的可测试性和可维护性。当用户请求 Review、重构或优化 Dart 代码时触发。 |
本 Skill 旨在将一段随意的 Flutter 代码转化为符合企业级标准的工程代码。它不进行闲聊,不提供模棱两可的建议,直接输出符合架构标准的重构代码。
Repository 接口而非具体实现类。final 字段和 const 构造函数。状态类应当是不可变的 (@immutable / freezed),通过 copyWith 更新而非直接修改属性。try-catch 不应散落在 UI 中。错误应在 Repository 层捕获并转化为自定义 Failure 类型,最终由状态管理层统一暴露给 UI。build() 方法必须无副作用。BuildContext 跨异步间隙使用必须有 mounted 检查。Controller, StreamSubscription, Timer 的 dispose 逻辑。当收到代码时,不进行寒暄,直接按照以下步骤处理:
输出必须严格遵循以下格式,无多余废话:
[规则名称]: 一句话解释违反了什么工程原则(如:违反单一职责,UI 直接依赖数据库)。
// Refactored Code (直接可用的修复代码)
class UserProfileNotifier extends StateNotifier<UserState> {
final UserRepository _repository; // 依赖接口
UserProfileNotifier(this._repository) : super(const UserState.initial());
Future<void> updateProfile(String name) async {
try {
// 业务逻辑内聚
final result = await _repository.updateName(name);
state = state.copyWith(data: result);
} catch (e) {
state = state.copyWith(error: UserFailure.from(e));
}
}
}
[优化点]: 说明性能或规范问题(如:缺少 const,列表未复用)。
// Optimized Code
ListView.builder(
itemExtent: 50.0, // 强制高度优化性能
itemCount: items.length,
itemBuilder: (context, index) => const UserListItem(key: ValueKey(id)), // const + keys
);
❌ Bad:
// UI 直接调用 HTTP
onTap: () async {
var response = await http.post('api/user');
if (response.statusCode == 200) setState(() { ... });
}
✅ Standard:
// UI 仅分发事件
onTap: () => ref.read(userControllerProvider.notifier).updateUser();
❌ Bad:
class MyWidget {
final ApiService api = ApiService(); // 直接依赖实现
}
✅ Standard:
class MyWidget {
final IApiService api; // 依赖抽象
const MyWidget({required this.api});
}
❌ Bad:
class State {
List<String> items = []; // 可变列表
}
state.items.add('new'); // 难以追踪变更
✅ Standard:
@freezed
class State with _$State {
const factory State({@Default([]) List<String> items}) = _State;
}
// update
state = state.copyWith(items: [...state.items, 'new']);