Disclamer: This is an experimentation for sharing cursor rules between several flutter projects.
We are currently using this repository to iterate on the sharing system and on the rules themselves.
β Important! Cursor rules currently don't work well in workspace mode : Only the first folder (in alphabetical order) is detected. It should work in most case for the app folder if you name it "Application" (or anything with an "a"), but not for the other repositories of your monorepo
Source : https://forum.cursor.com/t/cursor-rules-files-for-multi-project-workspace/48086
You have 2 options for fetching the rules in your project:
manually download the flutter-shared-rules.mdc
file in a .cursor/rules
folder
β Simple setup & project management.
β Need to do it again each time the file is updated, for all your projects.
- In the
melos.yaml
file of the project (replace<app folder>
by your app folder's name):
bootstrap:
[...]
hooks:
post: melos fetch_ai_rules
[...]
scripts:
[...]
fetch_ai_rules:
run: |
curl -L -s https://raw.githubusercontent.com/bamlab/flutter-ai-rules/refs/heads/main/flutter-shared-rules.mdc -o <app folder>/.cursor/rules/shared/flutter-shared-rules.mdc
description: Fetch AI rules
β Simple setup & project management.
β Rules are updated at eachmelos bootstrap
.
deprecated
Automated fetch - if this repository is private
- In the project where you want to add the rules (replace
<app folder>
by your app folder's name):
git submodule add [email protected]:bamlab/flutter-ai-rules.git <app folder>/.cursor/rules/shared && git submodule update --remote --init -- <app folder>/.cursor/rules/shared && git commit -m "devx(cursor) create cursor rules submodule"
- In the
melos.yaml
file of the project (replace<app folder>
by your app folder's name):
bootstrap:
[...]
hooks:
post: melos fetch_ai_rules
[...]
scripts:
[...]
fetch_ai_rules:
run: |
git submodule update --remote --merge -- <app folder>/.cursor/rules/shared
description: Fetch AI rules
β Rules are updated at each
melos bootstrap
.
β Every dev on the project must have access to this repo, or will see some error after runningmelos bootstrap
.
π When committing the rules changes on the project, the commit is unreadable. Nevertheless, this change has already been reviewed on this repository
π‘ If you want to interact manually with the submodule, be aware that git submodules badly support adding submodules in folders that begin by
.
. If you do so, you must always specify-- <submodule path>
in yourgit submodule
commands. You can also runcd <submodule path>
and use regular git commands, it will work well. Don't push anything on this rules repository though
π‘ If you use the "source control" view of vscode, you can see a new section after adding the submodule. You can easily close it with a right click on its header.
at the root of your project:
- remove the submodule from
.gitmodules
- remove the submodule from
.git/modules
- by default,
.git
is not visible in vscode: open finder and show hidden files (cmd
+shift
+.
)
- by default,