-
Notifications
You must be signed in to change notification settings - Fork 548
Add Claude Code plugin command discovery #848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add "plugin" as a third source type alongside "local" and "global" in the SlashCommand schema. This enables the API to distinguish commands from Claude Code marketplace plugins.
Add discovery of slash commands from Claude Code marketplace plugins. Reads installed_plugins.json and settings.json to find enabled plugins and scans their commands directories. Plugin commands are namespaced as /plugin-name:command-name and respect enabled/disabled state. Gracefully handles missing or malformed plugin metadata files.
Add 12 unit tests covering plugin discovery edge cases: - Missing/malformed metadata files - Enabled/disabled plugin filtering - Nested commands and namespacing - Multiple plugins Add integration test with 3 scenarios validating end-to-end behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to c354296 in 1 minute and 46 seconds. Click for details.
- Reviewed
1274lines of code in8files - Skipped
0files when reviewing. - Skipped posting
5draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. hld/api/server.gen.go:1
- Draft comment:
This file is auto-generated by oapi-codegen (v2.5.1); please avoid manual modifications. Ensure that the new constant for SlashCommandSourcePlugin is correctly integrated with the rest of the system. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. hld/daemon/daemon_slash_commands_integration_test.go:195
- Draft comment:
Prefer using the api.SlashCommandSourceLocal constant (and similarly for 'global') instead of literal strings ('local', 'global') in assertions for better maintainability and consistency. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. hld/daemon/daemon_slash_commands_integration_test.go:630
- Draft comment:
When removing the installed_plugins.json file (using os.Remove), consider checking and ignoring errors if the file does not exist. This can improve robustness in test cleanup. - Reason this comment was not posted:
Comment looked like it was already resolved.
4. hld/go.mod:5
- Draft comment:
The go.mod file updates (including replace directives and dependency versions) appear intentional. Please double‐check that these dependency version bumps (e.g., for github.com/golang/mock) are expected. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. hld/go.sum:1
- Draft comment:
The go.sum file reflects updated dependency checksums. They seem consistent with the go.mod changes; no issues noted. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_btR2tdcTJ52P8wnY
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
|
Thanks for the PR @crdant ! Plugins are still considered to be in beta by anthropic right now so I am hesitant to merge something that depends on what the Claude code team considers an unstable API Will discuss internally and let you know where we wind up on this |
Makes a lot of sense. This PR and my last one have a common theme. This whack-a-mole game isn't the best thing for me as a user or for your team as creators. Perhaps there's a better approach I can't see to stay aligned so the |
|
Appreciate both sides of this convo, and thanks chuck for the PR! @K-Mistele is this something we could drop in an opt-in “experimental features” thing? I would guess Claude will continue to launch beta features that ppl wanna use and we should weigh the tradeoffs of not supporting them |
|
@K-Mistele @dexhorthy if the experimental feature model makes sense, I can imagine I wouldn't be too hard for me to wrap it and contribute the whole thing. |
What problem(s) was I solving?
Problem: CodeLayer users cannot see or use slash commands from Claude Code marketplace plugins in the CodeLayer UI.
Claude Code marketplace plugins install their commands to a different location (
~/.config/claude-code/plugins/{plugin-name}/commands/), and their metadata is stored in separate JSON files (installed_plugins.jsonandsettings.json). The daemon had no logic to discover these plugin commands.Impact: Users installing plugins like "Superpowers" or other marketplace plugins would not see those commands available in CodeLayer, creating a disconnected experience between Claude Code and CodeLayer.
What user-facing changes did I ship?
CodeLayer will now display slash commands from installed Claude Code plugins:
source: "plugin"/plugin-name:command-name(e.g.,/superpowers:brainstorm)/plugin-name:config:show)No breaking changes - existing local and global commands work exactly as before.
How I implemented it
Architecture Decision: Isolated Plugin Discovery
I chose to encapsulate all plugin-specific logic in isolated functions to make the plugin system maintainable and adaptable to future changes by Anthropic:
New File:
hld/api/handlers/plugins.go(122 lines)discoverPluginCommands(configDir string)- Main discovery orchestrationscanPluginCommandsDir(dir, pluginName string)- Scans individual plugin commandsImplementation Details
1. OpenAPI Schema Extension (
hld/api/openapi.yaml)"plugin"to theSlashCommand.sourceenumSlashCommandSourcePluginconstant2. Plugin Discovery Logic (
hld/api/handlers/plugins.go)if
CLAUDE_CONFIG_DIRis discovery will use~/.claude3. Error Handling (Graceful Degradation)
installed_plugins.json→ return empty list (no plugins installed)settings.json→ treat all plugins as enabled (default behavior)4. Integration (
hld/api/handlers/sessions.go)5. Comprehensive Testing
Unit Tests (
hld/api/handlers/plugins_test.go- 12 tests):installed_plugins.jsonIntegration Tests (
hld/daemon/daemon_slash_commands_integration_test.go):TestPluginCommandsIntegrationwith 3 subtests:Key Design Decisions
1. Namespace Format:
/plugin-name:commandcommand.name.split(':')[0].slice(1)gives plugin name2. Config Directory Detection
CLAUDE_CONFIG_DIRenvironment variable logic~/.claude(macOS/Linux standard)expandTilde()helper function3. Isolation Pattern
plugins.gofileHow to verify it
make check testpassesVerification Results:
Test Coverage:
Manual Testing (optional but recommended):
With real Claude Code plugins installed:
Description for the changelog
Added: Claude Code marketplace plugin commands now appear in CodeLayer's slash command list. Plugin commands are discovered from
~/.config/claude-code/plugins/and respect enabled/disabled state from Claude Code settings. Commands are namespaced as/plugin-name:command-name.A picture of a cute animal (not mandatory but encouraged)
Technical Notes
Files Modified:
hld/api/openapi.yaml- Added "plugin" to source enumhld/api/server.gen.go- Auto-generated constanthld/api/handlers/sessions.go- Added plugin discovery call (24 lines)hld/daemon/daemon_slash_commands_integration_test.go- Added integration test (274 lines)hld/go.mod/hld/go.sum- Added test mock dependenciesFiles Created:
hld/api/handlers/plugins.go- Plugin discovery implementation (122 lines)hld/api/handlers/plugins_test.go- Comprehensive unit tests (250+ lines)Implementation Plan:
thoughts/shared/plans/2025-01-08-plugin-command-discovery.mdResearch Document:
docs/research/2025-11-04-codelayer-slash-command-loading.mdTotal Changes: +635 lines, -156 lines across 6 modified + 2 new files
Important
Adds discovery and display of Claude Code marketplace plugin commands in CodeLayer UI, with new logic in
plugins.goand comprehensive testing.hld/api/handlers/plugins.go./plugin-name:command-nameand appear withsource: "plugin".settings.json.plugins.gofor plugin command discovery logic.openapi.yamlto add "plugin" toSlashCommand.sourceenum.sessions.goto include plugin command discovery.plugins_test.gofor various scenarios including missing files and malformed JSON.daemon_slash_commands_integration_test.gofor plugin command discovery.go.modandgo.sumfor new dependencies.This description was created by
for c354296. You can customize this summary. It will automatically update as commits are pushed.