agent-kill-switch
Skill424 starsChanged 58 days agoMITView on GitHub
Give the human an off switch and a cost meter for the coding agents on this machine, using ClawMetry. Use when the user asks to stop or kill a runaway agent, see what an agent is doing or spending, cap agent spend, gate risky tool calls behind approval, or "set up a kill switch" for Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, Goose, Aider and similar runtimes.
- Installs packages
- Sends data out
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
If the port is taken: clawmetry --port 8901 and use that port below.
- Distinctive: line 62
Never call this on your own initiative.
- Very specific: line 96
When the cap is hit the proxy returns BUDGET_EXCEEDED instead of forwarding the request.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent kill switch
An agent that loops, re-reads the same files, or shells out to something it should not is expensive by the minute. This skill wires up ClawMetry, a local, read-only dashboard that reads the session logs the runtimes already write on disk, and uses it for three things: see what is running, stop one session, and hold risky tool calls until a human says yes.
Nothing here modifies the agent. Observation is read-only. Every control below is opt-in and stated as what it does, so tell the user exactly which ones you enabled.
1. Install and start
pip install clawmetry && clawmetryThe dashboard is at http://localhost:8900. It auto-detects the runtimes on
the machine (Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, Goose, Aider,
Cline, OpenCode and others); no config. Confirm it is up:
curl -s http://localhost:8900/api/overview | head -c 400If the port is taken: clawmetry --port 8901 and use that port below.
2. See what is running and what it costs
curl -s http://localhost:8900/api/sessions # live and recent sessions, ids look like claude_code:<uuid>
curl -s http://localhost:8900/api/usage # tokens and cache-aware cost per model and per sessionTell the user in plain words: which sessions are active, which one is spending the most, and whether any is showing loop signs. The dashboard's Sessions tab shows the full transcript and every tool call for a session.
3. Stop one session (the off switch)
curl -s -X POST http://localhost:8900/api/sessions/<session_id>/stop200with"ok": trueand apid: the session's process received SIGTERM.409with"ok": false: ClawMetry could not identify a process for that session, for example a Cursor editor conversation, which shares the IDE process. Say so instead of claiming it was stopped.
Never call this on your own initiative. Only when the user asks to stop a session, and confirm which session id first.
4. Hold risky tool calls until a human approves (Claude Code)
clawmetry hooks install # adds a PreToolUse hook to ~/.claude/settings.json, idempotent
clawmetry hooks statusThen one policy gates everything ClawMetry scores high or critical
(recursive deletes, force pushes, sudo, credential files, reverse shells,
cloud metadata endpoints):
# ~/.clawmetry/policies.yml
- name: 'Require approval for high-risk actions'
min_risk: 'high'
action: 'require_approval'
timeout: 604800
on_timeout: 'deny'A deny blocks that one call; the agent keeps its session. Approvals can be
answered from the Approvals tab or, with cloud sync, from a phone push.
Undo with clawmetry hooks uninstall (removes only ClawMetry's entries).
5. Cap spend for agents that call the API with a key
clawmetry proxy start --daily-budget 10
export ANTHROPIC_BASE_URL=http://localhost:4100/v1 # or OPENAI_BASE_URL for OpenAI-backed agentsWhen the cap is hit the proxy returns BUDGET_EXCEEDED instead of forwarding
the request. It also detects repeated near-identical requests (loops). This
only covers agents whose traffic you route through it; say that.
Honest limits
- OpenClaw and NemoClaw are free in the open-source app. The other runtimes, and the approvals feature, need ClawMetry Cloud or a self-hosted Pro license after the trial. Tell the user before enabling those.
- The stop in step 3 is SIGTERM to a process ClawMetry can identify. It is
not a guarantee for every runtime; the
409is the honest answer. - Data stays on the machine unless the user runs
clawmetry connect, which enables end-to-end encrypted cloud sync.
Remove
clawmetry hooks uninstall
clawmetry proxy stop
pip uninstall clawmetryDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

