@mallardbay/cursor-rules 1.0.21 → 1.0.24

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.
@@ -114,6 +114,11 @@ These principles apply to all code changes and should guide every implementation
114
114
  4. **Check git history** to understand why code exists as it does
115
115
  5. **Identify related files** that might be affected
116
116
  6. **Ask clarifying questions** if requirements are unclear
117
+ 7. **Use MCP servers when available**—leverage Model Context Protocol servers for enhanced capabilities
118
+ - **Context7 MCP**: Use the context7 MCP server when available to retrieve up-to-date documentation and code examples for libraries
119
+ - If context7 MCP is not available, suggest adding it to improve access to library documentation
120
+ - **Suggest useful MCP servers**: When appropriate, suggest popular and useful MCP servers that could enhance development workflow based on the task at hand
121
+ - Consider MCP servers for documentation, testing, debugging, and other development tasks
117
122
 
118
123
  ### During Implementation
119
124
  1. Make **small, incremental changes**
@@ -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,14 +20,27 @@ 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
 
25
- ### Step 1: Check Git Status
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.
26
36
 
27
- First, check the current git status to understand what needs to be committed:
37
+ ### Step 1: Check Git Status and Branch
38
+
39
+ First, check the current git status and branch:
28
40
 
29
41
  ```bash
30
42
  git status
43
+ git branch --show-current
31
44
  ```
32
45
 
33
46
  Identify:
@@ -36,6 +49,39 @@ Identify:
36
49
  - Current branch name
37
50
  - Whether there are any uncommitted changes
38
51
 
52
+ **CRITICAL: Verify Branch Protection**
53
+
54
+ **Never push directly to protected branches:**
55
+ - `main`
56
+ - `development`
57
+ - `production`
58
+
59
+ **If currently on a protected branch:**
60
+ 1. **Stop immediately** - do not commit or push
61
+ 2. Create a new branch with a semantic release prefix:
62
+ - `feat/` - for new features
63
+ - `fix/` - for bug fixes
64
+ - `test/` - for test-related changes
65
+ - `docs/` - for documentation
66
+ - `refactor/` - for refactoring
67
+ - `chore/` - for maintenance tasks
68
+ - `perf/` - for performance improvements
69
+ - `style/` - for formatting/style changes
70
+ 3. **Example branch names:**
71
+ - `feat/add-user-authentication`
72
+ - `fix/resolve-login-bug`
73
+ - `test/add-component-tests`
74
+ - `docs/update-api-documentation`
75
+ 4. Switch to the new branch:
76
+ ```bash
77
+ git checkout -b <semantic-prefix>/<descriptive-name>
78
+ ```
79
+ 5. Then proceed with the commit and PR workflow
80
+
81
+ **If already on a feature branch:**
82
+ - Verify the branch name follows semantic prefix conventions
83
+ - If it doesn't, consider renaming it before proceeding (optional but recommended)
84
+
39
85
  ### Step 2: Add Untracked Files
40
86
 
41
87
  Add all untracked files to staging:
@@ -49,17 +95,27 @@ Verify what was added:
49
95
  git status
50
96
  ```
51
97
 
52
- ### Step 3: Get Ticket Number
98
+ ### Step 3: Get GitHub Issue Number
53
99
 
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
100
+ **Priority order for finding GitHub issue number:**
57
101
 
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
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`, `ticket 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`.
63
119
 
64
120
  ### Step 4: Analyze Changes for Commit Message
65
121
 
@@ -97,9 +153,11 @@ Create a commit message using the inferred type and description from Step 4:
97
153
  ```bash
98
154
  # Format: <type>: <description>
99
155
  #
100
- # Closes <ticket-number>
156
+ # Closes #<issue-number>
101
157
  ```
102
158
 
159
+ Where `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix in commit message for GitHub to link it).
160
+
103
161
  **If `yarn commit` is available:**
104
162
 
105
163
  Check if `yarn commit` script exists:
@@ -124,7 +182,7 @@ Create a commit message file and use it:
124
182
  cat > /tmp/commit-msg.txt <<EOF
125
183
  <type>: <description>
126
184
 
127
- Closes <ticket-number>
185
+ Closes #<issue-number>
128
186
  EOF
129
187
 
130
188
  # Use git commit directly (bypasses commitizen but uses same format)
@@ -138,7 +196,7 @@ If commitizen requires interactive input, inform the developer they'll need to:
138
196
  - Confirm scope (if applicable, leave blank or suggest based on changed files)
139
197
  - Confirm short description (suggest: `<inferred-description>`)
140
198
  - Skip long description (unless needed)
141
- - Enter ticket number when prompted: `<ticket-number>`
199
+ - Enter GitHub issue number when prompted: `#<issue-number>` (include # prefix for GitHub linking)
142
200
 
