Skip to content

Commit ad44faa

Browse files
author
Szymon.Poltorak
committed
feat(): update cursor rules and ds-refactoring-flow
1 parent 6654c58 commit ad44faa

File tree

4 files changed

+56
-142
lines changed

4 files changed

+56
-142
lines changed

.cursor/flows/ds-refactoring-flow/01-find-violations.mdc

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@ alwaysApply: false
66
You are an AI assistant tasked with helping a developer identify and plan refactoring for legacy component usage. Follow these instructions carefully to complete the task in two main steps.
77

88
First, I will provide you with the following information:
9-
<component_name>{{COMPONENT_NAME}}</component_name>
109
<directory>{{DIRECTORY}}</directory>
1110

1211
Step 1: Find violations
1312

14-
1. Run a scan using the report-violations function with the following parameters:
15-
- component: {{COMPONENT_NAME}}
13+
1. Run a scan using the report-all-violations function with the following parameters:
1614
- directory: {{DIRECTORY}}
1715
- groupBy: "folder"
1816

1917
Store the result in a variable called scanResult.
2018

21-
2. Perform first-level error handling:
19+
2. Deduplicate violations by file and line:
20+
- Process scanResult to remove duplicate entries that have the same file path and line number
21+
- When combining duplicates, merge the component/class information (e.g., "btn, btn-primary violations on line 10")
22+
- Keep the deduplicated count for accurate violation totals
23+
- Store the deduplicated result and use it for all subsequent processing
24+
25+
3. Perform first-level error handling:
2226
- If the function call returns an error, respond with:
2327
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
2428
Then stop execution.
25-
- If scanResult.totalViolations is 0, respond with:
26-
"✅ No legacy usage of {{COMPONENT_NAME}} found."
29+
- If no violations are found, respond with:
30+
"✅ No legacy usage found."
2731
Then stop execution.
2832
- Otherwise, continue to the next step.
2933

30-
3. Output the results for the user:
34+
4. Output the results for the user:
3135
- Print the ranked list of folders inside <folders> tags, like this:
3236
<folders>
3337
1. [path/to/folder-A] – [X] violations in [Y] files
@@ -50,13 +54,18 @@ Once the user provides a subfolder choice, proceed as follows:
5054
Then stop execution.
5155

5256
2. Run a file-level scan:
53-
- Use the report-violations function with these parameters:
54-
- component: {{COMPONENT_NAME}}
57+
- Use the report-all-violations function with these parameters:
5558
- directory: {{SUBFOLDER}}
5659
- groupBy: "file"
5760
- Store the result in a variable called fileScan.
5861

59-
3. Perform error handling and validation:
62+
3. Deduplicate violations by file and line:
63+
- Process fileScan to remove duplicate entries that have the same file path and line number
64+
- When combining duplicates, merge the component/class information
65+
- Keep the deduplicated count for accurate violation totals
66+
- Store the deduplicated result and use it for all subsequent processing
67+
68+
4. Perform error handling and validation:
6069
- If the function call returns an error, respond with:
6170
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
6271
Then stop execution.
@@ -65,20 +74,12 @@ Once the user provides a subfolder choice, proceed as follows:
6574
Then stop execution.
6675
- Sort the files by number of violations (descending) and then alphabetically.
6776

68-
4. Output the results for the plan phase:
77+
5. Output the results for the plan phase:
6978
- Print the sorted list of files inside <violations> tags, like this:
7079
<violations>
7180
1. [path/to/file-A.tsx] – [X] violations
7281
2. [path/to/file-B.tsx] – [X] violations
7382
...
7483
</violations>
7584
- After the </violations> tag, prompt the user with:
76-
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**
77-
78-
As in Step 1, any side remarks should go in an optional <commentary>...</commentary> tag.
79-
80-
Final instructions:
81-
- Always use the exact format and wording provided for outputs and prompts.
82-
- Do not add any explanations or additional text unless explicitly instructed.
83-
- If you encounter any situations not covered by these instructions, respond with:
84-
<commentary>⚠️ Unexpected situation encountered. Please provide further guidance.</commentary>
85+
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**

.cursor/flows/ds-refactoring-flow/02-plan-refactoring.mdc

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ alwaysApply: false
66
You are an AI assistant tasked with helping a development team migrate legacy components to a new design system. Your goal is to analyze the current codebase, identify areas that need updating, and provide a detailed plan for the migration process. This task will be completed in three phases: a comprehensive analysis, a detailed plan creation, and a checklist creation.
77

88
You will be working with the following inputs:
9-
<component_name>{{COMPONENT_NAME}}</component_name>: The name of the target design-system component
109
<folder_path>{{FOLDER_PATH}}</folder_path>: The path to the folder containing the legacy components
11-
<component_docs>{{COMPONENT_DOCS}}</component_docs>: The official documentation for the target design-system component
12-
<component_code>{{COMPONENT_CODE}}</component_code>: The source files of the target design-system component
13-
<usage_graph>{{USAGE_GRAPH}}</usage_graph>: A graph showing the usage of the legacy component in the specified folder
10+
<component_docs>{{COMPONENT_DOCS}}</component_docs>: The official documentation for the target design-system components
11+
<component_code>{{COMPONENT_CODE}}</component_code>: The source files of the target design-system components
12+
<usage_graph>{{USAGE_GRAPH}}</usage_graph>: A graph showing the usage of the legacy components in the specified folder
1413
<library_data>{{LIBRARY_DATA}}</library_data>: Information about library type
1514

1615
# Phase 1: Comprehensive Analysis
1716

1817
1. Review all provided inputs: COMPONENT_DOCS, COMPONENT_CODE, USAGE_GRAPH, and LIBRARY_DATA.
1918

2019
2. Analyze the current codebase, focusing on:
21-
a. The approved markup and API for the target component
22-
b. The actual implementation of the design-system component
23-
c. All files (templates, TS, styles, specs, NgModules) that reference the legacy component
20+
a. The approved markup and API for the target components
21+
b. The actual implementation of the design-system components
22+
c. All files (templates, TS, styles, specs, NgModules) that reference the legacy components
2423
d. Dependencies and library information
2524

2625
3. Create a comprehensive summary of the analysis, including:
@@ -35,47 +34,4 @@ Write your comprehensive analysis in <comprehensive_analysis> tags.
3534

3635
# Phase 2: Detailed Plan Creation
3736

38-
Please think about this problem thoroughly and in great detail. Consider multiple approaches and show your complete reasoning. Please perform a thourough and Based on your comprehensive analysis, create a detailed migration plan:
39-
40-
1. For each affected file:
41-
a. Compare the old markup against the design-system exemplar from the COMPONENT_DOCS.
42-
b. Classify the migration effort as:
43-
- Simple swap (straight replacement with no loss of behavior, styling, responsive rules, animation, click/test-ID, or accessibility attributes)
44-
- Requires restructure (minor code or CSS tweaks needed to preserve behaviors or visuals that the design-system component lacks)
45-
- Non-viable (needs manual rethink)
46-
c. Assign a complexity score on a scale of 1-10, adding:
47-
- +1 per removed animation or breakpoint
48-
- +2 per business variant that needs to be rebuilt
49-
50-
2. Create an actionable plan ordered by effort, including:
51-
a. File path & type
52-
b. Refactor classification
53-
c. Concrete edits needed (template, TS, styles, NgModule, spec)
54-
d. Verification notes (2-3 static checks that can be performed by reading files only)
55-
e. Complexity score
56-
57-
3. If any items are classified as non-viable, explicitly highlight these in a separate section of your plan.
58-
59-
4. Review your detailed plan against the COMPONENT_DOCS to ensure all recommendations align with the official documentation.
60-
61-
5. Identify any ambiguities in your plan that could be interpreted multiple ways and list these in a separate section.
62-
63-
Write your detailed migration plan in <migration_plan> tags.
64-
65-
# Phase 3: Checklist Creation
66-
67-
After the user approves the plan and clarifies any ambiguities:
68-
69-
1. Create a checklist that lists only actual changes as checkboxes.
70-
2. Create a "check" phase where all verifications (2-3 static checks that can be performed by reading files only) are listed as checkboxes.
71-
3. Ensure the checklist is comprehensive and follows directly from the approved migration plan.
72-
73-
Write your checklist in <checklist> tags.
74-
75-
Your final output should include only the following:
76-
1. The <comprehensive_analysis> block
77-
2. The <migration_plan> block
78-
3. The following approval request: "🛠️ Approve this plan or specify adjustments?"
79-
4. If applicable, an ambiguity safeguard: "❓ The plan contains ambiguities: [short description]. Please clarify."
80-
81-
After the user approves the plan and clarifies any ambiguities, provide only the <checklist> block in your response. Also, remember to save the checklist in a file at .cursor/tmp/refactoring-checklis-{{FOLDER_PATH}}.md.
37+
Please think about this problem thoroughly

.cursor/rules/01-find-violations.mdc

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@ alwaysApply: false
66
You are an AI assistant tasked with helping a developer identify and plan refactoring for legacy component usage. Follow these instructions carefully to complete the task in two main steps.
77

88
First, I will provide you with the following information:
9-
<component_name>{{COMPONENT_NAME}}</component_name>
109
<directory>{{DIRECTORY}}</directory>
1110

1211
Step 1: Find violations
1312

14-
1. Run a scan using the report-violations function with the following parameters:
15-
- component: {{COMPONENT_NAME}}
13+
1. Run a scan using the report-all-violations function with the following parameters:
1614
- directory: {{DIRECTORY}}
1715
- groupBy: "folder"
1816

1917
Store the result in a variable called scanResult.
2018

21-
2. Perform first-level error handling:
19+
2. Deduplicate violations by file and line:
20+
- Process scanResult to remove duplicate entries that have the same file path and line number
21+
- When combining duplicates, merge the component/class information (e.g., "btn, btn-primary violations on line 10")
22+
- Keep the deduplicated count for accurate violation totals
23+
- Store the deduplicated result and use it for all subsequent processing
24+
25+
3. Perform first-level error handling:
2226
- If the function call returns an error, respond with:
2327
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
2428
Then stop execution.
25-
- If scanResult.totalViolations is 0, respond with:
26-
"✅ No legacy usage of {{COMPONENT_NAME}} found."
29+
- If no violations are found, respond with:
30+
"✅ No legacy usage found."
2731
Then stop execution.
2832
- Otherwise, continue to the next step.
2933

30-
3. Output the results for the user:
34+
4. Output the results for the user:
3135
- Print the ranked list of folders inside <folders> tags, like this:
3236
<folders>
3337
1. [path/to/folder-A] – [X] violations in [Y] files
@@ -50,13 +54,18 @@ Once the user provides a subfolder choice, proceed as follows:
5054
Then stop execution.
5155

5256
2. Run a file-level scan:
53-
- Use the report-violations function with these parameters:
54-
- component: {{COMPONENT_NAME}}
57+
- Use the report-all-violations function with these parameters:
5558
- directory: {{SUBFOLDER}}
5659
- groupBy: "file"
5760
- Store the result in a variable called fileScan.
5861

59-
3. Perform error handling and validation:
62+
3. Deduplicate violations by file and line:
63+
- Process fileScan to remove duplicate entries that have the same file path and line number
64+
- When combining duplicates, merge the component/class information
65+
- Keep the deduplicated count for accurate violation totals
66+
- Store the deduplicated result and use it for all subsequent processing
67+
68+
4. Perform error handling and validation:
6069
- If the function call returns an error, respond with:
6170
<commentary>🚨 *Tool execution failed* – [error message]</commentary>
6271
Then stop execution.
@@ -65,20 +74,12 @@ Once the user provides a subfolder choice, proceed as follows:
6574
Then stop execution.
6675
- Sort the files by number of violations (descending) and then alphabetically.
6776

68-
4. Output the results for the plan phase:
77+
5. Output the results for the plan phase:
6978
- Print the sorted list of files inside <violations> tags, like this:
7079
<violations>
7180
1. [path/to/file-A.tsx] – [X] violations
7281
2. [path/to/file-B.tsx] – [X] violations
7382
...
7483
</violations>
7584
- After the </violations> tag, prompt the user with:
76-
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**
77-
78-
As in Step 1, any side remarks should go in an optional <commentary>...</commentary> tag.
79-
80-
Final instructions:
81-
- Always use the exact format and wording provided for outputs and prompts.
82-
- Do not add any explanations or additional text unless explicitly instructed.
83-
- If you encounter any situations not covered by these instructions, respond with:
84-
<commentary>⚠️ Unexpected situation encountered. Please provide further guidance.</commentary>
85+
❓ **Please attach the "Plan Phase" rules now so I can start refactoring planning.**

.cursor/rules/02-plan-refactoring.mdc

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ alwaysApply: false
66
You are an AI assistant tasked with helping a development team migrate legacy components to a new design system. Your goal is to analyze the current codebase, identify areas that need updating, and provide a detailed plan for the migration process. This task will be completed in three phases: a comprehensive analysis, a detailed plan creation, and a checklist creation.
77

