Skip to content

Commit 8521f39

Browse files
committed
feat(skills): add very-good-analysis-upgrade
1 parent 7d3f6b0 commit 8521f39

1 file changed

Lines changed: 167 additions & 0 deletions

File tree

  • skills/linting/very_good_analysis_upgrade
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
name: upgrade-very-good-analysis
3+
description: >
4+
Upgrade the `very_good_analysis` lint package to a new version across Dart/Flutter projects.
5+
Handles the full upgrade workflow: bumping the version in pubspec.yaml, running flutter analyze
6+
to surface new lint warnings from newly enabled rules, fixing those warnings with minimal focused
7+
changes, and opening a PR that contains only the version bump and lint fixes.
8+
Use this skill whenever the user mentions "upgrade very_good_analysis", "bump VGA", "new very_good_analysis
9+
version is out", "update lint rules", "very_good_analysis PR", "flutter lint upgrade", or any
10+
request to update the analysis options package in a Flutter or Dart project — even if they just
11+
say "the new VGA is on pub.dev, can you open the PR?". Also use it when someone asks to fix
12+
lint warnings that appeared after a very_good_analysis bump.
13+
---
14+
15+
# Upgrade very_good_analysis
16+
17+
This skill guides the full upgrade of `very_good_analysis` in a Dart or Flutter project.
18+
The goal is a clean, focused PR: nothing more than the version bump in `pubspec.yaml` plus
19+
the minimal code changes needed to satisfy any new lint rules introduced in that version.
20+
21+
---
22+
23+
## Before You Start
24+
25+
Confirm two things before proceeding:
26+
27+
1. **Target version** — if the user didn't specify a version, fetch the latest from the pub.dev API
28+
and use that. Don't ask — just look it up and proceed:
29+
30+
```bash
31+
curl -s https://pub.dev/api/packages/very_good_analysis | python3 -c \
32+
"import sys, json; d=json.load(sys.stdin); print(d['latest']['version'])"
33+
```
34+
35+
Tell the user which version you're upgrading to before making any changes.
36+
37+
2. **Project scope** — is this a single package or a monorepo? In a monorepo, each sub-package
38+
with its own `pubspec.yaml` needs its own bump (and potentially its own PR).
39+
40+
---
41+
42+
## Step 1 — Bump the version in pubspec.yaml
43+
44+
Locate the `pubspec.yaml` file(s) for the project. Update the `very_good_analysis` entry under
45+
`dev_dependencies`:
46+
47+
```yaml
48+
dev_dependencies:
49+
very_good_analysis: ^x.y.z # replace x.y.z with the target version
50+
```
51+
52+
Keep the caret (`^`) prefix — that's the VGV convention. Don't change anything else in the file.
53+
54+
After editing, run:
55+
56+
```bash
57+
flutter pub get
58+
```
59+
60+
(For a pure Dart package without Flutter, use `dart pub get` instead.)
61+
62+
Use the Dart/Flutter MCP server if it is connected and exposes pub commands; otherwise run via Bash.
63+
64+
---
65+
66+
## Step 2 — Run flutter analyze
67+
68+
```bash
69+
flutter analyze
70+
```
71+
72+
Or for a pure Dart package:
73+
74+
```bash
75+
dart analyze
76+
```
77+
78+
Capture the full output. You're looking for new warnings or errors introduced by the version bump —
79+
lints that weren't flagged before. Ignore pre-existing issues unrelated to the bump (don't fix
80+
things that were already broken; that belongs in a separate PR).
81+
82+
---
83+
84+
## Step 3 — Fix the lint warnings
85+
86+
Work through the warnings one by one. Keep fixes **minimal and lint-compliance-only**:
87+
88+
- Fix only what `flutter analyze` flags
89+
- Don't refactor, rename, or reorganize anything beyond what's needed
90+
- Don't fix pre-existing lint warnings that existed before the bump
91+
- If a warning looks like it might require a behavioral change (not just style), flag it for
92+
human review rather than silently fixing it
93+
94+
Common patterns you'll encounter:
95+
96+
| Lint rule | Typical fix |
97+
| --------------------------- | ---------------------------------------------------- |
98+
| `prefer_const_constructors` | Add `const` keyword |
99+
| `use_super_parameters` | Convert `super.param` to initializer |
100+
| `unnecessary_late` | Remove `late` from immediately-initialized variables |
101+
| `avoid_dynamic_calls` | Cast the receiver to a specific type |
102+
| `require_trailing_commas` | Add trailing comma in argument/parameter lists |
103+
| `unnecessary_null_checks` | Remove redundant `!` operators |
104+
105+
After fixing, re-run `flutter analyze` to confirm zero warnings remain.
106+
107+
---
108+
109+
## Step 4 — Verify the fix is complete
110+
111+
Run the full analyze pass one more time to make sure nothing was missed:
112+
113+
```bash
114+
flutter analyze
115+
```
116+
117+
Expected output: `No issues found!` (or only pre-existing issues that you haven't touched).
118+
119+
If new warnings appear that weren't there after Step 2, address them now. If warnings persist
120+
after multiple attempts, list them explicitly and ask the user how they'd like to proceed.
121+
122+
---
123+
124+
## Step 5 — Create the PR
125+
126+
Stage only the changed files:
127+
128+
```bash
129+
git add pubspec.yaml pubspec.lock # always include these
130+
# plus any .dart files you edited for lint fixes
131+
```
132+
133+
Commit with a clear message following the project's conventions. A good default:
134+
135+
```
136+
chore: upgrade very_good_analysis to x.y.z
137+
138+
Bump very_good_analysis from <old> to <new> and resolve
139+
lint warnings introduced by newly enabled rules.
140+
```
141+
142+
Then push and open a PR. The PR should contain **nothing else** — no feature work, no unrelated
143+
refactors, no extra cleanup. Reviewers should be able to see at a glance that this is purely
144+
a lint compliance update.
145+
146+
If the project uses a PR template, fill it in. Mention specifically which rules were newly
147+
enabled if any warnings required code changes.
148+
149+
---
150+
151+
## Tips and edge cases
152+
153+
**Monorepos**: Each package that depends on `very_good_analysis` needs its own `pubspec.yaml`
154+
bump. You can often run `flutter analyze` from the repo root to surface all warnings at once,
155+
but `pub get` must be run per-package.
156+
157+
**analysis_options.yaml**: `very_good_analysis` ships its own `analysis_options.yaml` that is
158+
included by the project's own options file. You generally don't need to touch the project's
159+
`analysis_options.yaml` — the bump in `pubspec.yaml` is sufficient to pull in the new rules.
160+
161+
**Breaking rule changes**: Occasionally a new version disables a rule that was previously
162+
enabled, or changes its severity. That might cause previously-flagged issues to disappear,
163+
which is fine — don't re-introduce them.
164+
165+
**flutter pub get fails**: If dependency resolution fails after the bump (version conflicts),
166+
investigate the conflict before proceeding. Don't force-upgrade other dependencies just to
167+
make the bump work — surface the conflict to the user.

0 commit comments

Comments
 (0)