Skip to content

docs: explain how to use custom slash commands from the SDK#881

Open
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:feat/docs-slash-commands-120
Open

docs: explain how to use custom slash commands from the SDK#881
MukundaKatta wants to merge 1 commit intoanthropics:mainfrom
MukundaKatta:feat/docs-slash-commands-120

Conversation

@MukundaKatta
Copy link
Copy Markdown

Why

#120 keeps coming back: people try /help or a custom /foo from
.claude/commands/ against the Python SDK, get nothing, and assume it's
unsupported. The SDK already supports both paths the CLI uses
(setting_sources + cwd, or plugins), but the README never says so,
so the only places it's documented are buried inside
examples/setting_sources.py and examples/plugin_example.py.

This is the smallest fix that closes the loop: a README section right
after Working Directory that shows the two minimal recipes and links to
the runnable examples.

What

  • README: new Custom Slash Commands subsection under Basic Usage: query() with two snippets and a note about the None / []
    setting_sources defaults.
  • Points at the existing examples (setting_sources.py,
    plugin_example.py) so people can see the full flow without copy-paste.
  • No code changes. No type changes. No new fields on
    ClaudeAgentOptions.

I deliberately did not add a new slash_commands field on
AgentDefinition / ClaudeAgentOptions: slash commands are loaded by
the CLI from the filesystem (.claude/commands/ or a plugin), and the
SDK 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

  • diff against main's README shows only the new section is added; no
    surrounding text is touched.
  • The two snippets mirror what examples/setting_sources.py (the
    project_and_user case) and examples/plugin_example.py already do
    end-to-end, so the runnable proof is the existing examples.

Closes #120.

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
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.

slash commands

1 participant