Bug: Trailing quote in subagent_type parsing from pseudo-code blocks
Summary
When Claude Code interprets Task() pseudo-code blocks in slash command markdown files, the subagent_type parameter value incorrectly includes a trailing quote character, causing agent spawning to fail.
Environment
- Claude Code Version: 2.1.15
- Platform: Linux (WSL2)
- OS Version: 6.6.87.2-microsoft-standard-WSL2
Reproduction Steps
- Create a slash command markdown file with a Task() instruction block:
## Spawn Agent
Task(
prompt="Your instructions here",
subagent_type="general-purpose",
model="sonnet",
description="Research Phase 2.5"
)
- Execute the slash command that triggers this Task() block
- Observe the error output
Expected Behavior
Claude Code should parse subagent_type="general-purpose" and extract the value general-purpose (without quotes).
The agent should spawn successfully with type general-purpose.
Actual Behavior
Claude Code extracts the value as general-purpose" (with trailing quote).
Error message:
● general-purpose"(Research Phase 2.5)
⎿ Error: Agent type 'general-purpose"' not found. Available agents: Bash,
general-purpose, statusline-setup, Explore, Plan, claude-code-guide, ...
Root Cause Analysis
The string parsing logic appears to have an off-by-one error when extracting quoted string values from pseudo-code blocks in markdown:
- The opening
"is correctly stripped - The closing
"is incorrectly included in the extracted value
Important distinction: When Claude interprets the markdown instructions and calls the Task tool directly (via proper tool invocation), it works correctly. The bug occurs specifically when Claude Code's parser tries to automatically extract and execute Task() calls from code blocks.
Affected Use Cases
This bug affects any slash command or skill that uses the Task() pseudo-code syntax with quoted subagent_type values. This is a common pattern in:
- Custom slash commands
- The GSD (Get Shit Done) framework (https://github.com/glittercowboy/get-shit-done)
- Any system that uses Task() blocks to orchestrate subagents
Workaround
None known that works reliably. The bug is intermittent.
Suggested Fix
Review the regex or string parsing logic that extracts parameter values from Task() pseudo-code blocks in markdown. Ensure both opening and closing quotes are stripped from the extracted value.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