xiaohongshu
xiaohongshu
auto-duplicate-fixer
Automate detection and removal of duplicate files/functions in TypeScript, JavaScript, and Python projects. Safely refactor imports, validate with tests, and deploy changes with zero risk of breaking the system.
Full skill instructions
Automate detection and removal of duplicate files/functions in TypeScript, JavaScript, and Python projects. Safely refactor imports, validate with tests, and deploy changes with zero risk of breaking the system.
Designed for daily incremental fixes that keep architecture clean without chaos.
project_root: Path to projectmode: 'daily' | 'aggressive' | 'analysis' (default: 'daily')--dry-run: Preview only, don't modify.duplicate-report.json: Detection results.keep-remove-map.json: Decision mapping (keep/remove).refactor-log.json: Files changed, imports updated.validation-log.json: Test/lint/build results.deploy-log.json: Commit/PR status.pipeline-log.json: Full execution logsrc/utils or src/servicessrc/helpers, src/utils, src/servicesNaming convention:
src/
utils/ # General utilities (helper.ts, formatter.ts)
helpers/ # (DEPRECATED: merge to utils)
services/ # Business logic (userService.ts, authService.ts)
hooks/ # React hooks
components/ # UI components
constants/ # Constants
/common or /core packageExample structure:
src/
common/ # Shared utilities (helpers.py, validators.py)
core/ # Core business logic
services/ # Service classes
models/ # Data models
Command: npm run check <project> -- --format=json --min-tokens=50
Alternative (direct): node scripts/detect.js <project> --format=json --min-tokens=50
Process:
.ts, .tsx, .js, .jsx, .py files.duplicate-report.jsonTools:
jscpd: Copy-paste detectionts-morph / babel: AST parsingpython ast: Python structural analysisCommand: npm run decide <project> -- --report=.duplicate-report.json --strategy=test-coverage-first
Alternative (direct): node scripts/decide.js <project> --report=.duplicate-report.json --strategy=test-coverage-first
Decision ranking (highest score wins):
Example:
File A (helper.ts):
- 5 test cases → 15 points
- imported by 3 files → 6 points
- has types → 5 points
- follows convention → 3 points
Total: 29 points
File B (helpers/util.ts):
- 0 tests → 0 points
- imported by 1 file → 2 points
- no types → 0 points
- doesn't follow convention → 0 points
Total: 2 points
Decision: KEEP A, REMOVE B
Output: .keep-remove-map.json
Command: npm run refactor <project>
Alternative (direct): node scripts/refactor.js <project>
Process:
import x and from x import y statementsindex.ts, __init__.py).refactor-log.jsonSafety checks:
Command: npm run validate <project>
Alternative (direct): bash scripts/validate.sh <project>
Validation stack:
npm run test:ci / pytesttsc --noEmiteslint / flake8npm run buildIf ANY fails:
git checkout -- ..validation-log.jsonOutput: .validation-log.json
Command: npm run deploy <project> -- --auto-merge
Alternative (direct): node scripts/deploy.js <project> --auto-merge
Process:
git status for changesgit add -A).deploy-log.jsonCommit message:
Auto-fix: Remove duplicates and refactor imports
Files deleted: 5
Imports updated: 12
Automated by auto-duplicate-fixer skill
On Test Failure:
git checkout -- .
# Log failure to validation log
echo '{"status": "failed", "reason": "tests-failed", "timestamp": "'$(date -Iseconds)'"}' >> .validation-log.json
On TypeScript Errors:
npx tsc --noEmit --pretty
On Build Failure:
On Conflict:
npm run daily /path/to/project
npm run aggressive /path/to/project
npm run dry-run /path/to/project
# Detect only
npm run check /path/to/project
# View decisions
cat /path/to/project/.keep-remove-map.json
# Refactor
npm run refactor /path/to/project
# Validate
npm run validate /path/to/project
# Deploy
npm run deploy /path/to/project
Schedule daily at 2 AM (requires git access):
# Add to crontab
0 2 * * * cd /path/to/project && npm run daily
# Or in GitHub Actions
name: Daily Duplicate Fix
on:
schedule:
- cron: '0 2 * * *'
jobs:
fix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm run daily
- uses: peter-evans/create-pull-request@v4
| Language | Detection | Refactor | Validate |
|---|---|---|---|
| TypeScript | ✅ AST + jscpd | ✅ Import rewrite | ✅ tsc + test |
| JavaScript | ✅ AST + jscpd | ✅ Import rewrite | ✅ eslint + test |
| Python | ✅ AST | ✅ import rewrite | ✅ pytest + flake8 |
Before:
src/utils/format.ts (15 tests, imported 5 places)
src/helpers/formatter.ts (0 tests, imported 1 place)
Decision: KEEP src/utils/format.ts, REMOVE src/helpers/formatter.ts
Action:
- Update: src/services/user.ts
import { format } from '../utils/format';
- Delete: src/helpers/formatter.ts
- Delete: src/helpers/index.ts (if becomes empty)
Before:
core/validators.py (validate_email, validate_phone)
utils/helpers.py (validate_email, validate_phone)
Decision: KEEP core/validators.py, REMOVE utils/helpers.py
Action:
- Update: services/user.py
from core.validators import validate_email
- Delete: utils/helpers.py
Check any phase's logs:
cat .duplicate-report.json # What was found
cat .keep-remove-map.json # What will be kept/removed
cat .refactor-log.json # What was changed
cat .validation-log.json # Test results
cat .deploy-log.json # PR/commit status
cat .pipeline-log.json # Full execution timeline
aggressive mode for speedInstall script:
npm install
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience