Code Mode Skill logo

Code Mode Skill

Community
zeenie-ai
code-mode-skill

Generate Python code instead of sequential tool calls (81-98% token savings)

Overview

Publisherzeenie-ai
RepositoryOpenCompany
Skill namecode-mode-skill
Stars
912
Forks
137
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by zeenie-ai on GitHub. Read the source before you install it.

Installation

Install the Code Mode Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zeenie-ai/OpenCompany.git /tmp/OpenCompany
mkdir -p .claude/skills
cp -r /tmp/OpenCompany/server/skills/autonomous/code-mode-skill .claude/skills/code-mode-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Code Mode Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Code Mode Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Code Mode Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Code Mode Pattern

You are a Code Mode agent. Instead of calling tools sequentially, generate Python code that accomplishes the entire task in a single execution.

Why Code Mode?

Research from Cloudflare and Anthropic shows Code Mode provides:

  • 81-98% token savings vs sequential tool call sequences
  • Explicit control flow - loops, conditionals, error handling in code
  • Reusable patterns - functions and variables persist across iterations
  • Better debugging - executable code is easier to trace and verify

Available Libraries

When generating Python code, you have access to:

python
import math          # Mathematical functions (factorial, sqrt, sin, cos, etc.)
import json          # JSON parsing and serialization
import datetime      # Date and time operations
from datetime import timedelta
import re            # Regular expressions for text processing
import random        # Random number generation
from collections import Counter, defaultdict  # Data structures

Core Pattern

  1. Analyze - Understand the complete task requirements
  2. Generate - Write complete Python code that solves the entire task
  3. Execute - Use the python_code tool to run the code
  4. Return - The code output becomes your response

Simple Example

Task: "Calculate factorial of 10 and check if it's divisible by 7"

Wrong approach (multiple tool calls - wasteful):

1. Call calculator: factorial(10)
2. Get result: 3628800
3. Call calculator: 3628800 % 7
4. Get result: 0
5. Return answer
(4 LLM round-trips, ~4000 tokens)

Code Mode approach (single execution):

python
import math
import json

# Calculate factorial
result = math.factorial(10)

# Check divisibility
divisible = result % 7 == 0

# Output structured result
output = {
    "factorial_of_10": result,
    "divisible_by_7": divisible,
    "remainder": result % 7
}
print(json.dumps(output, indent=2))

(2 LLM round-trips, ~800 tokens - 80% savings)

Complex Example with Loop

Task: "Find all prime numbers between 1 and 100, show which are twin primes"

python
import json

def is_prime(n):
    """Check if a number is prime."""
    if n < 2:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

# Find all primes
primes = [n for n in range(1, 101) if is_prime(n)]

# Find twin primes (primes that differ by 2)
twin_primes = []
for i in range(len(primes) - 1):
    if primes[i + 1] - primes[i] == 2:
        twin_primes.append((primes[i], primes[i + 1]))

output = {
    "primes": primes,
    "count": len(primes),
    "sum": sum(primes),
    "twin_primes": twin_primes,
    "twin_count": len(twin_primes)
}
print(json.dumps(output, indent=2))

Data Processing Example

Task: "Analyze this list of numbers: find mean, median, mode, and standard deviation"

python
import json
from collections import Counter
import math

# Input data (would come from user or previous step)
numbers = [23, 45, 67, 23, 89, 45, 23, 67, 90, 12, 45, 78]

# Calculate statistics
n = len(numbers)
mean = sum(numbers) / n

# Median
sorted_nums = sorted(numbers)
if n % 2 == 0:
    median = (sorted_nums[n//2 - 1] + sorted_nums[n//2]) / 2
else:
    median = sorted_nums[n//2]

# Mode
counter = Counter(numbers)
mode = counter.most_common(1)[0][0]

# Standard deviation
variance = sum((x - mean) ** 2 for x in numbers) / n
std_dev = math.sqrt(variance)

output = {
    "data": numbers,
    "count": n,
    "mean": round(mean, 2),
    "median": median,
    "mode": mode,
    "std_deviation": round(std_dev, 2),
    "min": min(numbers),
    "max": max(numbers)
}
print(json.dumps(output, indent=2))

Error Handling in Code

Always include error handling for robustness:

python
import json

def safe_divide(a, b):
    """Safely divide two numbers."""
    try:
        return {"result": a / b, "success": True}
    except ZeroDivisionError:
        return {"error": "Division by zero", "success": False}
    except Exception as e:
        return {"error": str(e), "success": False}

# Example usage
results = []
test_cases = [(10, 2), (15, 3), (7, 0), (100, 4)]

for a, b in test_cases:
    result = safe_divide(a, b)
    result["operation"] = f"{a} / {b}"
    results.append(result)

print(json.dumps({"calculations": results}, indent=2))

When NOT to Use Code Mode

Use specific tools instead for:

  • External API calls - Use http_request tool for network requests
  • Database operations - Use data-specific tools
  • File operations - Use file-specific tools
  • User interaction - Respond directly without code
  • Real-time data - Use web_search or specific data tools
  • Device control - Use Android/device-specific tools

Integration with Multiple Tools

When you need both code AND external tools, use this pattern:

  1. Gather data using appropriate tools (http_request, web_search, etc.)
  2. Process the gathered data using Code Mode
  3. Return the combined result

Example flow:

User: "Search for Python release dates and calculate days since each release"

1. Use web_search tool: "Python version release dates"
2. Use python_code to process:
   - Parse the dates from search results
   - Calculate days since each release
   - Format output nicely

Output Format

Always output results as JSON for downstream processing:

python
import json
# ... your calculations ...
print(json.dumps(output, indent=2))

This enables:

  • Easy parsing by downstream nodes
  • Structured data for further processing
  • Clear, readable output for users

Frequently asked questions

What does the Code Mode Skill AI skill do?

Generate Python code instead of sequential tool calls (81-98% token savings)

Why use Code Mode Skill on TypingMind?

Because you install it once and use it with any model. Code Mode Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Code Mode Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zeenie-ai/OpenCompany/tree/main/server/skills/autonomous/code-mode-skill. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Code Mode Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Code Mode Skill?

As many as you like. As long as a model supports skills, you can use Code Mode Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Code Mode Skill AI skill free?

Yes. It is published on GitHub by zeenie-ai under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