From c3dd4efe82d47930cae33893b01d4085512f615e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Guti=C3=A9rrez?= <35082514+alezmad@users.noreply.github.com> Date: Thu, 9 Apr 2026 02:16:00 +0100 Subject: [PATCH] feat(cli): enforce context:fork via Agent tool instruction in prompts/get Claude Code's MCP prompts path doesn't support the context field natively. When a skill has context:"fork", prepend an instruction telling the model to use the Agent tool with the specified agent type and model. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/cli/src/mcp/server.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/cli/src/mcp/server.ts b/apps/cli/src/mcp/server.ts index 6084013..78d555f 100644 --- a/apps/cli/src/mcp/server.ts +++ b/apps/cli/src/mcp/server.ts @@ -336,6 +336,17 @@ Your message mode is "${messageMode}". if (manifest.argument_hint) fm.push(`argument-hint: "${manifest.argument_hint}"`); fm.push("---\n"); if (fm.length > 3) content = fm.join("\n") + content; + + // Enforce context:fork via Agent tool instruction — Claude Code's MCP prompts + // path doesn't support the context field natively, so we instruct the model. + if (manifest.context === "fork") { + const agentType = manifest.agent || "general-purpose"; + const modelHint = manifest.model ? `, model: "${manifest.model}"` : ""; + const toolsHint = manifest.allowed_tools?.length + ? `\nOnly use these tools: ${manifest.allowed_tools.join(", ")}.` + : ""; + content = `IMPORTANT: Execute this skill in an isolated sub-agent. Use the Agent tool with subagent_type="${agentType}"${modelHint}. Pass the full instructions below as the agent prompt.${toolsHint}\n\n` + content; + } } return {