Sign in
Explore
Workflows · WorkflowEveryday codingReviewed

Duplicate Code Detector

Finds duplicate code patterns across the codebase and suggests refactoring opportunities.

Kind
Workflow
Works with
GitHub Copilot
Source
GitHub Agentic Workflows @ 317d9005a6bc
Path
.github/workflows/duplicate-code-detector.md
License
MIT
Jobs
Review
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# Duplicate Code Detection

Analyze code to identify duplicated patterns using Serena's semantic code analysis capabilities. Report significant findings that require refactoring.

## Task

Detect and report code duplication by:

1. **Analyzing Recent Commits**: Review changes in the latest commits
2. **Detecting Duplicated Code**: Identify similar or duplicated code patterns using semantic analysis
3. **Reporting Findings**: Create a detailed issue if significant duplication is detected (threshold: >10 lines or 3+ similar patterns)

## Context

- **Repository**: ${{ github.repository }}
- **Commit ID**: ${{ github.event.head_commit.id }}
- **Triggered by**: @${{ github.actor }}

## Analysis Workflow

### 1. Project Activation

Activate the project in Serena:
- Use `activate_project` tool with workspace path `${{ github.workspace }}` (mounted repository directory)
- This sets up the semantic code analysis environment

### 2. Changed Files Analysis

Identify and analyze modified files:
- Determine files changed in the recent commits
- **ONLY analyze .go and .cjs files** - exclude all other file types
…