Skip to content

Commit a10ebcf

Browse files
TechNickAINick Sullivanclaude
authored
✨ Detect and help clean up duplicate local command/agent/skill files (#13)
Add detection logic that identifies when users have both marketplace plugins AND local copies of the same commands, agents, or skills. When duplicates are found, the update command now educates users about the plugin marketplace approach and offers to remove duplicates while preserving any custom files. This solves the common confusion where users keep old local copies that override marketplace versions, leading to version drift and unexpected behavior. Users get to choose: embrace the marketplace for easier updates, or keep both. But now they're aware of what's happening and can make an informed decision. Bumps core plugin version to 2.1.0 to reflect this UX improvement. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Nick Sullivan <[email protected]> Co-authored-by: Claude Sonnet 4.5 <[email protected]>
1 parent 8c1708c commit a10ebcf

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"name": "core",
1313
"source": "./plugins/core",
1414
"description": "Essential commands and context for AI-assisted development workflows",
15-
"version": "2.0.1",
15+
"version": "2.1.0",
1616
"tags": ["commands", "workflows", "essential"]
1717
},
1818
{

plugins/core/commands/ai-coding-config.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: Set up or update AI coding configurations
33
argument-hint: [update]
4-
version: 2.0.1
4+
version: 2.1.0
55
---
66

77
# AI Coding Configuration
@@ -293,6 +293,87 @@ claude plugin install skills@ai-coding-config
293293
Offer: "Migrate to new plugin structure (Recommended)" or "Skip migration"
294294
</plugin-migration-check>
295295

296+
<local-duplicate-cleanup>
297+
Check for local file duplication when marketplace plugins are installed.
298+
299+
**Detection method:** Read `~/.claude/plugins/installed_plugins.json` to see if marketplace plugins are installed (core, agents, skills). If plugins are installed, check if the user also has local copies in their project.
300+
301+
Check for these local directories:
302+
- `.claude/commands/` (as a real directory, not symlink)
303+
- `.claude/agents/` (as a real directory, not symlink)
304+
- `.claude/skills/` (as a real directory, not symlink)
305+
306+
**Why this happens:** Some projects were set up before the marketplace approach. They have local copies of commands/agents/skills that are now outdated and create confusion because they override the marketplace versions.
307+
308+
**Critical constraint:** Only remove files that are duplicates of marketplace content. Preserve any custom commands, agents, or skills the user created themselves.
309+
310+
**Duplicate identification strategy:**
311+
312+
For each directory type (commands, agents, skills):
313+
1. Use Glob to list files in the marketplace plugin install path
314+
2. Use Glob to list files in the local project directory
315+
3. Compare the two lists to identify exact filename matches
316+
4. Only remove the duplicates
317+
318+
Example paths to check:
319+
- Commands: `~/.claude/plugins/cache/ai-coding-config/core/*/commands/` vs `.claude/commands/`
320+
- Agents: `~/.claude/plugins/cache/ai-coding-config/agents/*/agents/` vs `.claude/agents/`
321+
- Skills: `~/.claude/plugins/cache/ai-coding-config/skills/*/skills/` vs `.claude/skills/`
322+
323+
Get the plugin version from installed_plugins.json to construct the correct path.
324+
325+
**Exception:** Never remove `.claude/commands/ai-coding-config.md` even if it's a duplicate - this file needs to stay in the project.
326+
327+
**User communication and choice:**
328+
329+
If duplicates are found, explain the situation clearly:
330+
331+
"I found duplicate files in your project. You have local copies of commands/agents/skills that are also available through the Claude Code plugin marketplace.
332+
333+
**What's the plugin marketplace?**
334+
335+
The Claude Code plugin marketplace is a centralized system where commands, agents, and skills are installed once globally and automatically stay up to date. Instead of copying files into each project, plugins are installed to `~/.claude/plugins/` and shared across all your projects.
336+
337+
Benefits:
338+
- Auto-updates when you run `/ai-coding-config update`
339+
- One source of truth across all projects
340+
- No manual file copying or syncing needed
341+
342+
Read more: https://github.com/TechNickAI/ai-coding-config#plugin-marketplace
343+
344+
**Your situation:**
345+
346+
You have local files that duplicate marketplace content. Local files override marketplace versions, which means:
347+
- Your local copies don't auto-update
348+
- You might be using outdated versions
349+
- It's confusing which version is actually running
350+
351+
**Found duplicates:**
352+
[List specific duplicate files with their locations, e.g.:]
353+
- `.claude/commands/autotask.md`
354+
- `.claude/agents/code-reviewer.md`
355+
- `.claude/skills/research.md`
356+
357+
**Custom files that will be preserved:**
358+
[List files that exist locally but not in marketplace, e.g.:]
359+
- `.claude/agents/logo-fetcher.md` (your custom agent)
360+
- `.claude/commands/ai-coding-config.md` (required in project)
361+
362+
**Recommendation:** Remove the duplicate files and rely on the marketplace plugins. Your custom files will be preserved."
363+
364+
Use AskUserQuestion to present the choice:
365+
- "Remove duplicates and use marketplace (Recommended)" - Explanation: "Delete duplicate files, keep custom files, rely on marketplace for updates"
366+
- "Keep both" - Explanation: "Local files will continue to override marketplace versions"
367+
368+
If user chooses to remove duplicates:
369+
- Use individual `rm` commands for each duplicate file
370+
- Confirm what was removed
371+
- Confirm what was preserved (ai-coding-config.md + any custom files)
372+
- Remind: "You're now using marketplace plugins. Run `/ai-coding-config update` anytime to get the latest versions."
373+
374+
The goal is to eliminate confusion by removing duplicates while preserving custom work and educating the user about the marketplace approach.
375+
</local-duplicate-cleanup>
376+
296377
<claude-code-update>
297378
For Claude Code users with plugins installed:
298379

0 commit comments

Comments
 (0)