|
1 | 1 | # Techdebt Cleanup Skill |
2 | 2 |
|
3 | | -Analyze and refactor changes on the current branch to reduce technical debt, eliminate code duplication, and remove unnecessary complexity. |
| 3 | +Analyze changes on the current branch to identify and fix technical debt, code duplication, and unnecessary complexity. |
4 | 4 |
|
5 | 5 | ## Instructions |
6 | 6 |
|
7 | | -You are a senior engineer performing a technical debt review of the changes introduced on this branch. Your goal is to refine the code to be cleaner, simpler, and more maintainable. |
| 7 | +### Step 1: Get Branch Changes |
8 | 8 |
|
9 | | -### Step 1: Gather Context |
10 | | - |
11 | | -Find the remote pointing to the upstream DataDog/dd-trace-java repository and get all changes: |
| 9 | +Find the upstream remote and compare against it: |
12 | 10 |
|
13 | 11 | ```bash |
14 | | -# Find upstream remote and get diff stats |
15 | | -UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') |
16 | | -echo "Upstream remote: $UPSTREAM" |
| 12 | +# Find upstream (DataDog org repo) and show changes |
| 13 | +UPSTREAM=$(git remote -v | grep -E 'DataDog/[^/]+(.git)?\s' | head -1 | awk '{print $1}') |
| 14 | +if [ -z "$UPSTREAM" ]; then |
| 15 | + echo "No DataDog upstream found, using origin" |
| 16 | + UPSTREAM="origin" |
| 17 | +fi |
| 18 | +echo "Comparing against: $UPSTREAM/master" |
17 | 19 | git diff ${UPSTREAM}/master --stat |
18 | 20 | git diff ${UPSTREAM}/master --name-status |
19 | 21 | ``` |
20 | 22 |
|
21 | | -Then read the full diff to understand the changes: |
| 23 | +If no changes exist, inform the user and stop. |
22 | 24 |
|
23 | | -```bash |
24 | | -UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') |
25 | | -git diff ${UPSTREAM}/master |
26 | | -``` |
| 25 | +If changes exist, read the diff and the full content of modified source files (not test files) to understand context. |
27 | 26 |
|
28 | | -### Step 2: Analyze for Technical Debt |
| 27 | +### Step 2: Analyze for Issues |
29 | 28 |
|
30 | | -Review all changes looking for these specific issues: |
| 29 | +Look for: |
31 | 30 |
|
32 | | -#### Code Duplication |
33 | | -- Similar code blocks that could be extracted into shared functions/methods |
| 31 | +**Code Duplication** |
| 32 | +- Similar code blocks that should be extracted into shared functions |
34 | 33 | - Copy-pasted logic with minor variations |
35 | | -- Repeated patterns that could use a common abstraction |
36 | 34 |
|
37 | | -#### Unnecessary Complexity |
38 | | -- Over-engineered solutions (abstractions for single use cases) |
| 35 | +**Unnecessary Complexity** |
| 36 | +- Over-engineered solutions (abstractions used only once) |
39 | 37 | - Excessive indirection or layers |
40 | 38 | - Backward compatibility shims that aren't needed |
41 | 39 |
|
42 | | -#### Redundant Code |
| 40 | +**Redundant Code** |
43 | 41 | - Dead code paths |
44 | | -- Excessive null checks or error handling for impossible scenarios |
45 | | -- Comments that just repeat what the code does |
46 | | - |
47 | | -#### Verbose Patterns |
48 | | -- Boilerplate that could be simplified |
49 | | -- Explicit types where inference works |
50 | | -- Unnecessarily defensive code |
51 | | - |
52 | | -### Step 3: Report Findings |
53 | | - |
54 | | -Present findings in this format: |
55 | | - |
56 | | -``` |
57 | | -## Technical Debt Analysis |
58 | | -
|
59 | | -### Summary |
60 | | -- Files analyzed: X |
61 | | -- Issues found: Y |
62 | | -
|
63 | | -### Issues by Category |
64 | | -
|
65 | | -#### 1. Code Duplication |
66 | | -[List each instance with file:line references and explanation] |
67 | | -
|
68 | | -#### 2. Unnecessary Complexity |
69 | | -[List each instance with file:line references and explanation] |
70 | | -
|
71 | | -#### 3. Redundant Code |
72 | | -[List each instance with file:line references and explanation] |
73 | | -
|
74 | | -### Recommended Refactorings |
75 | | -[Prioritized list of specific changes to make] |
76 | | -``` |
77 | | - |
78 | | -### Step 4: Implement Fixes (if requested) |
79 | | - |
80 | | -If the user wants you to fix the issues: |
| 42 | +- Overly defensive checks for impossible scenarios |
81 | 43 |
|
82 | | -1. Start with the highest-impact, lowest-risk changes |
83 | | -2. Make one logical change at a time |
84 | | -3. Explain each change briefly |
85 | | -4. Do NOT introduce new features or change behavior - only refactor |
| 44 | +### Step 3: Report and Fix |
86 | 45 |
|
87 | | -### Guidelines |
| 46 | +Present a concise summary of issues found with file:line references. |
88 | 47 |
|
89 | | -- **Be conservative**: Only flag clear issues, not stylistic preferences |
90 | | -- **Preserve behavior**: Refactoring must not change functionality |
91 | | -- **Stay focused**: Only analyze changes on this branch, not the entire codebase |
92 | | -- **Be specific**: Always include file paths and line numbers |
93 | | -- **Prioritize**: Focus on issues that matter, skip trivial ones |
| 48 | +Then ask the user if they want you to fix the issues. When fixing: |
| 49 | +- Make one logical change at a time |
| 50 | +- Do NOT change behavior, only refactor |
| 51 | +- Skip trivial or stylistic issues |
0 commit comments