143
201
  Then run: `yarn commit`
144
202
 
@@ -148,18 +206,33 @@ Use standard git commit with conventional commit format:
148
206
  ```bash
149
207
  git commit -m "<type>: <description>
150
208
 
151
- Closes <ticket-number>"
209
+ Closes #<issue-number>"
152
210
  ```
153
211
 
154
212
  Where:
155
213
  - `<type>` is the inferred commit type from Step 4 (e.g., `feat`, `fix`, `docs`)
156
214
  - `<description>` is the inferred description from Step 4 (concise, present tense)
157
- - `<ticket-number>` is the ticket number from Step 3
215
+ - `<issue-number>` is the GitHub issue number from Step 3 (use `#` prefix for GitHub to automatically link the issue)
158
216
 
159
217
  **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
218
 
161
219
  ### Step 6: Push Branch
162
220
 
221
+ **Before pushing, verify branch protection one more time:**
222
+
223
+ ```bash
224
+ CURRENT_BRANCH=$(git branch --show-current)
225
+ PROTECTED_BRANCHES="main development production"
226
+
227
+ if echo "$PROTECTED_BRANCHES" | grep -q "$CURRENT_BRANCH"; then
228
+ echo "ERROR: Cannot push to protected branch: $CURRENT_BRANCH"
229
+ echo "Please create a feature branch with semantic prefix (feat/, fix/, test/, etc.)"
230
+ exit 1
231
+ fi
232
+ ```
233
+
234
+ **If branch is safe to push:**
235
+
163
236
  Push the current branch to remote:
164
237
  ```bash
165
238
  git push origin $(git branch --show-current)
@@ -170,13 +243,18 @@ If branch doesn't exist on remote, set upstream:
170
243
  git push -u origin $(git branch --show-current)
171
244
  ```
172
245
 
246
+ **Branch naming reminder:**
247
+ - Use semantic prefixes: `feat/`, `fix/`, `test/`, `docs/`, `refactor/`, `chore/`, `perf/`, `style/`
248
+ - Follow with descriptive name: `feat/add-user-authentication`, `fix/resolve-login-bug`
249
+ - Never push directly to `main`, `development`, or `production`
250
+
173
251
  ### Step 7: Extract PR Information
174
252
 
175
253
  Gather information needed for PR:
176
254
 
177
255
  1. **Branch name:** `git branch --show-current`
178
256
  2. **Base branch:** Usually `main` or `master` (check with `git remote show origin`)
179
- 3. **Ticket number:** From Step 3
257
+ 3. **GitHub issue number:** From Step 3
180
258
  4. **Commit messages:** Use `git log origin/main..HEAD --oneline` to get commit messages since base branch
181
259
  5. **Changed files:** Use `git diff --name-status origin/main...HEAD` to see what changed
182
260
 
@@ -194,7 +272,7 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
194
272
 
195
273
  **2. What ticket does this PR address?**
196
274
 
197
- - <ticket-number>
275
+ - #<issue-number>
198
276
 
199
277
  **3. Screenshots, clips, demo links etc**
200
278
 
@@ -225,10 +303,37 @@ Use the Mallard Bay PR template from: https://github.com/mallardbay/.github/blob
225
303
  - Analyze commit messages to understand what the PR does
226
304
  - List key changes from `git diff --name-status`
227
305
  - Fill in section 1 with a summary based on commits and changes
228
- - Fill in section 2 with the ticket number
306
+ - Fill in section 2 with the GitHub issue number (format as `#123`)
229
307
  - Leave sections 3 and 4 as TODO for the developer to fill
230
308
 
231
- ### Step 9: Create PR Using GitHub CLI
309
+ ### Step 9: Check for Existing PR
310
+
311
+ **Before creating a PR, check if one already exists:**
312
+
313
+ ```bash
314
+ # Get current branch name
315
+ BRANCH_NAME=$(git branch --show-current)
316
+
317
+ # Check if PR exists for this branch
318
+ PR_INFO=$(gh pr view "$BRANCH_NAME" --json url,number,title,state 2>/dev/null)
319
+ EXIT_CODE=$?
320
+ ```
321
+
322
+ **If PR already exists** (exit code 0 and PR_INFO contains data):
323
+ - Extract the PR URL, number, and title from the JSON output
324
+ - Display a message: "PR already exists for this branch"
325
+ - Show the PR link: Use the `url` field from JSON (e.g., `https://github.com/<owner>/<repo>/pull/<number>`)
326
+ - Show PR number and title
327
+ - Skip PR creation and proceed to Step 11 with the existing PR information
328
+
329
+ **If PR does not exist** (exit code non-zero or empty PR_INFO):
330
+ - Continue to create a new PR (proceed to Step 10)
331
+
332
+ **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.
333
+
334
+ ### Step 10: Create PR Using GitHub CLI (if needed)
335
+
336
+ **Only execute this step if no PR exists from Step 9.**
232
337
 
