Skip to content

Conversation

@TechNickAI
Copy link
Owner

Summary

  • Detects when users have both Claude Code marketplace plugins AND local copies of the same commands/agents/skills that override marketplace versions
  • Educates users about the plugin marketplace benefits and how it prevents version drift
  • Offers users a clear choice: remove duplicates and use marketplace (recommended), or keep both
  • Only removes exact filename matches, preserves all custom commands/agents/skills users created
  • Handles the special case of ai-coding-config.md (always preserved even if duplicate)
  • Version bumps: core plugin 2.0.1 → 2.1.0, ai-coding-config.md 2.0.1 → 2.1.0

Changes

The /ai-coding-config update command now includes a <local-duplicate-cleanup> section that:

  • Detection: Reads ~/.claude/plugins/installed_plugins.json to check if marketplace plugins exist, then uses Glob to compare files in marketplace cache paths vs local project directories
  • Classification: Separates duplicate files from custom user files
  • Education: Explains what the plugin marketplace is, why local duplicates create confusion, and the benefits of using marketplace versions
  • User control: Uses AskUserQuestion to let users choose between removing duplicates (recommended) or keeping both
  • Safe removal: Only deletes exact filename matches, preserves custom files and always keeps .claude/commands/ai-coding-config.md

This solves a common problem where projects set up before the marketplace existed have outdated local copies that override marketplace versions, causing version drift and preventing auto-updates.

Testing

Can be tested on the mcp-hubby project, which has the exact situation this addresses: local copies of core commands/agents/skills alongside marketplace plugins.

Steps to verify:

  1. Check that mcp-hubby has both marketplace plugins installed and local .claude/ files
  2. Run /ai-coding-config update in mcp-hubby
  3. Verify detection identifies the correct duplicates and custom files
  4. Test both user choice paths: removing duplicates and keeping both
  5. Confirm only exact filename matches are removed
  6. Verify ai-coding-config.md is always preserved

🤖 Generated with Claude Code

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: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@claude
Copy link

claude bot commented Dec 19, 2025

Code Review

I've reviewed PR #13 and have the following feedback:

Positive Aspects

Clear problem statement: The PR addresses a real issue where users have outdated local copies overriding marketplace plugins

User education: Excellent explanation of the plugin marketplace benefits and why duplicates are problematic

Safety-first approach: The logic preserves custom files and has a special exception for ai-coding-config.md

User control: Uses AskUserQuestion to give users choice rather than forcing removal

Semantic versioning: Appropriate minor version bump (2.0.1 → 2.1.0) for new functionality


Concerns and Suggestions

1. Path Construction Relies on Wildcards (Medium Priority)

Lines 318-321 use wildcard patterns like:

~/.claude/plugins/cache/ai-coding-config/core/*/commands/

Issue: The prompt says "Get the plugin version from installed_plugins.json to construct the correct path" but then shows wildcard usage. This creates ambiguity for the LLM executing this command.

Recommendation: Be more explicit about path construction:

Read the version from installed_plugins.json for each plugin (core, agents, skills).
Construct exact paths using the version number:
- Commands: ~/.claude/plugins/cache/ai-coding-config/core/{version}/commands/
- Agents: ~/.claude/plugins/cache/ai-coding-config/agents/{version}/agents/
- Skills: ~/.claude/plugins/cache/ai-coding-config/skills/{version}/skills/

If the version isn't in installed_plugins.json or the path doesn't exist, fall back to using Glob with wildcards to find the most recent version.

2. Symlink Detection Method Unclear (Low Priority)

Lines 301-304 specify checking for "real directory, not symlink" but don't explain HOW to detect this.

Recommendation: Add explicit detection method:

Use bash test commands to distinguish directories from symlinks:
- [ -d .claude/commands ] && [ ! -L .claude/commands ] # real directory
- [ -L .claude/commands ] # symlink (skip these)

3. Error Handling Not Specified (Medium Priority)

The cleanup section doesn't specify what to do if:

  • installed_plugins.json doesn't exist
  • File removal fails due to permissions
  • The marketplace cache is missing or corrupted

Recommendation: Add error handling guidance:

<error-handling>
- If installed_plugins.json doesn't exist: Skip this section entirely (no plugins installed)
- If file removal fails: Report the error to user and continue with remaining files
- If marketplace cache paths don't exist: Warn user their plugin installation may be corrupt
</error-handling>

4. Alignment with Project Guidelines (Low Priority)

Per prompt-engineering.mdc lines 34-38, the project prefers:

  • Using native tools over bash
  • Avoiding bash loops
  • Using Glob for file listing

The current prompt follows these well with "Use Glob to list files" - good adherence to project standards.

5. Token Efficiency (Minor)

The user communication block (lines 331-362) is quite verbose. Per prompt-engineering.mdc, this is acceptable for LLM-to-LLM communication when clarity is needed, but consider if some sections could be condensed without losing meaning.

Current: ~450 words of explanation
Possible optimization: The marketplace explanation could reference documentation rather than repeating it


Security Considerations

Safe deletion strategy: Only removes exact filename matches from a known list
Exception for critical files: ai-coding-config.md always preserved
No wildcards in rm commands: Prompt specifies "individual rm commands"

One concern: The prompt doesn't explicitly warn against using rm -rf or recursive deletion. Consider adding:

Use individual rm commands for each file. Never use rm -rf or recursive deletion.

Testing Recommendations

The PR mentions testing on mcp-hubby project. Consider adding test cases for:

  1. Edge case: User has marketplace plugins but no local duplicates (should skip gracefully)
  2. Edge case: User has local files but no marketplace plugins (should skip gracefully)
  3. Mixed scenario: Some duplicates + some custom files (verify correct classification)
  4. Symlink scenario: Local directories are symlinks (should be detected and skipped)
  5. Permission errors: Files that can't be deleted

Minor: Version Consistency

The marketplace.json only bumps core to 2.1.0, but the other plugins (agents, skills) remain at 2.0.1. This is correct since only the core plugin's ai-coding-config.md command changed. Just confirming this is intentional.


Recommendation

Approve with suggestions. The core functionality is sound and addresses a real user problem. The concerns above are mostly about edge case handling and clarity for LLM execution. None are blocking issues.

Consider addressing the path construction ambiguity (concern #1) and adding error handling guidance (concern #3) before merging, as these could lead to confusing behavior in edge cases.

For each directory type (commands, agents, skills):
1. Use Glob to list files in the marketplace plugin install path
2. Use Glob to list files in the local project directory
3. Compare the two lists to identify exact filename matches
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Filename matching may delete user-customized file versions

The "Critical constraint" on line 308 states to "Only remove files that are duplicates of marketplace content" and "Preserve any custom commands, agents, or skills the user created themselves." However, the implementation on line 315 uses "exact filename matches" rather than content comparison. This means if a user customized a marketplace file (same filename, modified content), it would be identified as a duplicate and offered for removal, potentially causing data loss. Users seeing a list of "duplicates" may not realize their customized version is included since they might assume duplicates have identical content.

Fix in Cursor Fix in Web

@TechNickAI TechNickAI merged commit a10ebcf into main Dec 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants