From 18ff6c70ce2b6ca05f675786c530b500c2b60ae0 Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Tue, 3 Feb 2026 14:08:06 +0100 Subject: [PATCH 1/5] =?UTF-8?q?feat(ai):=E2=80=AFAdd=20techdebt=20claude?= =?UTF-8?q?=20skill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/techdebt.md | 129 +++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 .claude/skills/techdebt.md diff --git a/.claude/skills/techdebt.md b/.claude/skills/techdebt.md new file mode 100644 index 00000000000..5bdd3895e8d --- /dev/null +++ b/.claude/skills/techdebt.md @@ -0,0 +1,129 @@ +# Techdebt Cleanup Skill + +Analyze and refactor changes on the current branch to reduce technical debt, eliminate code duplication, and remove unnecessary complexity. + +## Instructions + +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. + +### Step 1: Gather Context + +Find the remote pointing to the upstream DataDog/dd-trace-java repository and get all changes: + +```bash +# Find upstream remote and get diff stats +UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') +echo "Upstream remote: $UPSTREAM" +git diff ${UPSTREAM}/master --stat +git diff ${UPSTREAM}/master --name-status +``` + +Then read the full diff to understand the changes: + +```bash +UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') +git diff ${UPSTREAM}/master +``` + +### Step 2: Analyze for Technical Debt + +Review all changes looking for these specific issues: + +#### Code Duplication +- Similar code blocks that could be extracted into shared functions/methods +- Copy-pasted logic with minor variations +- Repeated patterns that could use a common abstraction + +#### Unnecessary Complexity +- Over-engineered solutions (abstractions for single use cases) +- Excessive indirection or layers +- Backward compatibility shims that aren't needed + +#### Redundant Code +- Dead code paths +- Excessive null checks or error handling for impossible scenarios +- Comments that just repeat what the code does + +#### Verbose Patterns +- Boilerplate that could be simplified +- Explicit types where inference works +- Unnecessarily defensive code + +### Step 3: Report Findings + +Present findings in this format: + +``` +## Technical Debt Analysis + +### Summary +- Files analyzed: X +- Issues found: Y + +### Issues by Category + +#### 1. Code Duplication +[List each instance with file:line references and explanation] + +#### 2. Unnecessary Complexity +[List each instance with file:line references and explanation] + +#### 3. Redundant Code +[List each instance with file:line references and explanation] + +### Recommended Refactorings +[Prioritized list of specific changes to make] +``` + +### Step 4: Implement Fixes (if requested) + +If the user wants you to fix the issues: + +1. Start with the highest-impact, lowest-risk changes +2. Make one logical change at a time +3. Explain each change briefly +4. Do NOT introduce new features or change behavior - only refactor + +### Guidelines + +- **Be conservative**: Only flag clear issues, not stylistic preferences +- **Preserve behavior**: Refactoring must not change functionality +- **Stay focused**: Only analyze changes on this branch, not the entire codebase +- **Be specific**: Always include file paths and line numbers +- **Prioritize**: Focus on issues that matter, skip trivial ones + +### Example Duplication Fix + +Before: +```java +// In FileA.java +if (config != null && config.isEnabled() && config.getValue() > 0) { + process(config.getValue()); +} + +// In FileB.java +if (config != null && config.isEnabled() && config.getValue() > 0) { + handle(config.getValue()); +} +``` + +After: +```java +// In ConfigUtils.java +public static Optional getValidValue(Config config) { + if (config != null && config.isEnabled() && config.getValue() > 0) { + return Optional.of(config.getValue()); + } + return Optional.empty(); +} + +// In FileA.java +ConfigUtils.getValidValue(config).ifPresent(this::process); + +// In FileB.java +ConfigUtils.getValidValue(config).ifPresent(this::handle); +``` + +## User Invocation + +This skill can be invoked with `/techdebt` to analyze the current branch for technical debt. From ff6edea6c61f71d58dc01270e3fe6460f838f593 Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Tue, 3 Feb 2026 14:21:03 +0100 Subject: [PATCH 2/5] =?UTF-8?q?feat(ai):=E2=80=AFRemove=20unnecessary=20ex?= =?UTF-8?q?amples?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/techdebt.md | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/.claude/skills/techdebt.md b/.claude/skills/techdebt.md index 5bdd3895e8d..ea5dc4c68b2 100644 --- a/.claude/skills/techdebt.md +++ b/.claude/skills/techdebt.md @@ -91,39 +91,3 @@ If the user wants you to fix the issues: - **Stay focused**: Only analyze changes on this branch, not the entire codebase - **Be specific**: Always include file paths and line numbers - **Prioritize**: Focus on issues that matter, skip trivial ones - -### Example Duplication Fix - -Before: -```java -// In FileA.java -if (config != null && config.isEnabled() && config.getValue() > 0) { - process(config.getValue()); -} - -// In FileB.java -if (config != null && config.isEnabled() && config.getValue() > 0) { - handle(config.getValue()); -} -``` - -After: -```java -// In ConfigUtils.java -public static Optional getValidValue(Config config) { - if (config != null && config.isEnabled() && config.getValue() > 0) { - return Optional.of(config.getValue()); - } - return Optional.empty(); -} - -// In FileA.java -ConfigUtils.getValidValue(config).ifPresent(this::process); - -// In FileB.java -ConfigUtils.getValidValue(config).ifPresent(this::handle); -``` - -## User Invocation - -This skill can be invoked with `/techdebt` to analyze the current branch for technical debt. From 4162811639152fa96b2023cae6d291a3e42b1a4e Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Tue, 3 Feb 2026 14:25:44 +0100 Subject: [PATCH 3/5] =?UTF-8?q?feat(ai):=E2=80=AFSimplify=20the=20skill=20?= =?UTF-8?q?to=20be=20more=20focused?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/techdebt.md | 94 +++++++++++--------------------------- 1 file changed, 26 insertions(+), 68 deletions(-) diff --git a/.claude/skills/techdebt.md b/.claude/skills/techdebt.md index ea5dc4c68b2..ccb85336901 100644 --- a/.claude/skills/techdebt.md +++ b/.claude/skills/techdebt.md @@ -1,93 +1,51 @@ # Techdebt Cleanup Skill -Analyze and refactor changes on the current branch to reduce technical debt, eliminate code duplication, and remove unnecessary complexity. +Analyze changes on the current branch to identify and fix technical debt, code duplication, and unnecessary complexity. ## Instructions -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. +### Step 1: Get Branch Changes -### Step 1: Gather Context - -Find the remote pointing to the upstream DataDog/dd-trace-java repository and get all changes: +Find the upstream remote and compare against it: ```bash -# Find upstream remote and get diff stats -UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') -echo "Upstream remote: $UPSTREAM" +# Find upstream (DataDog org repo) and show changes +UPSTREAM=$(git remote -v | grep -E 'DataDog/[^/]+(.git)?\s' | head -1 | awk '{print $1}') +if [ -z "$UPSTREAM" ]; then + echo "No DataDog upstream found, using origin" + UPSTREAM="origin" +fi +echo "Comparing against: $UPSTREAM/master" git diff ${UPSTREAM}/master --stat git diff ${UPSTREAM}/master --name-status ``` -Then read the full diff to understand the changes: +If no changes exist, inform the user and stop. -```bash -UPSTREAM=$(git remote -v | grep -E 'DataDog/dd-trace-java(.git)?\s' | head -1 | awk '{print $1}') -git diff ${UPSTREAM}/master -``` +If changes exist, read the diff and the full content of modified source files (not test files) to understand context. -### Step 2: Analyze for Technical Debt +### Step 2: Analyze for Issues -Review all changes looking for these specific issues: +Look for: -#### Code Duplication -- Similar code blocks that could be extracted into shared functions/methods +**Code Duplication** +- Similar code blocks that should be extracted into shared functions - Copy-pasted logic with minor variations -- Repeated patterns that could use a common abstraction -#### Unnecessary Complexity -- Over-engineered solutions (abstractions for single use cases) +**Unnecessary Complexity** +- Over-engineered solutions (abstractions used only once) - Excessive indirection or layers - Backward compatibility shims that aren't needed -#### Redundant Code +**Redundant Code** - Dead code paths -- Excessive null checks or error handling for impossible scenarios -- Comments that just repeat what the code does - -#### Verbose Patterns -- Boilerplate that could be simplified -- Explicit types where inference works -- Unnecessarily defensive code - -### Step 3: Report Findings - -Present findings in this format: - -``` -## Technical Debt Analysis - -### Summary -- Files analyzed: X -- Issues found: Y - -### Issues by Category - -#### 1. Code Duplication -[List each instance with file:line references and explanation] - -#### 2. Unnecessary Complexity -[List each instance with file:line references and explanation] - -#### 3. Redundant Code -[List each instance with file:line references and explanation] - -### Recommended Refactorings -[Prioritized list of specific changes to make] -``` - -### Step 4: Implement Fixes (if requested) - -If the user wants you to fix the issues: +- Overly defensive checks for impossible scenarios -1. Start with the highest-impact, lowest-risk changes -2. Make one logical change at a time -3. Explain each change briefly -4. Do NOT introduce new features or change behavior - only refactor +### Step 3: Report and Fix -### Guidelines +Present a concise summary of issues found with file:line references. -- **Be conservative**: Only flag clear issues, not stylistic preferences -- **Preserve behavior**: Refactoring must not change functionality -- **Stay focused**: Only analyze changes on this branch, not the entire codebase -- **Be specific**: Always include file paths and line numbers -- **Prioritize**: Focus on issues that matter, skip trivial ones +Then ask the user if they want you to fix the issues. When fixing: +- Make one logical change at a time +- Do NOT change behavior, only refactor +- Skip trivial or stylistic issues From c45c95b6b62488376721dd8e40f24c5a8dd7a631 Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Tue, 3 Feb 2026 14:39:52 +0100 Subject: [PATCH 4/5] =?UTF-8?q?feat(ai):=E2=80=AFAdd=20skill=20metadata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/{techdebt.md => techdebt/SKILL.md} | 12 ++++++++++++ 1 file changed, 12 insertions(+) rename .claude/skills/{techdebt.md => techdebt/SKILL.md} (87%) diff --git a/.claude/skills/techdebt.md b/.claude/skills/techdebt/SKILL.md similarity index 87% rename from .claude/skills/techdebt.md rename to .claude/skills/techdebt/SKILL.md index ccb85336901..54f37c4d10f 100644 --- a/.claude/skills/techdebt.md +++ b/.claude/skills/techdebt/SKILL.md @@ -1,3 +1,15 @@ +--- +name: techdebt +description: Analyze branch changes for technical debt, code duplication, and unnecessary complexity +user-invocable: true +context: fork +allowed-tools: + - Bash + - Read + - Grep + - Glob +--- + # Techdebt Cleanup Skill Analyze changes on the current branch to identify and fix technical debt, code duplication, and unnecessary complexity. From bd198f8fbc0b7f86c5666d0fb46505d858ab64e5 Mon Sep 17 00:00:00 2001 From: Bruce Bujon Date: Wed, 4 Feb 2026 20:05:40 +0100 Subject: [PATCH 5/5] fix(ci): Fix diff to compute merge base first --- .claude/skills/techdebt/SKILL.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.claude/skills/techdebt/SKILL.md b/.claude/skills/techdebt/SKILL.md index 54f37c4d10f..6929e6e2240 100644 --- a/.claude/skills/techdebt/SKILL.md +++ b/.claude/skills/techdebt/SKILL.md @@ -18,18 +18,22 @@ Analyze changes on the current branch to identify and fix technical debt, code d ### Step 1: Get Branch Changes -Find the upstream remote and compare against it: +Find the merge-base (where this branch diverged from master) and compare against it: ```bash -# Find upstream (DataDog org repo) and show changes +# Find upstream (DataDog org repo) UPSTREAM=$(git remote -v | grep -E 'DataDog/[^/]+(.git)?\s' | head -1 | awk '{print $1}') if [ -z "$UPSTREAM" ]; then echo "No DataDog upstream found, using origin" UPSTREAM="origin" fi -echo "Comparing against: $UPSTREAM/master" -git diff ${UPSTREAM}/master --stat -git diff ${UPSTREAM}/master --name-status + +# Find the merge-base (commit where this branch diverged from master) +MERGE_BASE=$(git merge-base HEAD ${UPSTREAM}/master) +echo "Comparing changes introduced on this branch since diverging from master using base commit: $MERGE_BASE" + +git diff $MERGE_BASE --stat +git diff $MERGE_BASE --name-status ``` If no changes exist, inform the user and stop.