Skip to content

Commit 5625a34

Browse files
committed
issue: 4480494 Add Cursor rules for dev workflow
Add two Cursor AI rules to streamline development workflow: - commit-msg.mdc: Automates generation of well-formatted commit messages following project conventions with proper Redmine issue tracking and sign-off requirements - evaluate-bug.mdc: Provides structured approach for bug investigation using Redmine MCP integration, including ticket analysis, codebase investigation, and root cause analysis with visual diagrams These rules enable AI-assisted development by encoding project best practices and integrating with existing tools. Signed-off-by: Tomer Cabouly <[email protected]>
1 parent 9e1d79d commit 5625a34

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

.cursor/rules/commit-msg.mdc

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
description: Write a commit message
3+
alwaysApply: false
4+
---
5+
6+
Generate a well-formatted commit message for the currently staged changes following the project's conventions.
7+
8+
## Prerequisites
9+
Before writing the commit message:
10+
1. Review the staged changes using `git diff --staged` to understand what was modified
11+
2. Identify the Redmine issue ID (check branch name, recent commits, or ask user if not found)
12+
3. Retrieve git configuration:
13+
- User name: `git config user.name`
14+
- User email: `git config user.email`
15+
16+
## Template Format
17+
```
18+
issue: <redmine_issue_id> <concise-title>
19+
20+
<detailed-body>
21+
22+
Signed-off-by: <user_full_name> <user_email>
23+
```
24+
25+
## Writing Guidelines
26+
27+
### Subject Line (First Line)
28+
- **Format**: `issue: <redmine_issue_id> <concise-title>`
29+
- **Maximum length**: 51 characters (for optimal git log display)
30+
- **Style**: Use imperative mood (e.g., "Add feature" not "Added feature")
31+
- **Content**: Brief, actionable description of the change
32+
- **Example**: `issue: 12345 Fix memory leak in buffer pool`
33+
34+
### Body
35+
- **Line length**: Maximum 72 characters per line (for readability in various git tools)
36+
- **Content**:
37+
- Explain WHAT changed and WHY (not HOW - the code shows that)
38+
- Reference any technical decisions or trade-offs
39+
- Mention side effects or related changes
40+
- Use bullet points for multiple changes
41+
- **Tone**: Clear, technical, and informative
42+
- Leave a blank line between subject and body
43+
44+
### Sign-off
45+
- **Format**: `Signed-off-by: Full Name <[email protected]>`
46+
- Use values from git config (never hardcode)
47+
48+
## Error Handling
49+
- If Redmine issue ID is missing: Check branch name first (e.g., "bugfix/12345-description"), then ask user
50+
- If staged changes are empty: Alert user and abort
51+
- If git config is incomplete: Ask user to configure git first
52+
53+
## Examples
54+
55+
### Example 1: Feature Addition
56+
```
57+
issue: 12345 Add zero-copy receive path
58+
59+
Implement zero-copy receive mechanism using memory mapping
60+
to reduce CPU overhead in high-throughput scenarios.
61+
62+
- Add new RX buffer pool with mmap allocation
63+
- Integrate with existing ring buffer architecture
64+
- Add configuration option XLIO_RX_ZERO_COPY
65+
66+
Performance tests show 15% reduction in CPU usage for
67+
large packet workloads.
68+
69+
Signed-off-by: John Doe <[email protected]>
70+
```
71+
72+
### Example 2: Bug Fix
73+
```
74+
issue: 45678 Fix race condition in CQ polling
75+
76+
Resolve race between CQ event handler and polling thread
77+
that caused occasional missed completions.
78+
79+
Added mutex protection around CQ state transitions and
80+
ensured proper ordering of event acknowledgment.
81+
82+
Signed-off-by: Jane Smith <[email protected]>
83+
```
84+
85+
## Process
86+
1. Run `git diff --staged` to analyze changes
87+
2. Extract/confirm Redmine issue ID
88+
3. Generate subject line (check 51 char limit)
89+
4. Write body explaining the changes clearly
90+
5. Add sign-off with git config values
91+
6. Verify format compliance before presenting to user

.cursor/rules/evaluate-bug.mdc

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
description: Evaluate and analyze bugs
3+
alwaysApply: false
4+
---
5+
6+
Investigate and analyze a Redmine ticket to understand the root cause of a bug.
7+
8+
## Prerequisites
9+
**Stop and ask user to install Redmine MCP if unavailable.**
10+
11+
If ticket number is not provided, request it from the user.
12+
13+
## Phase 1: Investigation
14+
15+
### Ticket Analysis
16+
1. Fetch the full ticket using `yai__get_tickets` with ticket ID
17+
2. Extract key information:
18+
- Bug description and reproduction steps
19+
- Affected versions, components, priority
20+
- Attachments (logs, screenshots, stack traces)
21+
3. Review comments using `yai__get_comments`
22+
4. Search for similar issues using `yai__get_similar_issues`
23+
24+
### Codebase Investigation
25+
1. Locate affected code components (use semantic search and grep)
26+
2. Trace execution path from entry point to bug location
27+
3. Review recent changes to affected files (git history)
28+
4. Examine error handling and edge cases
29+
5. Check existing tests related to the functionality
30+
31+
### Data Gathering
32+
- Collect error messages, stack traces, logs
33+
- Document current vs. expected behavior
34+
- Note environmental factors (OS, versions, config)
35+
36+
## Phase 2: Root Cause Analysis
37+
38+
Provide a clear explanation of:
39+
- **What the user experiences**: Observable symptoms
40+
- **Technical root cause**: The actual defect in code/logic
41+
- **Why it exists**: Contributing factors (race condition, missing validation, incorrect assumption, etc.)
42+
- **Impact scope**: Which features/users are affected
43+
44+
## Phase 3: Visual Illustration
45+
46+
Create diagrams to illustrate:
47+
1. **Bug flow diagram**: Sequence/flow showing how the bug manifests
48+
2. **Architecture context**: Components involved and their relationships
49+
50+
Use mermaid or ASCII diagrams for clarity.
51+
52+
## Notes
53+
- If insufficient information exists, clearly state what's missing and ask user
54+
- Validate all assumptions by examining actual code
55+
56+
## Next Steps
57+
58+
After completing this evaluation:
59+
- **If fix is needed**: Use `@solve-bug.mdc [ticket#]` to generate solution proposals
60+
- **If more investigation needed**: Document questions and continue research
61+
- **If ticket is invalid**: Update ticket status with findings

0 commit comments

Comments
 (0)