For an overview of all available workflows, see the main README.
Automatically identify duplicate code patterns and suggest refactoring opportunities
The Duplicate Code Detector workflow runs daily to analyze recent code changes and detect duplicate patterns. It creates focused issues (max 3 per run) for significant duplication patterns, automatically assigned to @copilot for potential remediation.
# Install the 'gh aw' extension
gh extension install github/gh-aw
# Add the workflow to your repository
gh aw add-wizard githubnext/agentics/duplicate-code-detectorThis walks you through adding the workflow to your repository.
graph LR
A[Analyze Recent Changes] --> B[Detect Patterns]
B --> C[Find Duplicates]
C --> D{Significant?}
D -->|Yes| E[Create Refactoring Issue]
D -->|No| F[Report: Code is DRY]
The workflow reports identical or nearly identical functions, repeated code blocks, similar classes with overlapping functionality, and copy-pasted code. It excludes standard boilerplate, test setup code, config files, and small snippets (<5 lines).
Based on usage in the gh-aw repository: 79% merge rate (76 merged PRs out of 96 proposed).
The workflow is configured to:
- Run daily
- Create max 3 issues per run
- Auto-expire issues after 2 days if not addressed
- Skip test files, generated code, and workflow files
After editing run gh aw compile to update the workflow and commit all changes to the default branch.