Skip to content

Commit b05c12c

Browse files
Wreoslozhkovoi
andauthored
feat: sync official Flutter AI rules profiles (#10)
* feat: sync official Flutter AI rules profiles * fix: make API guard runner-compatible and fix AI docs link --------- Co-authored-by: Aleksandr Lozhkovoi <aleksandr.lozhkovoi@enpal.de>
1 parent 1f2fdbb commit b05c12c

14 files changed

Lines changed: 554 additions & 5 deletions

.cursor-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "flutter-cursor-plugin",
33
"displayName": "Flutter Cursor Plugin",
4-
"version": "1.8.0",
4+
"version": "1.9.0",
55
"description": "Open-source Cursor plugin for end-to-end Flutter development and testing with Dart MCP, Figma MCP, practical architecture patterns, and reliable test workflows.",
66
"author": {
77
"name": "Aleksandr Lozhkovoi",

.github/scripts/api_stability_guard.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ if [[ "${head_root_version}" == "${base_root_version}" && "${head_canonical_vers
4141
exit 1
4242
fi
4343

44-
if ! git diff --name-only "${diff_range}" | rg -q '^CHANGELOG\.md$'; then
44+
if ! git diff --name-only "${diff_range}" | grep -Eq '^CHANGELOG\.md$'; then
4545
echo "API surface changed but CHANGELOG.md was not updated."
4646
exit 1
4747
fi
4848

4949
breaking_change=false
50-
if echo "${api_name_status}" | rg -q '^(D|R[0-9]*)\s'; then
50+
if echo "${api_name_status}" | grep -Eq '^(D|R[0-9]+)[[:space:]]'; then
5151
breaking_change=true
5252
fi
5353

@@ -81,7 +81,7 @@ if [[ "${breaking_change}" == true ]]; then
8181
exit 1
8282
fi
8383

84-
if ! git diff -U0 "${diff_range}" -- CHANGELOG.md | rg -qi '^\+.*breaking'; then
84+
if ! git diff -U0 "${diff_range}" -- CHANGELOG.md | grep -Eiq '^\+.*breaking'; then
8585
echo "Breaking API change detected; add a CHANGELOG line that includes the word 'breaking'."
8686
exit 1
8787
fi

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
## Unreleased
44

5+
- Added official Flutter AI rules sync workflow:
6+
- command: `commands/sync-official-flutter-ai-rules.md`
7+
- skill: `skills/sync-official-flutter-ai-rules/SKILL.md`
8+
- docs: `docs/flutter-ai-rules-sync.md`
9+
- sync script: `scripts/sync_official_flutter_ai_rules.sh`
10+
- Added synced official Flutter AI rules profiles:
11+
- `rules/official/flutter-ai-rules-10k.mdc`
12+
- `rules/official/flutter-ai-rules-4k.mdc`
13+
- `rules/official/flutter-ai-rules-1k.mdc`
14+
- active: `rules/flutter-official-ai-rules.mdc`
515
- Added dedicated security posture documentation (`docs/security-posture.md`) with `/security-review` scope, false-positive handling, and CI integration guidance.
616
- Added a "Value in 5 minutes" demo section to `README.md` with one-prompt flow and three copy-ready scenarios.
717
- Added visual demo artifact `assets/demo-5min-flow.svg` for quick onboarding value proof.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Three ready-to-run scenarios:
8787
- `setup-mobile-github-pipeline`
8888
- `integrate-firebase`
8989
- `security-review`
90+
- `sync-official-flutter-ai-rules`
9091
- `write-widget-test`
9192
- `write-bloc-test`
9293
- `write-e2e-test`
@@ -105,13 +106,15 @@ Three ready-to-run scenarios:
105106
- `skills/migrate-flutter-code/`
106107
- `skills/update-flutter-dependencies/`
107108
- `skills/security-audit/`
109+
- `skills/sync-official-flutter-ai-rules/`
108110

109111
## MCP integrations
110112

111113
- **Dart MCP**: use for analysis, fix suggestions, formatting guidance, and project-aware Dart/Flutter workflows.
112114
- **Figma MCP**: use when translating Figma nodes/screens to Flutter UI with higher visual fidelity.
113115
- **Effective Dart**: align implementation with the official guidance at https://dart.dev/effective-dart.
114116
- **Claude `/security-review` parity**: security workflow mirrors `anthropics/claude-code-security-review` patterns (diff-aware + false-positive filtering).
117+
- **Official Flutter AI rules sync**: use `sync-official-flutter-ai-rules` to refresh upstream Flutter rules profiles.
115118

116119
## Official documentation
117120

@@ -123,6 +126,7 @@ Three ready-to-run scenarios:
123126
- Claude Code Security Review: https://github.com/anthropics/claude-code-security-review
124127
- Cursor plugin schema: https://raw.githubusercontent.com/cursor/plugins/main/schemas/plugin.schema.json
125128
- Flutter MCP server docs: https://docs.flutter.dev/ai/mcp-server
129+
- Flutter AI docs: https://docs.flutter.dev/ai
126130

127131
## Requirements
128132

@@ -161,6 +165,9 @@ Three ready-to-run scenarios:
161165
- `docs/dependency-upgrade-checklist.md`
162166
11. For monorepo/workspace setups, follow:
163167
- `docs/monorepo-workspace-guide.md`
168+
12. To sync official Flutter AI rules profiles (`10k`/`4k`/`1k`), use:
169+
- `sync-official-flutter-ai-rules`
170+
- `docs/flutter-ai-rules-sync.md`
164171

165172
Note: every code review flow includes mandatory security checks (OWASP MASVS-oriented).
166173

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: sync-official-flutter-ai-rules
3+
description: Sync official Flutter AI rules from Flutter upstream and select active profile (10k, 4k, 1k).
4+
---
5+
6+
Sync official Flutter AI rules into the plugin repository.
7+
8+
1. Follow `../skills/sync-official-flutter-ai-rules/SKILL.md`.
9+
2. Pick profile by context size:
10+
- `10k` for maximum guidance depth.
11+
- `4k` for balanced detail and token usage.
12+
- `1k` for minimal and fast context.
13+
3. Run `scripts/sync_official_flutter_ai_rules.sh <10k|4k|1k>`.
14+
4. Commit synced files under `rules/official/` and active file `rules/flutter-official-ai-rules.mdc`.

docs/flutter-ai-rules-sync.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Official Flutter AI Rules Sync
2+
3+
This document explains how to sync and use official Flutter AI rules in this plugin.
4+
5+
## Why this exists
6+
7+
Flutter publishes official AI rules in multiple sizes. This repository keeps a synced copy and exposes an active profile.
8+
9+
## Profiles
10+
11+
- `10k`: full and most detailed profile.
12+
- `4k`: balanced profile (recommended default).
13+
- `1k`: compact profile for constrained contexts.
14+
15+
## Sync command
16+
17+
Run from repository root:
18+
19+
```bash
20+
scripts/sync_official_flutter_ai_rules.sh <10k|4k|1k>
21+
```
22+
23+
Example:
24+
25+
```bash
26+
scripts/sync_official_flutter_ai_rules.sh 4k
27+
```
28+
29+
## Generated files
30+
31+
- `rules/official/flutter-ai-rules-10k.mdc`
32+
- `rules/official/flutter-ai-rules-4k.mdc`
33+
- `rules/official/flutter-ai-rules-1k.mdc`
34+
- `rules/flutter-official-ai-rules.mdc` (active profile copy)
35+
36+
## Upstream sources
37+
38+
- https://raw.githubusercontent.com/flutter/flutter/main/docs/rules/rules_10k.md
39+
- https://raw.githubusercontent.com/flutter/flutter/main/docs/rules/rules_4k.md
40+
- https://raw.githubusercontent.com/flutter/flutter/main/docs/rules/rules_1k.md
41+
- https://docs.flutter.dev/ai

docs/official-release-checklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Use this checklist before tagging a public release.
1919

2020
- Dart MCP workflow is documented and referenced by relevant agents/commands.
2121
- Figma MCP workflow is documented for UI implementation paths.
22+
- Official Flutter AI rules sync workflow is documented (`docs/flutter-ai-rules-sync.md`).
2223

2324
## Open source readiness
2425

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "flutter-cursor-plugin",
33
"displayName": "Flutter Cursor Plugin",
4-
"version": "1.8.0",
4+
"version": "1.9.0",
55
"description": "Open-source Cursor plugin for end-to-end Flutter development and testing with Dart MCP, Figma MCP, practical architecture patterns, and reliable test workflows.",
66
"author": "Aleksandr Lozhkovoi",
77
"license": "MIT",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!--
2+
Synced from official Flutter AI rules.
3+
Source: https://raw.githubusercontent.com/flutter/flutter/main/docs/rules/rules_4k.md
4+
Profile: 4k
5+
Do not edit manually; run scripts/sync_official_flutter_ai_rules.sh.
6+
-->
7+
8+
# AI Rules for Flutter
9+
10+
## Persona & Tools
11+
* **Role:** Expert Flutter Developer. Focus: Beautiful, performant, maintainable code.
12+
* **Explanation:** Explain Dart features (null safety, streams, futures) for new users.
13+
* **Tools:** ALWAYS run `dart_format`. Use `dart_fix` for cleanups. Use `analyze_files` with `flutter_lints` to catch errors early.
14+
* **Dependencies:** Add with `flutter pub add`. Use `pub_dev_search` for discovery. Explain why a package is needed.
15+
16+
## Architecture & Structure
17+
* **Entry:** Standard `lib/main.dart`.
18+
* **Layers:** Presentation (Widgets), Domain (Logic), Data (Repo/API).
19+
* **Features:** Group by feature (e.g., `lib/features/login/`) for scalable apps.
20+
* **SOLID:** strictly enforced.
21+
* **State Management:**
22+
* **Pattern:** Separate UI state (ephemeral) from App state.
23+
* **Native First:** Use `ValueNotifier`, `ChangeNotifier`.
24+
* **Prohibited:** NO Riverpod, Bloc, GetX unless explicitly requested.
25+
* **DI:** Manual constructor injection or `provider` package if requested.
26+
27+
## Code Style & Quality
28+
* **Naming:** `PascalCase` (Types), `camelCase` (Members), `snake_case` (Files).
29+
* **Conciseness:** Functions <20 lines. Avoid verbosity.
30+
* **Null Safety:** NO `!` operator. Use `?` and flow analysis (e.g. `if (x != null)`).
31+
* **Async:** Use `async/await` for Futures. Catch all errors with `try-catch`.
32+
* **Logging:** Use `dart:developer` `log()` locally. NEVER use `print`.
33+
34+
## Flutter Best Practices
35+
* **Build Methods:** Keep pure and fast. No side effects. No network calls.
36+
* **Isolates:** Use `compute()` for heavy tasks like JSON parsing.
37+
* **Lists:** `ListView.builder` or `SliverList` for performance.
38+
* **Immutability:** `const` constructors everywhere validation. `StatelessWidget` preference.
39+
* **Composition:** Break complex builds into private `class MyWidget extends StatelessWidget`.
40+
41+
## Routing (GoRouter)
42+
Use `go_router` exclusively for deep linking and web support.
43+
44+
```dart
45+
final _router = GoRouter(routes: [
46+
GoRoute(path: '/', builder: (_, __) => Home()),
47+
GoRoute(path: 'details/:id', builder: (_, s) => Detail(id: s.pathParameters['id']!)),
48+
]);
49+
MaterialApp.router(routerConfig: _router);
50+
```
51+
52+
## Data (JSON)
53+
Use `json_serializable` with `fieldRename: FieldRename.snake`.
54+
55+
```dart
56+
@JsonSerializable(fieldRename: FieldRename.snake)
57+
class User {
58+
final String name;
59+
User({required this.name});
60+
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
61+
}
62+
```
63+
64+
## Visual Design (Material 3)
65+
* **Aesthetics:** Premium, custom look. "Wow" the user. Avoid default blue.
66+
* **Theme:** Use `ThemeData` with `ColorScheme.fromSeed`.
67+
* **Modes:** Support Light & Dark modes (`ThemeMode.system`).
68+
* **Typography:** `google_fonts`. Define a consistent Type Scale.
69+
* **Layout:** `LayoutBuilder` for responsiveness. `OverlayPortal` for popups.
70+
* **Components:** Use `ThemeExtension` for custom tokens (colors/sizes).
71+
72+
## Testing
73+
* **Tools:** `flutter test` (Unit), `flutter_test` (Widget), `integration_test` (E2E).
74+
* **Mocks:** Prefer Fakes. Use `mockito` sparingly.
75+
* **Pattern:** Arrange-Act-Assert.
76+
* **Assertions:** Use `package:checks`.
77+
78+
## Accessibility (A11Y)
79+
* **Contrast:** 4.5:1 minimum for text.
80+
* **Semantics:** Label all interactive elements specifically.
81+
* **Scale:** Test dynamic font sizes (up to 200%).
82+
* **Screen Readers:** Verify with TalkBack/VoiceOver.
83+
84+
## Commands Reference
85+
* **Build Runner:** `dart run build_runner build --delete-conflicting-outputs`
86+
* **Test:** `flutter test .`
87+
* **Analyze:** `flutter analyze .`

0 commit comments

Comments
 (0)