233
338
  **Check GitHub CLI authentication:**
234
339
  ```bash
@@ -240,33 +345,86 @@ If not authenticated, prompt user to run:
240
345
  gh auth login
241
346
  ```
242
347
 
348
+ **Detect base branch:**
349
+ ```bash
350
+ # Try to detect the default branch
351
+ BASE_BRANCH=$(git remote show origin | grep "HEAD branch" | cut -d' ' -f5)
352
+
353
+ # Fallback to common branch names if detection fails
354
+ if [ -z "$BASE_BRANCH" ]; then
355
+ # Check which branch exists
356
+ if git show-ref --verify --quiet refs/remotes/origin/main; then
357
+ BASE_BRANCH="main"
358
+ elif git show-ref --verify --quiet refs/remotes/origin/master; then
359
+ BASE_BRANCH="master"
360
+ elif git show-ref --verify --quiet refs/remotes/origin/develop; then
361
+ BASE_BRANCH="develop"
362
+ else
363
+ BASE_BRANCH="main" # Default fallback
364
+ fi
365
+ fi
366
+ ```
367
+
243
368
  **Create the PR:**
244
369
  ```bash
370
+ BRANCH_NAME=$(git branch --show-current)
245
371
  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)
372
+ --title "<type>: <description> - #<issue-number>" \
373
+ --body "<PR description from Step 8>" \
374
+ --base "$BASE_BRANCH" \
375
+ --head "$BRANCH_NAME"
250
376
  ```
251
377
 
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
378
+ Where `<issue-number>` is the GitHub issue number from Step 3 (include `#` prefix in title for GitHub linking).
379
+
380
+ **Capture PR URL and details:**
381
+ ```bash
382
+ # Get the PR URL and number after creation
383
+ # The gh pr create command outputs the PR URL, but we'll also fetch it to be sure
384
+ PR_URL=$(gh pr view "$BRANCH_NAME" --json url --jq '.url')
385
+ PR_NUMBER=$(gh pr view "$BRANCH_NAME" --json number --jq '.number')
386
+ PR_TITLE=$(gh pr view "$BRANCH_NAME" --json title --jq '.title')
387
+
388
+ # If gh pr create already output a URL, use that; otherwise use the fetched one
389
+ # Store these for use in Step 11
390
+ ```
256
391
 
257
392
  **Handle errors:**
258
- - If PR already exists, inform user and provide link
259
393
  - If authentication fails, prompt user to authenticate
260
394
  - If branch conflicts, inform user
395
+ - If creation fails for other reasons, provide clear error message
396
+
397
+ ### Step 11: Provide Summary and PR Link
398
+
399
+ **Always display the PR link prominently at the end:**
400
+
401
+ If PR already existed (from Step 9):
402
+ - **PR Link:** `https://github.com/<owner>/<repo>/pull/<number>`
403
+ - Message: "PR already exists for this branch"
404
+ - PR number and title
261
405
 
262
- ### Step 10: Provide Summary
406
+ If PR was just created (from Step 10):
407
+ - **PR Link:** `https://github.com/<owner>/<repo>/pull/<number>` (from captured PR_URL)
408
+ - PR number (from captured PR_NUMBER)
409
+ - Success message: "PR created successfully"
263
410
 
264
- After PR is created, provide:
265
- - PR URL
266
- - PR number
411
+ **Additional summary information:**
267
412
  - Summary of what was committed
268
- - Reminder to fill in TODO sections in PR description
269
- - Next steps (e.g., request reviewers, add labels)
413
+ - Branch name
414
+ - Base branch
415
+ - GitHub issue number used (format as `#123`)
416
+ - Reminder to fill in TODO sections in PR description (sections 3 and 4)
417
+ - Next steps (e.g., request reviewers, add labels, fill in screenshots/demo links)
418
+
419
+ **Format the final output clearly:**
420
+ ```markdown
421
+ ✅ PR Link: https://github.com/<owner>/<repo>/pull/<number>
422
+ 📋 PR #<number>: <title>
423
+ 🎫 Issue: #<issue-number>
424
+ 🌿 Branch: <branch-name> → <base-branch>
425
+ ```
426
+
427
+ **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
428
 
