docs: explain how to use custom slash commands from the SDK#881
Open
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
Open
docs: explain how to use custom slash commands from the SDK#881MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
Conversation
Document how to load custom slash commands from .claude/commands/ via setting_sources=["project"] and from plugins via the plugins option. This is the recurring question on issue anthropics#120 - the SDK already supports both paths through existing options, but the README didn't surface it. Closes anthropics#120
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#120 keeps coming back: people try
/helpor a custom/foofrom.claude/commands/against the Python SDK, get nothing, and assume it'sunsupported. The SDK already supports both paths the CLI uses
(
setting_sources+cwd, orplugins), but the README never says so,so the only places it's documented are buried inside
examples/setting_sources.pyandexamples/plugin_example.py.This is the smallest fix that closes the loop: a README section right
after
Working Directorythat shows the two minimal recipes and links tothe runnable examples.
What
Custom Slash Commandssubsection underBasic Usage: query()with two snippets and a note about theNone/[]setting_sourcesdefaults.setting_sources.py,plugin_example.py) so people can see the full flow without copy-paste.ClaudeAgentOptions.I deliberately did not add a new
slash_commandsfield onAgentDefinition/ClaudeAgentOptions: slash commands are loaded bythe CLI from the filesystem (
.claude/commands/or a plugin), and theSDK already has the right knobs for both. Adding a parallel registration
API would just give people a second way to do the same thing.
Tested
diffagainstmain's README shows only the new section is added; nosurrounding text is touched.
examples/setting_sources.py(theproject_and_usercase) andexamples/plugin_example.pyalready doend-to-end, so the runnable proof is the existing examples.
Closes #120.