pratos/clanker-setup/code-duplication-check
Claude Code and agent skill by pratos/clanker-setup
- community
Checking that the SKILL.md file is still in the repository.
Prevents recreating existing code by detecting component requests, searching codebase for similar implementations, and offering reuse options before writing new code.
Install
npx vskill@latest install pratos/clanker-setup/code-duplication-checkSKILL.md
The same SKILL.md was published earlier as pratos/clanker-setup/code-duplication-check.
Code Duplication Prevention
Activation
When this skill is triggered, ALWAYS display this banner first:
When to Use
This skill activates automatically when it detects requests to write specific components. Pattern matching on:
- "write a callback"
- "create a utility" / "add a helper"
- "implement a new loss" / "add a loss function"
- "add a metric" / "create a metric"
- "build a multi-GPU function" / "add multi-GPU support"
- "create a data augmentation" / "add augmentation"
- "implement a scheduler" / "add scheduler"
- "write a transform" / "add transform"
Key principle: Search first, code second. Only write new code after checking for existing implementations.
Search Process
Scope
Search entire src/ directory comprehensively.
Strategy
Combine two approaches:
- Keyword-based: Exact matches on function/class names, file names, key terms
- Semantic understanding: Conceptual similarity (e.g., "learning rate warmup" finds scheduler code)
What to Track
- ML-specific patterns: PyTorch Lightning callbacks, multi-GPU utilities, WandB logging, checkpoint handlers, losses, metrics, augmentations, schedulers
- General Python utilities: Reusable functions/classes (data processing, file I/O, config helpers)
Matching Strictness
Use judgment based on context:
- Strict for well-defined ML components (callbacks, losses, metrics)
- Broader for general utilities (more variation in implementations)
Result Limiting
- Show 1 match if very confident it's the right one
- Show up to 3 matches if uncertain about which is best
- Rank by relevance (name similarity, usage patterns, code structure)
Presentation Flow
When matches are found, PAUSE before writing any code and present:
<code snippet>
Each match shows:
- Code snippet (function/class definition)
- File location with line numbers
- Brief context if helpful
Three Workflow Paths
Path 1: Use Existing
- Show import statement
- Show usage example (how to add to trainer, what parameters it needs, etc.)
- Confirm with user
- Done
Example:
Path 2: Write New
- Justify first: Explain why existing code doesn't meet requirements
- Proceed to write the requested code
- Document rationale in code comments or commit message
Example:
Path 3: Adapt Existing
- Show the existing code
- Show proposed modifications (highlighted or explained)
- Explain what changes are needed and why
- Ask for confirmation before editing
Example:
Special Cases
Registry-Based Components
For components using the project's registry pattern (@register_model, @register_loss):
- Check registry first: Look in
src/<component_type>/__init__.pyfor registered items - Then check implementations: Search individual files in
src/<component_type>/ - Suggest registry pattern: If match found in registry, show how to use it via
get_<component>()
Example:
from src.losses import get_loss_function loss_fn = get_loss_function({"type": "sisdr"})
Component-Specific Directories
Prioritize searches based on component type:
- Callbacks: Prioritize
src/trainer/, checksrc/utils/ - Losses/Metrics: Check registry first, then
src/losses/ - Utilities: Prioritize
src/utils/, search allsrc/ - Data augmentations:
src/data/augmentations.py,src/data/ - Multi-GPU helpers:
src/trainer/,src/config/,src/utils/
No Matches Found
If no similar code is found:
- Proceed silently without interruption
- Write the requested code normally
- No need to announce "no matches found"
Low-friction design: only intervene when reuse is possible.
Implementation Tools
Use these tools for search and presentation:
- Grep: Search for keywords and patterns
```
- Use with
output_mode="files_with_matches"first to find files - Then
output_mode="content"with-A/-Bcontext for snippets - Try both exact keywords and related terms
```
- Glob: Pattern matching for specific file types
```
- **/*.py for all Python files
- src/trainer/**/*.py for callbacks
- src/losses/*.py for losses
```
- Read: Get code snippets with line numbers
- AskUserQuestion: Present the 3-choice decision
Search Examples
Example 1: Callback Request
Example 2: Utility Request
Example 3: Loss Function Request
Red Flags - Never Do This
❌ Write code immediately without searching first ❌ Show matches without file location and line numbers ❌ Proceed to "write new" without justifying why existing code won't work ❌ Search only in one directory (always comprehensive search) ❌ Announce "no matches found" (silent when nothing found) ❌ Show more than 3 matches (information overload)
Success Criteria
✅ Auto-detects component writing requests ✅ Searches comprehensively before presenting options ✅ Shows code snippets with file locations ✅ Presents 3 clear options: use, write new, adapt ✅ Handles all three workflow paths completely ✅ Silent when no matches (low friction) ✅ Integrates with registry patterns when applicable
Notes
- This skill reduces code duplication across the research team
- Promotes discovery of existing utilities and patterns
- Forces deliberate decision-making about new code vs. reuse
- Minimal friction: only intervenes when helpful
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingclaude/skills/code-duplication-check/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pratos/clanker-setup/code-duplication-check)