88
You will be working with the following inputs:
9-
<component_name>{{COMPONENT_NAME}}</component_name>: The name of the target design-system component
109
<folder_path>{{FOLDER_PATH}}</folder_path>: The path to the folder containing the legacy components
11-
<component_docs>{{COMPONENT_DOCS}}</component_docs>: The official documentation for the target design-system component
12-
<component_code>{{COMPONENT_CODE}}</component_code>: The source files of the target design-system component
13-
<usage_graph>{{USAGE_GRAPH}}</usage_graph>: A graph showing the usage of the legacy component in the specified folder
10+
<component_docs>{{COMPONENT_DOCS}}</component_docs>: The official documentation for the target design-system components
11+
<component_code>{{COMPONENT_CODE}}</component_code>: The source files of the target design-system components
12+
<usage_graph>{{USAGE_GRAPH}}</usage_graph>: A graph showing the usage of the legacy components in the specified folder
1413
<library_data>{{LIBRARY_DATA}}</library_data>: Information about library type
1514

1615
# Phase 1: Comprehensive Analysis
1716

1817
1. Review all provided inputs: COMPONENT_DOCS, COMPONENT_CODE, USAGE_GRAPH, and LIBRARY_DATA.
1918

2019
2. Analyze the current codebase, focusing on:
21-
a. The approved markup and API for the target component
22-
b. The actual implementation of the design-system component
23-
c. All files (templates, TS, styles, specs, NgModules) that reference the legacy component
20+
a. The approved markup and API for the target components
21+
b. The actual implementation of the design-system components
22+
c. All files (templates, TS, styles, specs, NgModules) that reference the legacy components
2423
d. Dependencies and library information
2524

2625
3. Create a comprehensive summary of the analysis, including:
@@ -35,47 +34,4 @@ Write your comprehensive analysis in <comprehensive_analysis> tags.
3534

3635
# Phase 2: Detailed Plan Creation
3736

38-
Please think about this problem thoroughly and in great detail. Consider multiple approaches and show your complete reasoning. Please perform a thourough and Based on your comprehensive analysis, create a detailed migration plan:
39-
40-
1. For each affected file:
41-
a. Compare the old markup against the design-system exemplar from the COMPONENT_DOCS.
42-
b. Classify the migration effort as:
43-
- Simple swap (straight replacement with no loss of behavior, styling, responsive rules, animation, click/test-ID, or accessibility attributes)
44-
- Requires restructure (minor code or CSS tweaks needed to preserve behaviors or visuals that the design-system component lacks)
45-
- Non-viable (needs manual rethink)
46-
c. Assign a complexity score on a scale of 1-10, adding:
47-
- +1 per removed animation or breakpoint
48-
- +2 per business variant that needs to be rebuilt
49-
50-
2. Create an actionable plan ordered by effort, including:
51-
a. File path & type
52-
b. Refactor classification
53-
c. Concrete edits needed (template, TS, styles, NgModule, spec)
54-
d. Verification notes (2-3 static checks that can be performed by reading files only)
55-
e. Complexity score
56-
57-
3. If any items are classified as non-viable, explicitly highlight these in a separate section of your plan.
58-
59-
4. Review your detailed plan against the COMPONENT_DOCS to ensure all recommendations align with the official documentation.
60-
61-
5. Identify any ambiguities in your plan that could be interpreted multiple ways and list these in a separate section.
62-
63-
Write your detailed migration plan in <migration_plan> tags.
64-
65-
# Phase 3: Checklist Creation
66-
67-
After the user approves the plan and clarifies any ambiguities:
68-
69-
1. Create a checklist that lists only actual changes as checkboxes.
70-
2. Create a "check" phase where all verifications (2-3 static checks that can be performed by reading files only) are listed as checkboxes.
71-
3. Ensure the checklist is comprehensive and follows directly from the approved migration plan.
72-
73-
Write your checklist in <checklist> tags.
74-
75-
Your final output should include only the following:
76-
1. The <comprehensive_analysis> block
77-
2. The <migration_plan> block
78-
3. The following approval request: "🛠️ Approve this plan or specify adjustments?"
79-
4. If applicable, an ambiguity safeguard: "❓ The plan contains ambiguities: [short description]. Please clarify."
80-
81-
After the user approves the plan and clarifies any ambiguities, provide only the <checklist> block in your response. Also, remember to save the checklist in a file at .cursor/tmp/refactoring-checklis-{{FOLDER_PATH}}.md.
37+
Please think about this problem thoroughly

0 commit comments

Comments
 (0)