Skip to content

Add codemode skill for @cloudflare/codemode#26

Draft
mksglu wants to merge 1 commit intocloudflare:mainfrom
mksglu:feat/add-codemode-skill
Draft

Add codemode skill for @cloudflare/codemode#26
mksglu wants to merge 1 commit intocloudflare:mainfrom
mksglu:feat/add-codemode-skill

Conversation

@mksglu
Copy link

@mksglu mksglu commented Feb 23, 2026

Summary

Adds a new codemode skill covering @cloudflare/codemode — the pattern where LLMs write and execute JavaScript to orchestrate multiple tool calls in a single turn, instead of calling tools one at a time.

Code Mode reduces token usage by 99%+ for multi-tool workflows by collapsing N individual tool calls into a single code-generation step executed in an isolated V8 sandbox via DynamicWorkerExecutor.

What's included

skills/codemode/
├── SKILL.md                          (298 lines)
└── references/
    ├── api-reference.md              (237 lines)
    ├── executor-patterns.md          (166 lines)
    └── mcp-integration.md            (113 lines)

SKILL.md covers:

  • When to use Code Mode vs standard tool calling (decision table)
  • How it works (execution pipeline overview)
  • Quick reference for all public APIs
  • Required wrangler.jsonc configuration
  • Core pattern: define tools → create executor → use with streamText
  • Full AIChatAgent integration example
  • MCP tool merging and tool name sanitization
  • Network isolation configuration
  • Two entry points (@cloudflare/codemode vs @cloudflare/codemode/ai)
  • Executor lifecycle
  • Anti-patterns (7 entries with correct alternatives)
  • Troubleshooting (7 common issues with solutions)

Reference files provide deep-dives into:

  • api-reference.md — Complete API surface: createCodeTool, DynamicWorkerExecutor, Executor interface, ExecuteResult, ToolDispatcher, generateTypes, sanitizeToolName, ToolDescriptor, normalizeCode
  • executor-patterns.md — Three executor implementations (DynamicWorkerExecutor for production, Node.js VM for local dev, HTTP bridge for remote execution) with selection guide
  • mcp-integration.md — Multi-server orchestration patterns, token comparison table, server-side Code Mode pattern (search + execute), best practices

Conventions followed

This skill follows all conventions established by existing skills in this repo:

  • YAML frontmatter with name, description, and trigger phrases
  • Retrieval-led development section with resource links
  • Table-driven content (quick reference, when to use, anti-patterns, troubleshooting)
  • Complete code examples with imports and type annotations
  • Wrangler configuration in JSONC format
  • References section linking to references/ subdirectory

Sources

Written based on:

Adds a new skill covering Code Mode — the pattern where LLMs write and
execute JavaScript to orchestrate multiple tool calls in a single turn
instead of calling tools one at a time.

Includes:
- SKILL.md with decision tree, configuration, core patterns, agent
  integration, MCP integration, anti-patterns, and troubleshooting
- references/api-reference.md — full API surface (createCodeTool,
  DynamicWorkerExecutor, generateTypes, sanitizeToolName)
- references/executor-patterns.md — DynamicWorkerExecutor, Node VM,
  and HTTP bridge executor implementations
- references/mcp-integration.md — MCP server orchestration patterns
  and token comparison
@threepointone
Copy link

tbh I don't think codemode's in a place where we want to recommend it as a skill just yet, it's still experimental.

@elithrar elithrar marked this pull request as draft February 24, 2026 12:29
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.

2 participants