@mallardbay/cursor-rules 1.0.21 → 1.0.23

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.
@@ -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. Only requires ticket number from developer.
3
+ description: Add untracked files, commit changes using yarn commit (if available) with prefilled answers, and create a PR using the Mallard Bay template. GitHub issue number can be provided in the message (e.g., "/commit-and-pr 123" or "/commit-and-pr #123") or will be extracted from commit or asked if needed.
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, requiring only the ticket number from the developer. If changes are already committed, extracts the ticket number from the commit message.
14
+ Automates the workflow of staging untracked files, committing changes, and creating a pull request. Uses `yarn commit` (commitizen) if available with prefilled answers. The GitHub issue number can be provided when invoking the skill (e.g., `/commit-and-pr 123` or `/commit-and-pr #123`), extracted from existing commit messages, or will be requested if not found.
15
15
 
16
16
  ## When to Use
17
17
 
@@ -20,8 +20,20 @@ Automates the workflow of staging untracked files, committing changes, and creat
20
20
  - When you need to add untracked files and commit them
21
21
  - User mentions committing changes, creating PR, or opening pull request
22
22
 
23
+ ## Usage Examples
24
+
25
+ You can invoke this skill with a GitHub issue number:
26
+ - `/commit-and-pr 123` - Commit and create PR for issue #123
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`, `ticket 123`, etc.
32
+
23
33
  ## Instructions
24
34
 
35
+ **Important:** When this skill is invoked, check the user's message for a GitHub issue number first. Users can provide the issue number when invoking the skill (e.g., `/commit-and-pr 123` or `/commit-and-pr #123` or "commit and create PR for issue 123"). Extract it from their message before asking for it.
36
+
25
37
  ### Step 1: Check Git Status
26
38
 
27
39
  First, check the current git status to understand what needs to be committed:
@@ -49,17 +61,27 @@ Verify what was added:
49
61
  git status
