@mallardbay/cursor-rules 1.0.23 → 1.0.25
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/rules/testing.mdc +1 -0
- package/.cursor/shared/rules/general-best-practices.mdc +5 -0
- package/.cursor/shared/rules/testing.mdc +1 -0
- package/.cursor/shared/skills/commit-and-pr/SKILL.md +60 -3
- package/.cursor/shared/skills/commit-and-push/SKILL.md +1 -0
- package/.cursor/shared/skills/fix-tests/SKILL.md +125 -0
- package/.cursor/shared/skills/review-pr/SKILL.md +1 -0
- package/package.json +1 -1
|
@@ -59,6 +59,7 @@ Avoid e2e tests for UI. Favor unit tests.
|
|
|
59
59
|
- Apollo mocks
|
|
60
60
|
- Provider mocks
|
|
61
61
|
- Keep mocks simple and maintainable
|
|
62
|
+
- **Do not use variable matchers for Apollo mocks**—match exact variables (e.g. avoid `expect.anything()` or `variables: {}`) so tests fail when the component passes incorrect variables to queries or mutations
|
|
62
63
|
|
|
63
64
|
### Test Utilities
|
|
64
65
|
|
|
@@ -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**
|
|
@@ -62,6 +62,7 @@ Avoid e2e tests for UI. Favor unit tests.
|
|
|
62
62
|
- Apollo mocks
|
|
63
63
|
- Provider mocks
|
|
64
64
|
- Keep mocks simple and maintainable
|
|
65
|
+
- **Do not use variable matchers for Apollo mocks**—match exact variables (e.g. avoid `expect.anything()` or `variables: {}`) so tests fail when the component passes incorrect variables to queries or mutations
|
|
65
66
|
|
|
66
67
|
### Test Utilities
|
|
67
68
|
|
|
@@ -34,12 +34,13 @@ The issue number can be provided in various formats: `123`, `#123`, `issue 123`,
|
|
|
34
34
|
|
|
35
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
36
|
|
|
37
|
-
### Step 1: Check Git Status
|
|
37
|
+
### Step 1: Check Git Status and Branch
|
|
38
38
|
|
|
39
|
-
First, check the current git status
|
|
39
|
+
First, check the current git status and branch:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
git status
|
|
43
|
+
git branch --show-current
|
|
43
44
|
```
|
|
44
45
|
|
|
45
46
|
Identify:
|
|
@@ -48,6 +49,39 @@ Identify:
|
|
|
48
49
|
- Current branch name
|
|
49
50
|
- Whether there are any uncommitted changes
|
|
50
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
|
+
|
|
51
85
|
### Step 2: Add Untracked Files
|
|
52
86
|
|
|
53
87
|
Add all untracked files to staging:
|
|
@@ -184,6 +218,21 @@ Where:
|
|
|
184
218
|
|
|
185
219
|
### Step 6: Push Branch
|
|
186
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
|
+
|
|
187
236
|
Push the current branch to remote:
|
|
188
237
|
```bash
|
|
189
238
|
git push origin $(git branch --show-current)
|
|
@@ -194,6 +243,11 @@ If branch doesn't exist on remote, set upstream:
|
|
|
194
243
|
git push -u origin $(git branch --show-current)
|
|
195
244
|
```
|
|
196
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
|
+
|
|
197
251
|
### Step 7: Extract PR Information
|
|
198
252
|
|
|
199
253
|
Gather information needed for PR:
|
|
@@ -395,14 +449,17 @@ If PR was just created (from Step 10):
|
|
|
395
449
|
|
|
396
450
|
## Notes
|
|
397
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/`)
|
|
398
454
|
- This skill assumes conventional commit format (feat, fix, docs, etc.)
|
|
399
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
|
|
400
456
|
- PR template TODOs should be filled by developer after PR creation
|
|
401
|
-
- Always verify git status before making changes
|
|
457
|
+
- Always verify git status and branch name before making changes
|
|
402
458
|
- Use GitHub CLI (`gh`) for PR creation - it's the most reliable method
|
|
403
459
|
- If commitizen config is non-standard, may need to adapt the commit step
|
|
404
460
|
- Consider running `prep-for-pr` skill before this one to ensure code quality
|
|
405
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
|
|
406
463
|
|
|
407
464
|
## Authentication
|
|
408
465
|
|
|
@@ -48,3 +48,4 @@ This is an alias skill that uses the same functionality as `commit-and-pr`. It c
|
|
|
48
48
|
- This skill provides the same functionality as `commit-and-pr`
|
|
49
49
|
- Use whichever name feels more natural: `/commit-and-pr` or `/commit-and-push`
|
|
50
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
|