271
429
  ## Error Handling
272
430
 
@@ -274,15 +432,16 @@ After PR is created, provide:
274
432
  - Fall back to standard `git commit`
275
433
  - Inform user that commitizen wasn't used
276
434
 
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)
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)
280
438
 
281
439
  **If PR creation fails:**
282
- - Check if PR already exists
283
- - Verify branch is pushed
284
- - Check authentication status
440
+ - Verify branch is pushed (should already be done in Step 6)
441
+ - Check authentication status (should already be verified in Step 10)
442
+ - If PR already exists, this should have been caught in Step 9 - double-check with `gh pr view`
285
443
  - Provide clear error message and next steps
444
+ - Still attempt to show PR link if one exists
286
445
 
287
446
  **If no changes to commit:**
288
447
  - Inform user there are no changes
@@ -290,13 +449,17 @@ After PR is created, provide:
290
449
 
291
450
  ## Notes
292
451
 
452
+ - **CRITICAL: Never push directly to protected branches** (`main`, `development`, `production`)
453
+ - **Always use semantic release prefixes** for branch names (`feat/`, `fix/`, `test/`, `docs/`, `refactor/`, `chore/`, `perf/`, `style/`)
293
454
  - This skill assumes conventional commit format (feat, fix, docs, etc.)
294
- - Ticket number format may vary - be flexible in detection
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
295
456
  - PR template TODOs should be filled by developer after PR creation
296
- - Always verify git status before making changes
457
+ - Always verify git status and branch name before making changes
297
458
  - Use GitHub CLI (`gh`) for PR creation - it's the most reliable method
298
459
  - If commitizen config is non-standard, may need to adapt the commit step
299
460
  - 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
+ - If on a protected branch, create a feature branch first before committing
300
463
 
301
464
  ## Authentication
302
465
 
