[PR #26] Add codemode skill for @cloudflare/codemode #27

Open
opened 2026-03-02 03:21:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/cloudflare/skills/pull/26
Author: @mksglu
Created: 2/23/2026
Status: 🔄 Open

Base: mainHead: feat/add-codemode-skill


📝 Commits (1)

  • bf94675 Add codemode skill for @cloudflare/codemode

📊 Changes

4 files changed (+814 additions, -0 deletions)

View changed files

skills/codemode/SKILL.md (+298 -0)
skills/codemode/references/api-reference.md (+237 -0)
skills/codemode/references/executor-patterns.md (+166 -0)
skills/codemode/references/mcp-integration.md (+113 -0)

📄 Description

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:


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/skills/pull/26 **Author:** [@mksglu](https://github.com/mksglu) **Created:** 2/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/add-codemode-skill` --- ### 📝 Commits (1) - [`bf94675`](https://github.com/cloudflare/skills/commit/bf94675aa95066658213488d266ef5cafd5056dc) Add codemode skill for @cloudflare/codemode ### 📊 Changes **4 files changed** (+814 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `skills/codemode/SKILL.md` (+298 -0) ➕ `skills/codemode/references/api-reference.md` (+237 -0) ➕ `skills/codemode/references/executor-patterns.md` (+166 -0) ➕ `skills/codemode/references/mcp-integration.md` (+113 -0) </details> ### 📄 Description ## Summary Adds a new **codemode** skill covering [`@cloudflare/codemode`](https://developers.cloudflare.com/agents/api-reference/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: - [`@cloudflare/codemode` source code](https://github.com/cloudflare/agents/tree/main/packages/codemode) (v0.1.0) - [Codemode API reference](https://developers.cloudflare.com/agents/api-reference/codemode/) - [Codemode example app](https://github.com/cloudflare/agents/tree/main/examples/codemode) - [Code Mode blog post](https://blog.cloudflare.com/code-mode-mcp/) - Existing `agents-sdk/references/codemode.md` reference in this repo --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/skills#27
No description provided.