Tool Defense

Modmod61Verified

A tower defense above the Claude Code prompt where every enemy is one of Claude's real tool calls: Bash sends runners, an Edit or Write a slow tank, a web or MCP call a flyer, an Agent a boss. Build and upgrade towers by clicking beside the road, hold the base through Claude's turn. Zero tokens. Needs an interactive terminal with a mouse.

Install CommandLocked
npx claude-code-templates@latest --skill β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’β€’
Unlock to reveal command
Byclaude-code-templates
claude-code β€” mods games tool defense
$

Interactive Terminal Locked

Unlock this skill to run and inspect the interactive installation sequence.

CookApps Fine Software Cuisine
CONTENT

tool-defense

A tower defense above the Claude Code prompt where every enemy is one of Claude's real tool calls: Bash sends runners, an Edit or Write a slow tank, a web or MCP call a flyer, an Agent a boss. Build and upgrade towers by clicking beside the road, hold the base through Claude's turn. Zero tokens: the mod answers every key and click itself and never asks the model anything.

Play

1
/defense opens the board above the prompt (/defense stop or the close button closes it).
2
Click the board to give it the mouse and keyboard; Esc gives them back to the prompt.
3
Click a free cell to build a tower (25 gold), click a tower to upgrade it (30, then 50): more range, more damage, faster fire. Space or p pauses, r restarts.
4
Enemies walk the road from the left to your base on the right; ten get through and the base falls. Each kill pays gold and points.

Every tool call Claude makes releases one enemy the moment the call starts, shaped by the tool:

toolenemy
Bash, PowerShellβ–Άβ–Ά runner: fast, fragile
Edit, Write, NotebookEditβ–ˆβ–ˆ tank: slow, tough
WebFetch, WebSearch, any MCP toolβ—’β—£ flyer: crosses the bottom row over the towers' heads
Agent, Workflowβ–“β–“ boss
anything else (Read, Grep, Glob, ...)β–ͺβ–ͺ scout

Between Claude's calls a quiet trickle of scouts keeps the game alive, so it is playable on its own too. A long turn with many tool calls is the real wave: build before you press Enter.

Your best score is kept in the plugin's store across sessions.

Install

shcode
npx claude-code-templates@latest --mod games/tool-defense
claude

It is written to .claude/skills/tool-defense/, which Claude Code auto-loads as tool-defense@skills-dir. For one session with hot reload: claude --plugin-dir .claude/skills/tool-defense. claude plugin validate .claude/skills/tool-defense prints every event it hooks and every $ call it makes.

How it is built

hooks/register.tsx is the hooks module: it registers /defense, mounts the board on the AbovePrompt band and keeps the score in $.store. hooks/games/*.ts is the game's logic, pure functions with no drawing, and hooks/boards/*.tsx is the surface module that draws it in two-character cells on the drawing thread and takes the keys and the mouse. Written for aitmpl.com against Anthropic's published function-hooks declarations.

Requirements

  • Claude Code 2.1.287 or later (mods are on by default from that version).
  • An interactive terminal that reports the mouse. Nothing draws in claude -p, the desktop app or mobile.
  • A terminal font with box-drawing and block characters.
  • A clone of the genre, not affiliated with or endorsed by the original publisher.

    How to Use & Getting Started

    Protected

    # Step 1: Initialize skill agent setup

    npx skills add Tool Defense --install-production

    python -m pip install -r requirements.txt

    codex plugin install Tool Defense@latest

    export API_KEY=secret_token_key_here

    Installation Runbook & Walkthrough Locked

    Unlock this skill to reveal complete step-by-step setup guides, terminal commands, configuration recipes, repository links, and interactive installation video walkthroughs.

    Unlock full access to Tool Defense

    Get instant access to complete setup guides, repository source code, and integration assets.

    mod3.0k

    Prompt Cache Control

    Prompt-cache meter above the Claude Code prompt: how many tokens each request read from, wrote to and sent past the cache, a live countdown to the cache's expiry, and what to do about it (keep going, compact or clear). The TTL follows Claude Code's own rules for your account (1 hour on a Claude subscription, 5 minutes on an API key, cloud provider or usage credits, plus the TTL variables and setting) and corrects itself from request timing. When Claude Code will compact an idle conversation by itself, it counts down to that too. cache opens a per-turn table.

    mod1.8k

    Jev Model Router

    Picks the model and the reasoning effort for each task with TypeSafe's Jev, a System One decision model reached either through TypeSafe's own API or the Vercel AI Gateway. Routes subagent models at agent.spawn and the main loop's effort and model at turn.step, in both directions, falling back to the engine's built-in classifier when no key is set.

    mod1.7k

    Jev Skill Suggestion

    Keeps the skill listing out of the context window and lets TypeSafe's Jev, a System One decision model, pick at most one skill per prompt from the skills' descriptions, the way TypeSafe's skill-suggestion cookbook does: one request ranks every skill and asks whether the prompt needs a skill at all, a second re-reads the top three with their SKILL.md and can reject them all. The winner's SKILL.md is attached to the prompt, so the skills can be hidden from the model altogether ( jev-skill-suggestion:setup makes them user-invocable-only and context counts them at 0). Falls back to the engine's built-in classifier when no key is set.