50
62
  ```
51
63
 
52
- ### Step 3: Get Ticket Number
64
+ ### Step 3: Get GitHub Issue Number
53
65
 
54
- **If not already committed:**
55
- - Ask the developer for the ticket number (e.g., "MB-123", "123", "TICKET-456")
56
- - Store this for use in commit and PR
66
+ **Priority order for finding GitHub issue number:**
57
67
 
58
- **If already committed:**
59
- - Extract ticket number from the most recent commit message
60
- - Use `git log -1 --pretty=%B` to get the last commit message
61
- - Look for ticket patterns like: `MB-123`, `[MB-123]`, `(MB-123)`, `TICKET-123`, or just numbers
62
- - If ticket number is found in commit, use it; otherwise ask the developer
68
+ 1. **Check user's message** (if skill was invoked with issue number):
69
+ - Look for GitHub issue number patterns in the user's message when invoking the skill
70
+ - Common patterns: `#123`, `123`, `issue 123`, `ticket 123`, `[#123]`, `(#123)`, `Closes #123`, `Closes 123`
71
+ - Examples: User says "/commit-and-pr 123" or "/commit-and-pr #123" or "commit and create PR for issue 123"
72
+ - Extract the issue number from the message if present (remove # prefix if present, store as plain number)
73
+
74
+ 2. **If already committed** (and issue number not in user message):
75
+ - Extract issue number from the most recent commit message
76
+ - Use `git log -1 --pretty=%B` to get the last commit message
77
+ - Look for issue patterns like: `#123`, `Closes #123`, `Closes 123`, `[#123]`, `(#123)`, `issue 123`, or just numbers
78
+ - If issue number is found in commit, use it (extract number, ignore # prefix)
79
+
80
+ 3. **If not found** (and not already committed):
81
+ - Ask the developer for the GitHub issue number (e.g., "123" or "#123")
82
+ - Store this as a plain number (without # prefix) for use in commit and PR
83
+
84
+ **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`.
63
85
 
64
86
  ### Step 4: Analyze Changes for Commit Message
65
87
 
@@ -97,9 +119,11 @@ Create a commit message using the inferred type and description from Step 4:
97
119
  ```bash
98
120
  # Format: <type>: <description>
99
121
  #
100
- # Closes <ticket-number>
122
+ # Closes #<issue-number>
101
123
  ```
102
124
 
125
+ Where `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix in commit message for GitHub to link it).
126
+
103
127
  **If `yarn commit` is available:**
104
128
 
105
129
  Check if `yarn commit` script exists:
@@ -124,7 +148,7 @@ Create a commit message file and use it:
124
148
  cat > /tmp/commit-msg.txt <<EOF
125
149
  <type>: <description>
126
150
 
127
- Closes <ticket-number>
151
+ Closes #<issue-number>
128
152
  EOF
129
153
 
130
154
  # Use git commit directly (bypasses commitizen but uses same format)
@@ -138,7 +162,7 @@ If commitizen requires interactive input, inform the developer they'll need to:
138
162
  - Confirm scope (if applicable, leave blank or suggest based on changed files)
139
163
  - Confirm short description (suggest: `<inferred-description>`)
140
164
  - Skip long description (unless needed)
141
- - Enter ticket number when prompted: `<ticket-number>`
165
+ - Enter GitHub issue number when prompted: `#<issue-number>` (include # prefix for GitHub linking)
142
166
 
143
167
  Then run: `yarn commit`
144
168
 
@@ -148,13 +172,13 @@ Use standard git commit with conventional commit format:
148
172
  ```bash
149
173
  git commit -m "<type>: <description>
150
174
 
151
- Closes <ticket-number>"
175
+ Closes #<issue-number>"
152
176
  ```
153
177
 
154
178
  Where:
155
179
  - `<type>` is the inferred commit type from Step 4 (e.g., `feat`, `fix`, `docs`)
156
180
  - `<description>` is the inferred description from Step 4 (concise, present tense)
157
- - `<ticket-number>` is the ticket number from Step 3
181
+ - `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix for GitHub to automatically link the issue)
158
182
 
159
183
  **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.
160
184
 
@@ -176,7 +200,7 @@ Gather information needed for PR:
176
200
 
177
201
  1. **Branch name:** `git branch --show-current`
178
202
  2. **Base branch:** Usually `main` or `master` (check with `git remote show origin`)
179
- 3. **Ticket number:** From Step 3
203
+ 3. **GitHub issue number:** From Step 3
180
204
  4. **Commit messages:** Use `git log origin/main..HEAD --oneline` to get commit messages since base branch
181
205
  5. **Changed files:** Use `git diff --name-status origin/main...HEAD` to see what changed
182
206
 
@@ -194,7 +218,7 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
194
218
 
195
219
  **2. What ticket does this PR address?**
196
220
 
197
- - <ticket-number>
221
+ - #<issue-number>
198
222
 
199
223
  **3. Screenshots, clips, demo links etc**
200
224
 
@@ -225,10 +249,37 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
225
249
  - Analyze commit messages to understand what the PR does
226
250
  - List key changes from `git diff --name-status`
227
251
  - Fill in section 1 with a summary based on commits and changes
228
- - Fill in section 2 with the ticket number
252
+ - Fill in section 2 with the GitHub issue number (format as `#123`)
229
253
  - Leave sections 3 and 4 as TODO for the developer to fill
230
254
 
231
- ### Step 9: Create PR Using GitHub CLI
255
+ ### Step 9: Check for Existing PR
256
+
257
+ **Before creating a PR, check if one already exists:**
258
+
259
+ ```bash
260
+ # Get current branch name
261
+ BRANCH_NAME=$(git branch --show-current)
262
+
263
+ # Check if PR exists for this branch
264
+ PR_INFO=$(gh pr view "$BRANCH_NAME" --json url,number,title,state 2>/dev/null)
265
+ EXIT_CODE=$?
266
+ ```
267
+
268
+ **If PR already exists** (exit code 0 and PR_INFO contains data):
269
+ - Extract the PR URL, number, and title from the JSON output
270
+ - Display a message: "PR already exists for this branch"
271
+ - Show the PR link: Use the `url` field from JSON (e.g., `https://github.com/<owner>/<repo>/pull/<number>`)
272
+ - Show PR number and title
273
+ - Skip PR creation and proceed to Step 11 with the existing PR information
274
+
275
+ **If PR does not exist** (exit code non-zero or empty PR_INFO):
276
+ - Continue to create a new PR (proceed to Step 10)
277
+
278
+ **Note:** The `gh pr view` command returns a non-zero exit code if no PR exists, which is expected behavior. Only proceed with creation if the PR truly doesn't exist.
279
+
280
+ ### Step 10: Create PR Using GitHub CLI (if needed)
281
+
282
+ **Only execute this step if no PR exists from Step 9.**
232
283
 
233
284
  **Check GitHub CLI authentication:**
234
285
  ```bash
@@ -240,33 +291,86 @@ If not authenticated, prompt user to run:
240
291
  gh auth login
241
292
  ```
242
293
 
294
+ **Detect base branch:**
295
+ ```bash
296
+ # Try to detect the default branch
297
+ BASE_BRANCH=$(git remote show origin | grep "HEAD branch" | cut -d' ' -f5)
298
+
299
+ # Fallback to common branch names if detection fails
300
+ if [ -z "$BASE_BRANCH" ]; then
301
+ # Check which branch exists
302
+ if git show-ref --verify --quiet refs/remotes/origin/main; then
303
+ BASE_BRANCH="main"
304
+ elif git show-ref --verify --quiet refs/remotes/origin/master; then
305
+ BASE_BRANCH="master"
306
+ elif git show-ref --verify --quiet refs/remotes/origin/develop; then
307
+ BASE_BRANCH="develop"
308
+ else
309
+ BASE_BRANCH="main" # Default fallback
310
+ fi
311
+ fi
312
+ ```
313
+
243
314
  **Create the PR:**
244
315
  ```bash
316
+ BRANCH_NAME=$(git branch --show-current)
245
317
  gh pr create \
246
- --title "<type>: <description> - <ticket-number>" \
247
- --body "<PR description from Step 7>" \
248
- --base main \
249
- --head $(git branch --show-current)
318
+ --title "<type>: <description> - #<issue-number>" \
319
+ --body "<PR description from Step 8>" \
320
+ --base "$BASE_BRANCH" \
321
+ --head "$BRANCH_NAME"
250
322
  ```
251
323
 
252
- **If base branch is different:**
253
- - Detect base branch: `git remote show origin | grep "HEAD branch" | cut -d' ' -f5`
254
- - Or check common branches: `main`, `master`, `develop`
255
- - Use detected base branch in `--base` flag
324
+ Where `<issue-number>` is the GitHub issue number from Step 3 (include `#` prefix in title for GitHub linking).
325
+
326
+ **Capture PR URL and details:**
327
+ ```bash
328
+ # Get the PR URL and number after creation
329
+ # The gh pr create command outputs the PR URL, but we'll also fetch it to be sure
330
+ PR_URL=$(gh pr view "$BRANCH_NAME" --json url --jq '.url')
331
+ PR_NUMBER=$(gh pr view "$BRANCH_NAME" --json number --jq '.number')
332
+ PR_TITLE=$(gh pr view "$BRANCH_NAME" --json title --jq '.title')
333
+
334
+ # If gh pr create already output a URL, use that; otherwise use the fetched one
335
+ # Store these for use in Step 11
336
+ ```
256
337
 
257
338
  **Handle errors:**
258
- - If PR already exists, inform user and provide link
259
339
  - If authentication fails, prompt user to authenticate
260
340
  - If branch conflicts, inform user
341
+ - If creation fails for other reasons, provide clear error message
261
342
 
262
- ### Step 10: Provide Summary
343
+ ### Step 11: Provide Summary and PR Link
263
344
 
264
- After PR is created, provide:
265
- - PR URL
266
- - PR number
345
+ **Always display the PR link prominently at the end:**
346
+
347
+ If PR already existed (from Step 9):
348
+ - **PR Link:** `https://github.com/<owner>/<repo>/pull/<number>`
349
+ - Message: "PR already exists for this branch"
350
+ - PR number and title
351
+
352
+ If PR was just created (from Step 10):
353
+ - **PR Link:** `https://github.com/<owner>/<repo>/pull/<number>` (from captured PR_URL)
354
+ - PR number (from captured PR_NUMBER)
355
+ - Success message: "PR created successfully"
356
+
357
+ **Additional summary information:**
267
358
  - Summary of what was committed
268
- - Reminder to fill in TODO sections in PR description
269
- - Next steps (e.g., request reviewers, add labels)
359
+ - Branch name
360
+ - Base branch
361
+ - GitHub issue number used (format as `#123`)
362
+ - Reminder to fill in TODO sections in PR description (sections 3 and 4)
363
+ - Next steps (e.g., request reviewers, add labels, fill in screenshots/demo links)
364
+
365
+ **Format the final output clearly:**
366
+ ```markdown
367
+ ✅ PR Link: https://github.com/<owner>/<repo>/pull/<number>
368
+ 📋 PR #<number>: <title>
369
+ 🎫 Issue: #<issue-number>
370
+ 🌿 Branch: <branch-name> → <base-branch>
371
+ ```
372
+
373
+ **CRITICAL:** Always display the PR link prominently at the very end of your response. Make it the most visible element - use markdown formatting to make it stand out, and ensure it's clickable. The PR link is the most important output of this skill.
270
374
 
271
375
  ## Error Handling
272
376
 
@@ -274,15 +378,16 @@ After PR is created, provide:
274
378
  - Fall back to standard `git commit`
275
379
  - Inform user that commitizen wasn't used
276
380
 
277
- **If ticket number not found:**
278
- - Ask user for ticket number explicitly
279
- - If user doesn't provide, create PR without ticket number (they can add later)
381
+ **If GitHub issue number not found:**
382
+ - Ask user for GitHub issue number explicitly
383
+ - If user doesn't provide, create PR without issue number (they can add later or link manually)
280
384
 
281
385
  **If PR creation fails:**
282
- - Check if PR already exists
283
- - Verify branch is pushed
284
- - Check authentication status
386
+ - Verify branch is pushed (should already be done in Step 6)
387
+ - Check authentication status (should already be verified in Step 10)
388
+ - If PR already exists, this should have been caught in Step 9 - double-check with `gh pr view`
285
389
  - Provide clear error message and next steps
390
+ - Still attempt to show PR link if one exists
286
391
 
287
392
  **If no changes to commit:**
288
393
  - Inform user there are no changes
@@ -291,12 +396,13 @@ After PR is created, provide:
291
396
  ## Notes
292
397
 
293
398
  - This skill assumes conventional commit format (feat, fix, docs, etc.)
294
- - Ticket number format may vary - be flexible in detection
399
+ - GitHub issue numbers are plain numbers (e.g., `123`) but should be formatted with `#` prefix in commit messages and PR titles for GitHub linking
295
400
  - PR template TODOs should be filled by developer after PR creation
296
401
  - Always verify git status before making changes
297
402
  - Use GitHub CLI (`gh`) for PR creation - it's the most reliable method
298
403
  - If commitizen config is non-standard, may need to adapt the commit step
299
404
  - Consider running `prep-for-pr` skill before this one to ensure code quality
405
+ - When extracting issue numbers, remove `#` prefix for storage but add it back when using in commits/PRs for GitHub linking
300
406
 
301
407
  ## Authentication
302
408
 
@@ -0,0 +1,50 @@
1
+ ---
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. GitHub issue number can be provided (e.g., "/commit-and-push 123").
4
+ version: 1.0.0
5
+ tags:
6
+ - commit
7
+ - push
8
+ - workflow
9
+ - git
10
+ - alias
11
+ ---
12
+
13
+ # Commit and Push (Alias)
14
+
15
+ This is an alias skill that uses the same functionality as `commit-and-pr`. It commits changes, pushes to remote, and handles PRs (shows existing PR link or creates new one if needed).
16
+
17
+ ## When to Use
18
+
19
+ - When you want to commit and push changes
20
+ - When you want a shorter command than `/commit-and-pr`
21
+ - User mentions "commit and push", "commit changes", or similar
22
+
23
+ ## Instructions
24
+
25
+ **This skill provides the same functionality as `commit-and-pr`.** Follow the complete workflow from the `commit-and-pr` skill, which includes:
26
+
27
+ 1. **Check Git Status** - Understand what needs to be committed
28
+ 2. **Add Untracked Files** - Stage all untracked files with `git add .`
29
+ 3. **Get GitHub Issue Number** - Extract from user message, existing commit, or ask
30
+ 4. **Analyze Changes** - Infer commit type and description from changes
31
+ 5. **Commit Changes** - Use `yarn commit` if available, or standard git commit with conventional format
32
+ 6. **Push Branch** - Push to remote, set upstream if needed
33
+ 7. **Check for Existing PR** - If PR exists, show link and skip creation
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
36
+
37
+ **Reference:** See `.cursor/shared/skills/commit-and-pr/SKILL.md` for complete detailed instructions. This alias uses identical logic and behavior.
38
+
39
+ ## Usage Examples
40
+
41
+ - `/commit-and-push 123` - Commit and push for issue #123
42
+ - `/commit-and-push #123` - Commit and push for issue #123 (with # prefix)
43
+ - `/commit-and-push` - Extract issue number from commit or ask
44
+ - `commit and push changes` - Extract issue number from commit or ask
45
+
46
+ ## Notes
47
+
48
+ - This skill provides the same functionality as `commit-and-pr`
49
+ - Use whichever name feels more natural: `/commit-and-pr` or `/commit-and-push`
50
+ - Both skills behave identically
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mallardbay/cursor-rules",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Mallard Bay shared cursor rules",
5
5
  "main": "bin/setup-cursor.sh",
6
6
  "repository": "git@github.com:mallardbay/cursor-rules.git",