CC

chenhunghan/code-mode-skill

Developer tools
21 stars Quality 42 Trend 31

Claude Code skill: add code mode to any MCP server for 65-99% context reduction

Overview

An agent skill that helps you add to any MCP server — so LLMs can write small processing scripts that run against large API responses in a sandboxed runtime, and only the script's compact output enters the context window. Works with any AI agent that supports agent skills. When an MCP tool returns a large API response (e.g. listing 500 Kubernetes pods, 200 SCIM users, or thousands of GitHub issues), that entire payload enters the LLM's context window — consuming tokens and degrading performance. Code mode flips the approach: instead of dumping raw data into context, the LLM writes a small processing script. The MCP server runs the script in a against the raw data, and only the script's stdout enters context. This works especially well with well-known APIs (SCIM, Kubernetes, GitHub, Stripe, Slack, AWS, etc.) because LLMs already know the response schemas from training data. Inspired by Cloudflare Code Mode and claude-context-mode. This is an .

README

Code Mode Skill

An agent skill that helps you add code mode to any MCP server — so LLMs can write small processing scripts that run against large API responses in a sandboxed runtime, and only the script’s compact output enters the context window. Works with any AI agent that supports agent skills.

Typical result: 65–99% context reduction.

What is Code Mode?

When an MCP tool returns a large API response (e.g. listing 500 Kubernetes pods, 200 SCIM users, or thousands of GitHub issues), that entire payload enters the LLM’s context window — consuming tokens and degrading performance.

Code mode flips the approach: instead of dumping raw data into context, the LLM writes a small processing script. The MCP server runs the script in a sandboxed runtime against the raw data, and only the script’s stdout enters context.

This works especially well with well-known APIs (SCIM, Kubernetes, GitHub, Stripe, Slack, AWS, etc.) because LLMs already know the response schemas from training data.

Inspired by Cloudflare Code Mode and claude-context-mode.

What This Skill Does

This is an interactive planning skill. It works with you step-by-step to:

  1. Understand your MCP server (language, framework, which tools return large data)
  2. Select a sandbox that fits your server language and security requirements
  3. Plan the implementation together
  4. Implement the code mode tool, sandbox executor, and wiring
  5. Benchmark before/after context sizes to verify the reduction

Supported Server Languages

Server Language Sandbox Options
TypeScript/JavaScript quickjs-emscripten (WASM), pyodide (WASM), isolated-vm (V8)
Python RestrictedPython, pyodide (WASM), quickjs bindings
Go goja, Wazero (WASM), starlark-go
Rust boa_engine, wasmtime/wasmer (WASM), deno_core

All sandbox options are isolated from the host filesystem and network by default.

Install

npx skills add chenhunghan/code-mode-skill

Or manually copy the SKILL.md and references/ directory into your agent’s skills directory.

Usage

Just ask your agent to add code mode to your MCP server:

  • “I want to add code mode to my MCP server to reduce token usage”
  • “Add a sandboxed code execution tool to my TypeScript MCP server”
  • “My get-users tool returns 50KB+ responses, help me reduce context size”

The skill will guide you through the process interactively.

License

MIT

View this README on GitHub

Recommended Tools

Try a different keyword or remove a filter.

Install

npx skillfish add chenhunghan/code-mode-skill