[BUG] Slash commands don't work in non-interactive json streaming mode
Resolved 💬 4 comments Opened Jul 23, 2025 by SawyerHood Closed Jul 25, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- Claude CLI version: V1.0.58
- Operating System: macOS 15.4.1
- Terminal: VSCode terminal and Ghostty
Bug Description
Slash commands don’t work in sdk mode.
If I have a custom project command .claude/commands/quack.md
With this contents:
Say banana and how much you love the minions movie.
And then run claude interactively with “/quack”, this is the output in the session file:
{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"9d77ea9c-a7a5-4b13-a590-baaf81427e77","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":"<command-message>quack is running…</command-message>\n<command-name>/quack</command-name>"},"uuid":"ec306def-f6ab-45f0-83db-02b25d5ae566","timestamp":"2025-07-23T02:34:13.997Z"}
{"parentUuid":"ec306def-f6ab-45f0-83db-02b25d5ae566","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"9d77ea9c-a7a5-4b13-a590-baaf81427e77","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":[{"type":"text","text":"Say banana and how much you love the minions movie.\n"}]},"isMeta":true,"uuid":"d77a8921-6e94-431d-bd29-1cd03c3749be","timestamp":"2025-07-23T02:34:13.997Z"}
{"parentUuid":"d77a8921-6e94-431d-bd29-1cd03c3749be","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"9d77ea9c-a7a5-4b13-a590-baaf81427e77","version":"1.0.58","gitBranch":"fix-cc","message":{"id":"msg_01JvtTuV5bRoc8BpHH8nPxgY","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"text","text":"banana! I absolutely adore the Minions movie - those little yellow creatures with their gibberish language and obsession with bananas are pure comedic genius. The way they say \"banana\" in their adorable voices while causing delightful chaos is entertainment perfection!"}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":17715,"cache_read_input_tokens":0,"output_tokens":60,"service_tier":"standard"}},"requestId":"req_011CRPAmyNwp7Nha3u1bS3Ks","type":"assistant","uuid":"7cf1c8b5-6806-4ea5-a252-783733b56f39","timestamp":"2025-07-23T02:34:18.950Z"}
Note that the command gets expanded. If I do it interactively like:
claude -p --output-format stream-json --verbose '/quack'
The session json file looks like this:
{"type":"summary","summary":"Quack Command and Banana Minions Chatter","leafUuid":"3795d118-9ef7-416f-bec3-ad46cfdf707d"}
{"type":"summary","summary":"Quack Command and Banana Minions Chatter","leafUuid":"9c557694-7303-4f91-9c4d-10bbc8b9f2bf"}
{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":"<command-message>quack is running…</command-message>\n<command-name>/quack</command-name>"},"uuid":"4a7cb051-793e-43ac-b86e-3dffd6dec684","timestamp":"2025-07-23T02:41:17.987Z"}
{"parentUuid":"4a7cb051-793e-43ac-b86e-3dffd6dec684","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":[{"type":"text","text":"Say banana and how much you love the minions movie.\n"}]},"isMeta":true,"uuid":"72f4c5f8-6a62-4e92-84ea-5a1915b66d48","timestamp":"2025-07-23T02:41:17.987Z"}
{"parentUuid":"72f4c5f8-6a62-4e92-84ea-5a1915b66d48","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","message":{"id":"msg_01DVbhK5xcQCKgNuVdHrNkpn","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"text","text":"I'll help you with that! Let me use the Task tool to execute the /quack command."}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":17334,"cache_read_input_tokens":0,"output_tokens":1,"service_tier":"standard"}},"requestId":"req_011CRPBKFm3dXkTST6NgC1a3","type":"assistant","uuid":"9aaee214-c2b2-40b0-bb4a-17323cc36838","timestamp":"2025-07-23T02:41:21.677Z"}
{"parentUuid":"9aaee214-c2b2-40b0-bb4a-17323cc36838","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","message":{"id":"msg_01DVbhK5xcQCKgNuVdHrNkpn","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"tool_use","id":"toolu_0178CWDxU2AftiHZWcP7XUfn","name":"Task","input":{"description":"Execute /quack command","prompt":"/quack"}}],"stop_reason":"tool_use","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":17334,"cache_read_input_tokens":0,"output_tokens":96,"service_tier":"standard"}},"requestId":"req_011CRPBKFm3dXkTST6NgC1a3","type":"assistant","uuid":"e32792ec-6d57-4eb2-8ce2-ad2a89489a76","timestamp":"2025-07-23T02:41:22.254Z"}
{"parentUuid":null,"isSidechain":true,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":"/quack"},"uuid":"9ec225bb-06fa-4e3d-a493-2f81ade2a73d","timestamp":"2025-07-23T02:41:22.278Z"}
{"parentUuid":"9ec225bb-06fa-4e3d-a493-2f81ade2a73d","isSidechain":true,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","message":{"id":"msg_01SAy2CxiAaWTAEYccZeYi42","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"text","text":"I don't see a command or specific task to perform with \"/quack\". This appears to be either:\n\n1. A typo or incomplete command\n2. A test to see how I respond\n3. An attempt to use a command that doesn't exist in this codebase\n\nCould you please clarify what you'd like me to help you with? I'm ready to assist with any coding tasks, file operations, or questions about the Terragon codebase."}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":13935,"cache_read_input_tokens":0,"output_tokens":102,"service_tier":"standard"}},"requestId":"req_011CRPBKYBGveA6ZiAyPyQEZ","type":"assistant","uuid":"2d8d8201-203e-43cc-8407-d0defa99753b","timestamp":"2025-07-23T02:41:27.093Z"}
{"parentUuid":"e32792ec-6d57-4eb2-8ce2-ad2a89489a76","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_0178CWDxU2AftiHZWcP7XUfn","type":"tool_result","content":[{"type":"text","text":"I don't see a command or specific task to perform with \"/quack\". This appears to be either:\n\n1. A typo or incomplete command\n2. A test to see how I respond\n3. An attempt to use a command that doesn't exist in this codebase\n\nCould you please clarify what you'd like me to help you with? I'm ready to assist with any coding tasks, file operations, or questions about the Terragon codebase."}]}]},"uuid":"e5f571d8-5316-42a5-bbc3-47764fc581aa","timestamp":"2025-07-23T02:41:27.132Z","toolUseResult":{"content":[{"type":"text","text":"I don't see a command or specific task to perform with \"/quack\". This appears to be either:\n\n1. A typo or incomplete command\n2. A test to see how I respond\n3. An attempt to use a command that doesn't exist in this codebase\n\nCould you please clarify what you'd like me to help you with? I'm ready to assist with any coding tasks, file operations, or questions about the Terragon codebase."}],"totalDurationMs":4854,"totalTokens":14041,"totalToolUseCount":0,"usage":{"input_tokens":4,"cache_creation_input_tokens":13935,"cache_read_input_tokens":0,"output_tokens":102,"service_tier":"standard"},"wasInterrupted":false}}
{"parentUuid":"e5f571d8-5316-42a5-bbc3-47764fc581aa","isSidechain":false,"userType":"external","cwd":"/Users/sawyerhood/terragon","sessionId":"74192f7a-6bb9-4189-9387-99b4fb24fac6","version":"1.0.58","gitBranch":"fix-cc","message":{"id":"msg_019TFVDxdH5MajCHE4cKcckJ","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"text","text":"Banana! I absolutely love the Minions movie - those adorable yellow creatures and their gibberish language are hilarious! 🍌"}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":5,"cache_creation_input_tokens":410,"cache_read_input_tokens":17334,"output_tokens":34,"service_tier":"standard"}},"requestId":"req_011CRPBKtxRs9PP6tqrdntyM","type":"assistant","uuid":"b405de06-4afb-427e-b8e9-5b38451ec733","timestamp":"2025-07-23T02:41:29.993Z"}
It looks like it is initializing the agent twice. Once with command expansion and once without.
Steps to Reproduce
- Add a custom slash command in the root of a project
- Run
claude -p --output-format stream-json --verbose '/command' - Read the json file for the session in
~/.claude/projects/{project}/{sessionid}.jsonl - Open it and not that it looks like two agent sessions are interleaved
Expected Behavior
- the command is expanded
Actual Behavior
- two invocations of the agent are interleaved into the session file
- it seems there is a race where one of them is actually streamed via stdout
Other Info
It actually seems that this might not work with any slash commands including builtins like /compact
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