@mallardbay/cursor-rules 1.0.33 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/frontend/rules/ui.mdc +3 -0
- package/.cursor/frontend-mobile/rules/{ui.mdc → mobile-ui.mdc} +1 -0
- package/.cursor/frontend-mobile/rules/react-native.mdc +92 -0
- package/.cursor/rules/general-best-practices.mdc +11 -0
- package/.cursor/shared/skills/address-pr-feedback/SKILL.md +28 -1
- package/.cursor/shared/skills/check-and-fix-ci/SKILL.md +22 -0
- package/.cursor/shared/skills/commit-and-pr/SKILL.md +83 -76
- package/.cursor/shared/skills/commit-and-push/SKILL.md +7 -9
- package/.cursor/shared/skills/prep-for-pr/SKILL.md +31 -0
- package/.cursor/shared/skills/review-pr/SKILL.md +28 -4
- package/.cursor/shared/skills/should-we-merge/SKILL.md +23 -0
- package/package.json +1 -1
|
@@ -48,6 +48,9 @@ Maintain clean and consistent component structure:
|
|
|
48
48
|
|
|
49
49
|
- Use existing components in @mallardbay/lib-react-components, @mallardbay/lib-react-components is based off Crakra UI v2
|
|
50
50
|
- If no component available in @mallardbay/lib-react-components, create one using Crakra UI and place it under src/components/shared/todo-lib-react-components/ to me moved later
|
|
51
|
+
- **Do not import directly from `@chakra-ui/react`**—always import components, hooks, and utilities from `@mallardbay/lib-react-components` instead
|
|
52
|
+
- This ensures a consistent design system, proper theming, and easier future migrations
|
|
53
|
+
- If something you need is not re-exported by `@mallardbay/lib-react-components`, add it there first rather than importing from `@chakra-ui/react` directly
|
|
51
54
|
|
|
52
55
|
## Responsive Design
|
|
53
56
|
|
|
@@ -87,6 +87,7 @@ Maintain clean and consistent component structure:
|
|
|
87
87
|
### React Native Specifics
|
|
88
88
|
|
|
89
89
|
- Use `StyleSheet.create` or NativeBase style props — avoid inline object styles
|
|
90
|
+
- **`StyleSheet.create` must be placed at the bottom of the file** — never at the top. See [react-native.mdc](mdc:react-native.mdc) for full file ordering and the `useStyles` hook pattern
|
|
90
91
|
- Prefer `FlatList` / `SectionList` over mapping arrays for long lists
|
|
91
92
|
- Use platform-specific extensions (`.ios.tsx`, `.android.tsx`) only when behavior genuinely diverges
|
|
92
93
|
- Test on both iOS and Android
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: React Native specific conventions for styling, component structure, and patterns that complement the general UI and TypeScript rules
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# React Native Development Standards
|
|
8
|
+
|
|
9
|
+
These rules extend the general UI, TypeScript, and code quality standards with React Native specific conventions.
|
|
10
|
+
|
|
11
|
+
## Styling
|
|
12
|
+
|
|
13
|
+
### File Ordering for Styles
|
|
14
|
+
|
|
15
|
+
StyleSheet definitions must live at the **bottom** of the file, after all component and helper definitions—following the same principle as types. This keeps the scannable, important logic (exports, components, hooks) at the top.
|
|
16
|
+
|
|
17
|
+
**File ordering for RN component files:**
|
|
18
|
+
|
|
19
|
+
1. Imports
|
|
20
|
+
2. Constants
|
|
21
|
+
3. Exported components / functions
|
|
22
|
+
4. Helpers and non-exported definitions
|
|
23
|
+
5. Types (when not imported)
|
|
24
|
+
6. StyleSheet definitions (`StyleSheet.create`)
|
|
25
|
+
|
|
26
|
+
### Prefer Hook-Based Styling Over Static StyleSheets
|
|
27
|
+
|
|
28
|
+
When styles need access to **theme values, colors, spacing, or any dynamic context**, use a `useStyles` hook pattern instead of a top-level `StyleSheet.create`. This avoids hardcoding values that should come from the theme and prevents painful refactors later.
|
|
29
|
+
|
|
30
|
+
- **Use `StyleSheet.create` only for truly static styles** that will never need theme values
|
|
31
|
+
- **Use a `useStyles` hook** when styles depend on theme, colors, spacing, or dynamic values
|
|
32
|
+
- Even when using `StyleSheet.create`, place it at the bottom of the file
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// Preferred: hook-based styling with theme access
|
|
36
|
+
function useStyles() {
|
|
37
|
+
const theme = useTheme()
|
|
38
|
+
|
|
39
|
+
return useMemo(
|
|
40
|
+
() =>
|
|
41
|
+
StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
padding: theme.space[4],
|
|
44
|
+
backgroundColor: theme.colors.background,
|
|
45
|
+
},
|
|
46
|
+
title: {
|
|
47
|
+
fontSize: theme.fontSizes.lg,
|
|
48
|
+
color: theme.colors.text,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
[theme]
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// Acceptable: static styles that genuinely don't need theme
|
|
58
|
+
// BUT must be at the BOTTOM of the file
|
|
59
|
+
const styles = StyleSheet.create({
|
|
60
|
+
row: {
|
|
61
|
+
flexDirection: "row",
|
|
62
|
+
alignItems: "center",
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Avoid Hardcoded Style Values
|
|
68
|
+
|
|
69
|
+
- Never hardcode colors — use theme colors
|
|
70
|
+
- Never hardcode spacing — use theme spacing
|
|
71
|
+
- Never hardcode font sizes — use theme typography
|
|
72
|
+
- If you find yourself reaching for a hardcoded value in `StyleSheet.create`, that's a signal to switch to `useStyles`
|
|
73
|
+
|
|
74
|
+
## Performance
|
|
75
|
+
|
|
76
|
+
### Lists
|
|
77
|
+
|
|
78
|
+
- Use `FlatList` or `SectionList` for long lists — never `ScrollView` with `.map()`
|
|
79
|
+
- Always provide a `keyExtractor`
|
|
80
|
+
- Use `getItemLayout` when item heights are known for better scroll performance
|
|
81
|
+
- Memoize `renderItem` callbacks with `useCallback`
|
|
82
|
+
|
|
83
|
+
### Images
|
|
84
|
+
|
|
85
|
+
- Use cached image libraries (e.g., `react-native-fast-image`) over the default `Image` when dealing with remote URLs
|
|
86
|
+
- Always specify image dimensions to avoid layout thrashing
|
|
87
|
+
|
|
88
|
+
### Animations
|
|
89
|
+
|
|
90
|
+
- Prefer `react-native-reanimated` over `Animated` API for complex animations
|
|
91
|
+
- Run animations on the UI thread when possible
|
|
92
|
+
- Avoid JS-driven animations for performance-critical interactions
|
|
@@ -82,6 +82,12 @@ These principles apply to all code changes and should guide every implementation
|
|
|
82
82
|
- Use shared test utilities and fixtures to reduce boilerplate
|
|
83
83
|
- Each test should be independent and runnable in isolation
|
|
84
84
|
|
|
85
|
+
### Before Pushing
|
|
86
|
+
- **Lint the entire project** before pushing—not just modified files. Use `yarn lint:quiet:slow` for a full deep check. Your changes may introduce lint errors in files you didn't directly edit (e.g. unused exports, circular dependencies, type mismatches)
|
|
87
|
+
- **Run related tests** before pushing to confirm nothing is broken. Identify test files related to your changes and run them. If unsure which tests are related, err on the side of running more rather than fewer
|
|
88
|
+
- **Fix any failures before pushing**—do not push code that fails lint or tests
|
|
89
|
+
- These checks are a hard gate: **no push without a clean lint and passing tests**
|
|
90
|
+
|
|
85
91
|
### Code Organization
|
|
86
92
|
- Group related functionality together
|
|
87
93
|
- Keep related code close (cohesion)
|
|
@@ -141,6 +147,11 @@ These principles apply to all code changes and should guide every implementation
|
|
|
141
147
|
5. **Verify the change works** end-to-end
|
|
142
148
|
6. **Check for side effects**—ensure changes don't break unrelated code
|
|
143
149
|
|
|
150
|
+
### Before Pushing
|
|
151
|
+
1. **Lint the entire project** with `yarn lint:quiet:slow`—not just modified files. Fix all failures
|
|
152
|
+
2. **Run related tests** and ensure they pass. If unsure which tests are related, run more rather than fewer
|
|
153
|
+
3. **Do not push** until lint and tests are clean
|
|
154
|
+
|
|
144
155
|
### When Changes Are Large
|
|
145
156
|
1. **Consider splitting** into multiple smaller PRs
|
|
146
157
|
2. **Use test sharding**—run tests in batches, not all at once
|
|
@@ -139,7 +139,34 @@ gh pr comment <number> --body "@reviewer Ready for another look! ✅"
|
|
|
139
139
|
|
|
140
140
|
## Output Format
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
Always start the output with the PR link and the branch preview URL (when available), then provide the rest of the summary.
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
**PR Link:** <pr-url>
|
|
146
|
+
**Branch Preview:** <preview-url> ← include only if detected; omit entirely otherwise
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Then provide: PR status (conflicts & checks), summary of feedback addressed, changes made, conversations resolved, remaining items, next steps.
|
|
150
|
+
|
|
151
|
+
### Detecting the Branch Preview URL
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
PR_NUMBER=<pr-number>
|
|
155
|
+
|
|
156
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
157
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
158
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
159
|
+
| .[0] // ""')
|
|
160
|
+
|
|
161
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
162
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
163
|
+
--jq '.comments[]?.body' \
|
|
164
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
165
|
+
| head -1)
|
|
166
|
+
fi
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Do not use a placeholder such as "n/a" when no preview URL is found—omit the line.
|
|
143
170
|
|
|
144
171
|
## Notes
|
|
145
172
|
|
|
@@ -120,6 +120,8 @@ gh run watch
|
|
|
120
120
|
```markdown
|
|
121
121
|
## CI Check Results
|
|
122
122
|
|
|
123
|
+
**PR Link:** <pr-url>
|
|
124
|
+
**Branch Preview:** <preview-url> ← include only if detected; omit entirely otherwise
|
|
123
125
|
**PR:** #<number> - <title>
|
|
124
126
|
**Branch:** <branch>
|
|
125
127
|
|
|
@@ -142,6 +144,26 @@ gh run watch
|
|
|
142
144
|
- <if any remain>
|
|
143
145
|
```
|
|
144
146
|
|
|
147
|
+
### Detecting the Branch Preview URL
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
PR_NUMBER=<pr-number>
|
|
151
|
+
|
|
152
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
153
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
154
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
155
|
+
| .[0] // ""')
|
|
156
|
+
|
|
157
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
158
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
159
|
+
--jq '.comments[]?.body' \
|
|
160
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
161
|
+
| head -1)
|
|
162
|
+
fi
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Omit the Branch Preview line entirely when no preview URL is detected—do not use a placeholder.
|
|
166
|
+
|
|
145
167
|
## Notes
|
|
146
168
|
|
|
147
169
|
- Prioritize fixing non-transient issues; don't waste time on flaky/timeout failures
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: commit-and-pr
|
|
3
|
-
description: Add untracked files, commit changes using yarn commit (if available) with prefilled answers, and create a PR using the Mallard Bay template.
|
|
3
|
+
description: Add untracked files, commit changes using yarn commit (if available) with prefilled answers, and create a PR using the Mallard Bay template.
|
|
4
4
|
version: 1.0.0
|
|
5
5
|
tags:
|
|
6
6
|
- pr
|
|
@@ -11,7 +11,7 @@ tags:
|
|
|
11
11
|
|
|
12
12
|
# Commit and Create PR
|
|
13
13
|
|
|
14
|
-
Automates the workflow of staging untracked files, committing changes, and creating a pull request. Uses `yarn commit` (commitizen) if available with prefilled answers.
|
|
14
|
+
Automates the workflow of staging untracked files, committing changes, and creating a pull request. Uses `yarn commit` (commitizen) if available with prefilled answers.
|
|
15
15
|
|
|
16
16
|
## When to Use
|
|
17
17
|
|
|
@@ -22,17 +22,12 @@ Automates the workflow of staging untracked files, committing changes, and creat
|
|
|
22
22
|
|
|
23
23
|
## Usage Examples
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
- `/commit-and-pr #123` - Commit and create PR for issue #123 (with # prefix)
|
|
28
|
-
- `commit and create PR for issue 456` - Extract issue number from message
|
|
29
|
-
- `commit-and-pr` - Will extract issue number from commit or ask for it
|
|
30
|
-
|
|
31
|
-
The issue number can be provided in various formats: `123`, `#123`, `issue 123`, etc.
|
|
25
|
+
- `/commit-and-pr` - Commit changes and create a PR
|
|
26
|
+
- `commit and create PR` - Same workflow using natural language
|
|
32
27
|
|
|
33
28
|
## Instructions
|
|
34
29
|
|
|
35
|
-
**Important:**
|
|
30
|
+
**Important:** Do not request or require ticket/issue numbers. This workflow no longer depends on issue IDs.
|
|
36
31
|
|
|
37
32
|
### Step 1: Check Git Status and Branch
|
|
38
33
|
|
|
@@ -95,29 +90,7 @@ Verify what was added:
|
|
|
95
90
|
git status
|
|
96
91
|
```
|
|
97
92
|
|
|
98
|
-
### Step 3:
|
|
99
|
-
|
|
100
|
-
**Priority order for finding GitHub issue number:**
|
|
101
|
-
|
|
102
|
-
1. **Check user's message** (if skill was invoked with issue number):
|
|
103
|
-
- Look for GitHub issue number patterns in the user's message when invoking the skill
|
|
104
|
-
- Common patterns: `#123`, `123`, `issue 123`, `[#123]`, `(#123)`, `Closes #123`, `Closes 123`
|
|
105
|
-
- Examples: User says "/commit-and-pr 123" or "/commit-and-pr #123" or "commit and create PR for issue 123"
|
|
106
|
-
- Extract the issue number from the message if present (remove # prefix if present, store as plain number)
|
|
107
|
-
|
|
108
|
-
2. **If already committed** (and issue number not in user message):
|
|
109
|
-
- Extract issue number from the most recent commit message
|
|
110
|
-
- Use `git log -1 --pretty=%B` to get the last commit message
|
|
111
|
-
- Look for issue patterns like: `#123`, `Closes #123`, `Closes 123`, `[#123]`, `(#123)`, `issue 123`, or just numbers
|
|
112
|
-
- If issue number is found in commit, use it (extract number, ignore # prefix)
|
|
113
|
-
|
|
114
|
-
3. **If not found** (and not already committed):
|
|
115
|
-
- Ask the developer for the GitHub issue number (e.g., "123" or "#123")
|
|
116
|
-
- Store this as a plain number (without # prefix) for use in commit and PR
|
|
117
|
-
|
|
118
|
-
**Note:** When a user invokes this skill with an issue number (e.g., `/commit-and-pr 123` or `/commit-and-pr #123` or "commit and create PR for issue 123"), extract the issue number from their message rather than asking for it. Store issue numbers as plain numbers (e.g., `123`) for consistency, even if user provides `#123`.
|
|
119
|
-
|
|
120
|
-
### Step 4: Analyze Changes for Commit Message
|
|
93
|
+
### Step 3: Analyze Changes for Commit Message
|
|
121
94
|
|
|
122
95
|
Before committing, analyze the changes to infer commit type and description:
|
|
123
96
|
|
|
@@ -144,7 +117,7 @@ git diff --cached --stat
|
|
|
144
117
|
- Create a concise, descriptive summary
|
|
145
118
|
- Use present tense, imperative mood (e.g., "Add feature" not "Added feature")
|
|
146
119
|
|
|
147
|
-
### Step
|
|
120
|
+
### Step 4: Commit Changes
|
|
148
121
|
|
|
149
122
|
**Prepare commit message:**
|
|
150
123
|
|
|
@@ -152,12 +125,8 @@ Create a commit message using the inferred type and description from Step 4:
|
|
|
152
125
|
|
|
153
126
|
```bash
|
|
154
127
|
# Format: <type>: <description>
|
|
155
|
-
#
|
|
156
|
-
# Closes #<issue-number>
|
|
157
128
|
```
|
|
158
129
|
|
|
159
|
-
Where `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix in commit message for GitHub to link it).
|
|
160
|
-
|
|
161
130
|
**If `yarn commit` is available:**
|
|
162
131
|
|
|
163
132
|
Check if `yarn commit` script exists:
|
|
@@ -181,8 +150,6 @@ Create a commit message file and use it:
|
|
|
181
150
|
# Create commit message file
|
|
182
151
|
cat > /tmp/commit-msg.txt <<EOF
|
|
183
152
|
<type>: <description>
|
|
184
|
-
|
|
185
|
-
Closes #<issue-number>
|
|
186
153
|
EOF
|
|
187
154
|
|
|
188
155
|
# Use git commit directly (bypasses commitizen but uses same format)
|
|
@@ -196,7 +163,6 @@ If commitizen requires interactive input, inform the developer they'll need to:
|
|
|
196
163
|
- Confirm scope (if applicable, leave blank or suggest based on changed files)
|
|
197
164
|
- Confirm short description (suggest: `<inferred-description>`)
|
|
198
165
|
- Skip long description (unless needed)
|
|
199
|
-
- Enter GitHub issue number when prompted: `#<issue-number>` (include # prefix for GitHub linking)
|
|
200
166
|
|
|
201
167
|
Then run: `yarn commit`
|
|
202
168
|
|
|
@@ -204,18 +170,36 @@ Then run: `yarn commit`
|
|
|
204
170
|
|
|
205
171
|
Use standard git commit with conventional commit format:
|
|
206
172
|
```bash
|
|
207
|
-
git commit -m "<type>: <description>
|
|
208
|
-
|
|
209
|
-
Closes #<issue-number>"
|
|
173
|
+
git commit -m "<type>: <description>"
|
|
210
174
|
```
|
|
211
175
|
|
|
212
176
|
Where:
|
|
213
177
|
- `<type>` is the inferred commit type from Step 4 (e.g., `feat`, `fix`, `docs`)
|
|
214
178
|
- `<description>` is the inferred description from Step 4 (concise, present tense)
|
|
215
|
-
- `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix for GitHub to automatically link the issue)
|
|
216
179
|
|
|
217
180
|
**Important:** Always ensure the commit message follows conventional commit format. If commitizen interaction fails or is not available, use standard git commit with a properly formatted message.
|
|
218
181
|
|
|
182
|
+
### Step 5: Lint and Test Before Pushing
|
|
183
|
+
|
|
184
|
+
**This is a hard gate—do not push until lint and tests are clean.**
|
|
185
|
+
|
|
186
|
+
**Lint the entire project:**
|
|
187
|
+
```bash
|
|
188
|
+
yarn lint:quiet:slow
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- Fix all lint errors before proceeding. Your changes may introduce lint errors in files you didn't directly edit (e.g. unused exports, circular dependencies, type mismatches).
|
|
192
|
+
- Do not disable eslint rules to make errors go away—fix the underlying issues.
|
|
193
|
+
|
|
194
|
+
**Run related tests:**
|
|
195
|
+
```bash
|
|
196
|
+
# Identify test files related to your changes and run them
|
|
197
|
+
# If unsure which tests are related, err on the side of running more
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
- Ensure all related tests pass before pushing.
|
|
201
|
+
- If any tests fail, fix the failures before proceeding.
|
|
202
|
+
|
|
219
203
|
### Step 6: Push Branch
|
|
220
204
|
|
|
221
205
|
**Before pushing, verify branch protection one more time:**
|
|
@@ -254,9 +238,8 @@ Gather information needed for PR:
|
|
|
254
238
|
|
|
255
239
|
1. **Branch name:** `git branch --show-current`
|
|
256
240
|
2. **Base branch:** Usually `main` or `master` (check with `git remote show origin`)
|
|
257
|
-
3. **
|
|
258
|
-
4. **
|
|
259
|
-
5. **Changed files:** Use `git diff --name-status origin/main...HEAD` to see what changed
|
|
241
|
+
3. **Commit messages:** Use `git log origin/main..HEAD --oneline` to get commit messages since base branch
|
|
242
|
+
4. **Changed files:** Use `git diff --name-status origin/main...HEAD` to see what changed
|
|
260
243
|
|
|
261
244
|
### Step 8: Create PR Description
|
|
262
245
|
|
|
@@ -270,9 +253,9 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
|
|
|
270
253
|
|
|
271
254
|
- [Generate from commit messages and changed files]
|
|
272
255
|
|
|
273
|
-
**2.
|
|
256
|
+
**2. Context / links (optional)**
|
|
274
257
|
|
|
275
|
-
-
|
|
258
|
+
- N/A
|
|
276
259
|
|
|
277
260
|
**3. Screenshots, clips, demo links etc**
|
|
278
261
|
|
|
@@ -303,7 +286,7 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
|
|
|
303
286
|
- Analyze commit messages to understand what the PR does
|
|
304
287
|
- List key changes from `git diff --name-status`
|
|
305
288
|
- Fill in section 1 with a summary based on commits and changes
|
|
306
|
-
- Fill in section 2 with
|
|
289
|
+
- Fill in section 2 with any optional context links if provided
|
|
307
290
|
- Leave sections 3 and 4 as TODO for the developer to fill
|
|
308
291
|
|
|
309
292
|
### Step 9: Check for Existing PR
|
|
@@ -320,11 +303,12 @@ EXIT_CODE=$?
|
|
|
320
303
|
```
|
|
321
304
|
|
|
322
305
|
**If PR already exists** (exit code 0 and PR_INFO contains data):
|
|
323
|
-
- Extract the PR URL, number, and title from the JSON output
|
|
306
|
+
- Extract the PR URL, number, and title from the JSON output into `PR_URL`, `PR_NUMBER`, `PR_TITLE`
|
|
307
|
+
- Also attempt to capture a `PREVIEW_URL` using the detection snippet in Step 10 (preview URL fetch)
|
|
324
308
|
- Display a message: "PR already exists for this branch"
|
|
325
309
|
- Show the PR link: Use the `url` field from JSON (e.g., `https://github.com/<owner>/<repo>/pull/<number>`)
|
|
326
310
|
- Show PR number and title
|
|
327
|
-
- Skip PR creation and proceed to Step 11 with the existing PR information
|
|
311
|
+
- Skip PR creation and proceed to Step 11 with the existing PR information and preview URL
|
|
328
312
|
|
|
329
313
|
**If PR does not exist** (exit code non-zero or empty PR_INFO):
|
|
330
314
|
- Continue to create a new PR (proceed to Step 10)
|
|
@@ -369,14 +353,12 @@ fi
|
|
|
369
353
|
```bash
|
|
370
354
|
BRANCH_NAME=$(git branch --show-current)
|
|
371
355
|
gh pr create \
|
|
372
|
-
--title "<type>: <description>
|
|
356
|
+
--title "<type>: <description>" \
|
|
373
357
|
--body "<PR description from Step 8>" \
|
|
374
358
|
--base "$BASE_BRANCH" \
|
|
375
359
|
--head "$BRANCH_NAME"
|
|
376
360
|
```
|
|
377
361
|
|
|
378
|
-
Where `<issue-number>` is the GitHub issue number from Step 3 (include `#` prefix in title for GitHub linking).
|
|
379
|
-
|
|
380
362
|
**Capture PR URL and details:**
|
|
381
363
|
```bash
|
|
382
364
|
# Get the PR URL and number after creation
|
|
@@ -389,42 +371,73 @@ PR_TITLE=$(gh pr view "$BRANCH_NAME" --json title --jq '.title')
|
|
|
389
371
|
# Store these for use in Step 11
|
|
390
372
|
```
|
|
391
373
|
|
|
374
|
+
**Capture branch preview URL (if available):**
|
|
375
|
+
|
|
376
|
+
Many projects have a preview deployment (Vercel, Netlify, Cloudflare Pages, Render, etc.) that exposes a per-branch URL via a status check or a bot-posted PR comment. Attempt to detect it:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Prefer status checks - deployment providers usually expose a targetUrl/detailsUrl
|
|
380
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
381
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
382
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
383
|
+
| .[0] // ""')
|
|
384
|
+
|
|
385
|
+
# Fallback: scan PR comments for preview URLs posted by deployment bots
|
|
386
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
387
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
388
|
+
--jq '.comments[]?.body' \
|
|
389
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
390
|
+
| head -1)
|
|
391
|
+
fi
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Preview checks may take a few seconds to appear after pushing. If `PREVIEW_URL` is empty, it's fine—omit the preview line from the final summary rather than showing a placeholder.
|
|
395
|
+
|
|
392
396
|
**Handle errors:**
|
|
393
397
|
- If authentication fails, prompt user to authenticate
|
|
394
398
|
- If branch conflicts, inform user
|
|
395
399
|
- If creation fails for other reasons, provide clear error message
|
|
396
400
|
|
|
397
|
-
### Step 11: Provide Summary and
|
|
401
|
+
### Step 11: Provide Summary, PR Link, and Branch Preview URL
|
|
402
|
+
|
|
403
|
+
**Always display the PR link and, when available, the branch preview URL prominently at the end.**
|
|
398
404
|
|
|
399
|
-
|
|
405
|
+
Before returning the summary, make sure you have captured (from Step 9 or Step 10):
|
|
406
|
+
- `PR_URL` — the pull request URL
|
|
407
|
+
- `PR_NUMBER` — the pull request number
|
|
408
|
+
- `PR_TITLE` — the pull request title
|
|
409
|
+
- `PREVIEW_URL` — the branch preview deployment URL (may be empty)
|
|
400
410
|
|
|
401
|
-
If PR already existed (from Step 9):
|
|
402
|
-
- **PR Link:** `
|
|
411
|
+
If PR already existed (from Step 9 check):
|
|
412
|
+
- **PR Link:** `PR_URL`
|
|
413
|
+
- **Branch Preview:** `PREVIEW_URL` (include only if non-empty)
|
|
403
414
|
- Message: "PR already exists for this branch"
|
|
404
415
|
- PR number and title
|
|
405
416
|
|
|
406
|
-
If PR was just created (from Step 10):
|
|
407
|
-
- **PR Link:** `
|
|
408
|
-
-
|
|
417
|
+
If PR was just created (from Step 10 creation):
|
|
418
|
+
- **PR Link:** `PR_URL`
|
|
419
|
+
- **Branch Preview:** `PREVIEW_URL` (include only if non-empty)
|
|
409
420
|
- Success message: "PR created successfully"
|
|
410
421
|
|
|
411
422
|
**Additional summary information:**
|
|
412
423
|
- Summary of what was committed
|
|
413
424
|
- Branch name
|
|
414
425
|
- Base branch
|
|
415
|
-
- GitHub issue number used (format as `#123`)
|
|
416
426
|
- Reminder to fill in TODO sections in PR description (sections 3 and 4)
|
|
417
427
|
- Next steps (e.g., request reviewers, add labels, fill in screenshots/demo links)
|
|
418
428
|
|
|
419
429
|
**Format the final output clearly:**
|
|
420
430
|
```markdown
|
|
421
|
-
✅ PR Link:
|
|
431
|
+
✅ PR Link: <PR_URL>
|
|
432
|
+
🔗 Branch Preview: <PREVIEW_URL> ← omit this line entirely if no preview URL was found
|
|
422
433
|
📋 PR #<number>: <title>
|
|
423
|
-
🎫 Issue: #<issue-number>
|
|
424
434
|
🌿 Branch: <branch-name> → <base-branch>
|
|
425
435
|
```
|
|
426
436
|
|
|
427
|
-
**CRITICAL:**
|
|
437
|
+
**CRITICAL:**
|
|
438
|
+
- Always display the PR link prominently at the very end of your response. Make it the most visible element—use markdown formatting so it stands out and is clickable.
|
|
439
|
+
- Always include the branch preview URL when one was detected. It is the second most important output for visual/QA review.
|
|
440
|
+
- If no preview URL was detected, do NOT show a placeholder like "n/a" or "none"—simply omit the Branch Preview line.
|
|
428
441
|
|
|
429
442
|
## Error Handling
|
|
430
443
|
|
|
@@ -432,14 +445,10 @@ If PR was just created (from Step 10):
|
|
|
432
445
|
- Fall back to standard `git commit`
|
|
433
446
|
- Inform user that commitizen wasn't used
|
|
434
447
|
|
|
435
|
-
**If GitHub issue number not found:**
|
|
436
|
-
- Ask user for GitHub issue number explicitly
|
|
437
|
-
- If user doesn't provide, create PR without issue number (they can add later or link manually)
|
|
438
|
-
|
|
439
448
|
**If PR creation fails:**
|
|
440
|
-
- Verify branch is pushed (should already be done in Step
|
|
441
|
-
- Check authentication status (should already be verified in Step
|
|
442
|
-
- If PR already exists, this should have been caught in Step
|
|
449
|
+
- Verify branch is pushed (should already be done in Step 5)
|
|
450
|
+
- Check authentication status (should already be verified in Step 9)
|
|
451
|
+
- If PR already exists, this should have been caught in Step 8 - double-check with `gh pr view`
|
|
443
452
|
- Provide clear error message and next steps
|
|
444
453
|
- Still attempt to show PR link if one exists
|
|
445
454
|
|
|
@@ -452,13 +461,11 @@ If PR was just created (from Step 10):
|
|
|
452
461
|
- **CRITICAL: Never push directly to protected branches** (`main`, `development`, `production`)
|
|
453
462
|
- **Always use semantic release prefixes** for branch names (`feat/`, `fix/`, `test/`, `docs/`, `refactor/`, `chore/`, `perf/`, `style/`)
|
|
454
463
|
- This skill assumes conventional commit format (feat, fix, docs, etc.)
|
|
455
|
-
- GitHub issue numbers are plain numbers (e.g., `123`) but should be formatted with `#` prefix in commit messages and PR titles for GitHub linking
|
|
456
464
|
- PR template TODOs should be filled by developer after PR creation
|
|
457
465
|
- Always verify git status and branch name before making changes
|
|
458
466
|
- Use GitHub CLI (`gh`) for PR creation - it's the most reliable method
|
|
459
467
|
- If commitizen config is non-standard, may need to adapt the commit step
|
|
460
468
|
- Consider running `prep-for-pr` skill before this one to ensure code quality
|
|
461
|
-
- When extracting issue numbers, remove `#` prefix for storage but add it back when using in commits/PRs for GitHub linking
|
|
462
469
|
- If on a protected branch, create a feature branch first before committing
|
|
463
470
|
|
|
464
471
|
## Authentication
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: commit-and-push
|
|
3
|
-
description: Alias for commit-and-pr skill. Commits changes and pushes to remote. If PR exists, shows link; if not, creates PR.
|
|
3
|
+
description: Alias for commit-and-pr skill. Commits changes and pushes to remote. If PR exists, shows link; if not, creates PR.
|
|
4
4
|
version: 1.0.0
|
|
5
5
|
tags:
|
|
6
6
|
- commit
|
|
@@ -26,22 +26,20 @@ This is an alias skill that uses the same functionality as `commit-and-pr`. It c
|
|
|
26
26
|
|
|
27
27
|
1. **Check Git Status** - Understand what needs to be committed
|
|
28
28
|
2. **Add Untracked Files** - Stage all untracked files with `git add .`
|
|
29
|
-
3. **
|
|
30
|
-
4. **
|
|
31
|
-
5. **
|
|
29
|
+
3. **Analyze Changes** - Infer commit type and description from changes
|
|
30
|
+
4. **Commit Changes** - Use `yarn commit` if available, or standard git commit with conventional format
|
|
31
|
+
5. **Lint and Test** - Lint the entire project (`yarn lint:quiet:slow`) and run related tests. Fix all failures before pushing
|
|
32
32
|
6. **Push Branch** - Push to remote, set upstream if needed
|
|
33
33
|
7. **Check for Existing PR** - If PR exists, show link and skip creation
|
|
34
34
|
8. **Create PR** - If no PR exists, create one using Mallard Bay template
|
|
35
|
-
9. **Show PR Link** - Always display PR link prominently at the end
|
|
35
|
+
9. **Show PR Link and Branch Preview URL** - Always display the PR link prominently at the end, and include the branch preview URL whenever a preview deployment is detected (see `commit-and-pr` Step 10/11 for the detection snippet and output format). Omit the preview line entirely if no URL is found—do not use a placeholder.
|
|
36
36
|
|
|
37
37
|
**Reference:** See `.cursor/shared/skills/commit-and-pr/SKILL.md` for complete detailed instructions. This alias uses identical logic and behavior.
|
|
38
38
|
|
|
39
39
|
## Usage Examples
|
|
40
40
|
|
|
41
|
-
- `/commit-and-push
|
|
42
|
-
-
|
|
43
|
-
- `/commit-and-push` - Extract issue number from commit or ask
|
|
44
|
-
- `commit and push changes` - Extract issue number from commit or ask
|
|
41
|
+
- `/commit-and-push` - Commit and push changes, then handle PR
|
|
42
|
+
- `commit and push changes` - Same workflow using natural language
|
|
45
43
|
|
|
46
44
|
## Notes
|
|
47
45
|
|
|
@@ -149,6 +149,37 @@ After preparing the branch, provide:
|
|
|
149
149
|
2. **Issues Fixed**: List of specific issues that were addressed
|
|
150
150
|
3. **Remaining Items**: Any items that need attention but couldn't be fixed automatically
|
|
151
151
|
4. **Readiness Status**: Whether the branch is ready for PR creation
|
|
152
|
+
5. **PR Link and Branch Preview URL**: If a PR already exists for this branch, include:
|
|
153
|
+
- **PR Link:** the pull request URL
|
|
154
|
+
- **Branch Preview:** the preview deployment URL (if one is detected)
|
|
155
|
+
|
|
156
|
+
If no PR exists yet (this skill commonly runs before PR creation), clearly note "No PR yet—run `/commit-and-pr` to create one" instead of fabricating a link.
|
|
157
|
+
|
|
158
|
+
### Detecting PR and Preview URL
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
BRANCH=$(git branch --show-current)
|
|
162
|
+
PR_JSON=$(gh pr view "$BRANCH" --json url,number 2>/dev/null)
|
|
163
|
+
|
|
164
|
+
if [ -n "$PR_JSON" ]; then
|
|
165
|
+
PR_URL=$(echo "$PR_JSON" | jq -r '.url')
|
|
166
|
+
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
|
|
167
|
+
|
|
168
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
169
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
170
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
171
|
+
| .[0] // ""')
|
|
172
|
+
|
|
173
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
174
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
175
|
+
--jq '.comments[]?.body' \
|
|
176
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
177
|
+
| head -1)
|
|
178
|
+
fi
|
|
179
|
+
fi
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Omit the Branch Preview line entirely if no preview URL is detected—do not show a placeholder.
|
|
152
183
|
|
|
153
184
|
## Notes
|
|
154
185
|
|
|
@@ -232,23 +232,47 @@ gh pr review <pr-number> --comment --body "Review summary"
|
|
|
232
232
|
|
|
233
233
|
Provide:
|
|
234
234
|
|
|
235
|
-
1. **
|
|
235
|
+
1. **PR Link and Branch Preview URL** (always at the top so it's easy to jump to):
|
|
236
|
+
- **PR Link:** the pull request URL
|
|
237
|
+
- **Branch Preview:** the preview deployment URL (include only when detected)
|
|
238
|
+
|
|
239
|
+
2. **Review Summary:**
|
|
236
240
|
- Overall assessment
|
|
237
241
|
- Number of blocking/important/suggestion comments
|
|
238
242
|
- Key findings
|
|
239
243
|
|
|
240
|
-
|
|
244
|
+
3. **Comments Posted:**
|
|
241
245
|
- List of comments with file:line references
|
|
242
246
|
- Categorization (blocking/important/suggestion)
|
|
243
247
|
|
|
244
|
-
|
|
248
|
+
4. **Review Decision:**
|
|
245
249
|
- Approve / Request Changes / Comment
|
|
246
250
|
- Rationale
|
|
247
251
|
|
|
248
|
-
|
|
252
|
+
5. **Positive Feedback:**
|
|
249
253
|
- What was done well
|
|
250
254
|
- Appreciate good patterns or solutions
|
|
251
255
|
|
|
256
|
+
### Detecting the Branch Preview URL
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
PR_NUMBER=<pr-number>
|
|
260
|
+
|
|
261
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
262
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
263
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
264
|
+
| .[0] // ""')
|
|
265
|
+
|
|
266
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
267
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
268
|
+
--jq '.comments[]?.body' \
|
|
269
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
270
|
+
| head -1)
|
|
271
|
+
fi
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Omit the Branch Preview line entirely if no preview URL is detected—do not show a placeholder like "n/a".
|
|
275
|
+
|
|
252
276
|
## Notes
|
|
253
277
|
|
|
254
278
|
- **Read every line** of changed code
|
|
@@ -115,6 +115,9 @@ Use this output format:
|
|
|
115
115
|
```markdown
|
|
116
116
|
## Should We Merge? [YES / NO / CONDITIONAL]
|
|
117
117
|
|
|
118
|
+
**PR Link:** <pr-url>
|
|
119
|
+
**Branch Preview:** <preview-url> ← include only if detected; omit entirely otherwise
|
|
120
|
+
|
|
118
121
|
**Summary:** [1–2 sentence verdict]
|
|
119
122
|
|
|
120
123
|
---
|
|
@@ -140,6 +143,26 @@ Use this output format:
|
|
|
140
143
|
- [Rules/standards cited]
|
|
141
144
|
```
|
|
142
145
|
|
|
146
|
+
### Detecting the Branch Preview URL
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
PR_NUMBER=<pr-number>
|
|
150
|
+
|
|
151
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json statusCheckRollup \
|
|
152
|
+
--jq '[.statusCheckRollup[]? | (.targetUrl // .detailsUrl // "")]
|
|
153
|
+
| map(select(test("vercel\\.app|netlify\\.app|pages\\.dev|onrender\\.com|preview"; "i")))
|
|
154
|
+
| .[0] // ""')
|
|
155
|
+
|
|
156
|
+
if [ -z "$PREVIEW_URL" ]; then
|
|
157
|
+
PREVIEW_URL=$(gh pr view "$PR_NUMBER" --json comments \
|
|
158
|
+
--jq '.comments[]?.body' \
|
|
159
|
+
| grep -oE 'https?://[a-zA-Z0-9.-]+\.(vercel\.app|netlify\.app|pages\.dev|onrender\.com)[^ )>"]*' \
|
|
160
|
+
| head -1)
|
|
161
|
+
fi
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Omit the Branch Preview line entirely when no preview URL is detected—do not use a placeholder like "n/a".
|
|
165
|
+
|
|
143
166
|
**Merge decision logic:**
|
|
144
167
|
- **YES** — No P0 issues; P1 issues are minimal or acceptable to merge with follow-up
|
|
145
168
|
- **NO** — Any P0 issues
|