gemini-code-exec

A way to run Python code in Gemini’s isolated environment without using the local computer or its files.

In plain words
What is it for?
Use it to verify mathematics, test regular expressions, simulate algorithms, validate data transformations, and probe edge cases such as empty or boundary values.
Why use it?
It lets you check calculations and code behavior without creating side effects in the project or relying on local execution.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/azmym/gemini-plugin/gemini-code-exec
Any agent
npx skills add azmym/gemini-plugin --skill gemini-code-exec
Clone the repo
git clone --depth 1 https://github.com/azmym/gemini-plugin

Made for: Claude Code, Codex.

Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 991 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00038 $0.00991
Opus 5 $0.00019 $0.00495
Sonnet 5 $0.00008 $0.00198
Haiku 4.5 $0.00004 $0.00099

Measured yesterday against content hash 621b5a0a7151, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gemini-code-exec scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/gemini-code-exec/SKILL.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Gemini Code Exec

Use this skill to run Python code inside Gemini's isolated sandbox. This gives you a clean, side-effect-free execution environment for verifying computations, testing patterns, and validating logic without touching the local machine.

When to use this skill

  • Math verification: Confirm a formula, check a statistical calculation, or validate a numeric result.
  • Regex testing: Test a regular expression against a set of sample inputs before embedding it in production code.
  • Algorithm simulation: Run a sorting algorithm, dynamic programming solution, or graph traversal with sample data to verify correctness.
  • Data transformation validation: Confirm that a proposed data mapping, normalization, or encoding produces the expected output.
  • Edge case probing: Run code against boundary values (zero, max int, empty string, None) to see what happens.
  • Dependency-free snippets: Execute a pure-Python snippet that has no local filesystem or network dependencies.

MCP tools

Tool Purpose
gemini_code_execute Submit Python code for execution in Gemini's sandbox and receive stdout, stderr, and the return value

Usage pattern

Verify a math formula

{
  "tool": "gemini_code_execute",
  "arguments": {
    "code": "import math\n\ndef compound_interest(principal, rate, periods):\n    return principal * (1 + rate) ** periods\n\nresult = compound_interest(1000, 0.05, 10)\nprint(f'After 10 years: {result:.2f}')"
  }
}

Test a regex pattern

{
  "tool": "gemini_code_execute",
  "arguments": {
    "code": "import re\n\npattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'\ntest_cases = ['[email protected]', 'bad-email', '[email protected]', '[email protected]']\nfor case in test_cases:\n    match = bool(re.match(pattern, case))\n    print(f'{case!r}: {match}')"
  }
}

Validate an algorithm

{
  "tool": "gemini_code_execute",
  "arguments": {
    "code": "def longest_common_subsequence(s1, s2):\n    m, n = len(s1), len(s2)\n    dp = [[0] * (n + 1) for _ in range(m + 1)]\n    for i in range(1, m + 1):\n        for j in range(1, n + 1):\n            if s1[i-1] == s2[j-1]:\n                dp[i][j] = dp[i-1][j-1] + 1\n            else:\n                dp[i][j] = max(dp[i-1][j], dp[i][j-1])\n    return dp[m][n]\n\nprint(longest_common_subsequence('ABCBDAB', 'BDCAB'))  # Expected: 4"
  }
}

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 81 lines · 38 tokens per session scan A 621b5a0a7151

Subscribe to this mod's changes

gemini-code-exec is a skill published in the GitHub repository azmym/gemini-plugin (1 stars, last pushed 18d ago), licensed MIT. It adds 38 tokens to every session and 991 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.