@@ -0,0 +1,51 @@
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
51
+ - **CRITICAL: Never push directly to protected branches** (`main`, `development`, `production`) - always use semantic prefix branches (`feat/`, `fix/`, `test/`, etc.)
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: fix-tests
3
+ description: Fix failing tests and linting errors to get the build green locally. Prioritize understanding failures before making changes. Fix all failures, even if not caused by our changes. Use when tests are failing, linting errors exist, or the build needs to be fixed.
4
+ version: 1.0.0
5
+ tags:
6
+ - tests
7
+ - linting
8
+ - debugging
9
+ - test-fixes
10
+ - quality
11
+ - workflow
12
+ - build
13
+ ---
14
+
15
+ # Fix Tests and Linting
16
+
17
+ Fix failing tests and linting errors to get the build green locally. Prioritize understanding failures before making changes. Fix all failures, even if they weren't caused by our changes. This skill helps maintain code quality and ensures the build passes.
18
+
19
+ ## When to Use
20
+
21
+ - When tests are failing and need to be fixed
22
+ - When linting errors exist and need to be resolved
23
+ - When the build is failing and needs to be fixed
24
+ - User mentions failing tests, linting errors, or build failures
25
+ - After code changes break existing tests or introduce linting errors
26
+ - When tests need updates due to API or behavior changes
27
+ - **Goal: Get the build green locally**—fix all test and linting failures
28
+
29
+ ## Instructions
30
+
31
+ **Critical Principle: Prioritize understanding failures over making changes without understanding.** Always analyze and understand the root cause before applying fixes.
32
+
33
+ ### Running Tests with Sharding
34
+
35
+ **Use test sharding to run tests efficiently:**
36
+ - **Server projects**: Run tests in 10 shards (e.g., `yarn test --shard=1/10`, `yarn test --shard=2/10`, etc.)
37
+ - **Frontend projects**: Run tests in 4 shards (e.g., `yarn test --shard=1/4`, `yarn test --shard=2/4`, etc.)
38
+ - Run all shards to ensure complete test coverage
39
+ - This prevents running all tests in parallel and helps identify failures more efficiently
40
+
41
+ ### Fixing Tests
42
+
43
+ 1. **Identify failing tests**
44
+ - Run the test suite using appropriate sharding (10 shards for server, 4 for frontend)
45
+ - Run all shards to get a complete picture of failures
46
+ - Identify which tests are failing
47
+ - Note error messages and stack traces
48
+
49
+ 2. **Analyze test failures (CRITICAL: Understand before fixing)**
50
+ - **Prioritize understanding**: Read error messages carefully, understand what each test is trying to verify
51
+ - **Investigate root causes**: Don't make changes until you understand why tests are failing
52
+ - Identify the root cause of failures by examining:
53
+ - Code changes that broke existing behavior
54
+ - Test setup or mocking issues
55
+ - Outdated test expectations
56
+ - Missing dependencies or configuration
57
+ - Flaky test conditions
58
+ - Pre-existing failures (tests that were already broken)
59
+ - **Fix all failures**: Even if a test failure wasn't caused by our changes, we still need to fix it to get the build green
60
+
61
+ 3. **Apply appropriate fixes**
62
+ - Fix code if tests revealed actual bugs
63
+ - Update tests if expectations need to change
64
+ - Fix test setup, mocks, or fixtures
65
+ - Update test utilities or helpers
66
+ - Address timing or async issues
67
+ - Fix pre-existing failures—don't skip tests that were already broken
68
+
69
+ 4. **Verify fixes**
70
+ - Run tests again using sharding to confirm fixes work
71
+ - Run all shards to ensure no new failures were introduced
72
+ - Verify test coverage is maintained
73
+
74
+ 5. **Follow testing standards**
75
+ - Adhere to project testing standards (see [testing.mdc](mdc:.cursor/rules/testing.mdc))
76
+ - Maintain test quality and clarity
77
+ - Keep tests focused and atomic
78
+ - Use appropriate test utilities and patterns
79
+
80
+ ### Fixing Linting Errors
81
+
82
+ 1. **Run linting**
83
+ - Use `yarn lint:quiet:slow` to identify all linting errors (as specified in [general-best-practices.mdc](mdc:.cursor/rules/general-best-practices.mdc))
84
+ - This provides deeper checks and identifies all issues
85
+
86
+ 2. **Analyze linting errors (CRITICAL: Understand before fixing)**
87
+ - **Prioritize understanding**: Read each linting error carefully
88
+ - **Investigate root causes**: Understand why each error exists before fixing
89
+ - **Never disable eslint rules** to make errors go away—fix the underlying issues instead
90
+ - Identify if errors are due to:
91
+ - Code quality issues that need fixing
92
+ - Missing dependencies or configuration
93
+ - Pre-existing errors (linting issues that were already present)
94
+ - **Fix all errors**: Even if a linting error wasn't caused by our changes, we still need to fix it to get the build green
95
+
96
+ 3. **Apply appropriate fixes**
97
+ - Fix code quality issues properly
98
+ - Add missing dependencies or configuration
99
+ - Refactor code to address linting concerns
100
+ - Fix pre-existing errors—don't skip linting issues that were already present
101
+ - **Never add `eslint-disable` comments** unless there's a legitimate, documented reason
102
+
103
+ 4. **Verify fixes**
104
+ - Run `yarn lint:quiet:slow` again to confirm all errors are resolved
105
+ - Ensure no new linting errors were introduced
106
+
107
+ ### Final Verification
108
+
109
+ - Run all test shards to ensure all tests pass
110
+ - Run `yarn lint:quiet:slow` to ensure all linting errors are resolved
111
+ - **Goal achieved**: Build is green locally with all tests passing and no linting errors
112
+
113
+ ## Notes
114
+
115
+ - **Always understand failures before fixing**—prioritize understanding over quick fixes
116
+ - **Fix all failures**—even if they weren't caused by our changes, we need to fix them to get the build green
117
+ - Focus on fixing root causes, not symptoms
118
+ - Use test sharding (10 for server, 4 for frontend) to run tests efficiently
119
+ - Use `yarn lint:quiet:slow` for comprehensive linting checks
120
+ - Never disable eslint rules—fix the underlying issues instead
121
+ - Ensure tests accurately validate expected behavior
122
+ - Maintain or improve test coverage
123
+ - Follow existing test patterns and conventions
124
+ - Keep tests clear, fast, and maintainable
125
+ - **Goal: Get the build green locally**—all tests passing, no linting errors
@@ -136,6 +136,7 @@ Check for breaking changes that could affect clients:
136
136
  - **Important** - Should fix (code quality, maintainability)
137
137
  - **Suggestion** - Nice to have (style, minor improvements)
138
138
  - **Question** - Need clarification
139
+
139
140
 
140
141
  2. **Write constructive comments:**
141
142
  - Be specific about the issue
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.24",
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",