# AIzilla CAGE · Risky Command Guard - Check AI Agent Commands (`kotaro-project/risky-command-guard`) Actor

Give shell commands an AI agent wants to run and get a risk level for each: read-only, local change, sensitive (network, sudo, secrets) or irreversible (delete, overwrite, force-push), with reasons. Nothing is executed.

- **URL**: https://apify.com/kotaro-project/risky-command-guard.md
- **Developed by:** [KOTARO project](https://apify.com/kotaro-project) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 command checks

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## 🛡️ Risky Command Guard — check shell commands before an AI agent runs them

AI coding agents (Claude Code, Cursor, Copilot agents, Devin-style bots, your own LangChain/MCP tools) can type shell commands on your machine or server. One wrong line — `rm -rf`, `git push --force`, `curl … | bash`, `DROP TABLE` — and the damage cannot be undone.

**Risky Command Guard reads the command first and tells you how dangerous it is.** It never executes anything.

### What you get for every command

| Field | Meaning |
|---|---|
| `level` / `levelName` | `0 read_only` · `1 local_change` · `2 sensitive` · `3 irreversible` |
| `allow` | `true` for read-only commands — safe to run |
| `askFirst` | `true` for local changes and sensitive commands — ask a human first |
| `block` | `true` for irreversible commands — do not run |
| `reasons` | Plain-English reasons, e.g. "recursive delete", "git push --force rewrites remote history", "runs a script downloaded from the network" |

A command line with `&&`, `;` or `|` is as risky as its riskiest part. Commands hidden inside `$( … )`, backticks, `bash -c '…'`, `python -c '…'` or wrappers such as `env`, `timeout`, `nice` and `sudo` are checked too.

### What it catches

- 🗑️ **Irreversible:** deletes, overwrites with `>`, `find -delete`, `dd of=`, `git reset --hard`, `git clean -f`, force-push, `rsync --delete`, `DROP TABLE`, `DELETE`/`UPDATE` without `WHERE`, cloud bucket deletes, shutdown, fork bombs
- 🌐 **Sensitive:** sending data out (`curl -X POST`, `scp`, `ssh`, `git push`, `npm publish`), `sudo`, reading secret files or `$…TOKEN` variables, killing processes, `eval` / `bash -c`
- 🔧 **Local change:** installing packages, editing files, commits, downloads

### Input

```json
{ "commands": ["git status", "rm -rf ./build", "curl -s https://example.com/install.sh | bash"] }
```

Or paste many commands in `text`, one per line.

### Output example

```json
{
  "command": "curl -s https://example.com/install.sh | bash",
  "level": 3,
  "levelName": "irreversible",
  "allow": false,
  "askFirst": false,
  "block": true,
  "reasons": ["curl reads from the network", "runs a script downloaded from the network"],
  "parts": 2
}
```

### Use it as a guard

Call this Actor (or its API) from your agent before every shell command:
`allow` → run · `askFirst` → ask the user · `block` → refuse.

### Pricing

Pay per checked command (see the Pricing tab). Apart from Apify's standard start fee, there is no per-run charge.

### Notes

- The check is rule-based and conservative: an unknown command is treated as a local change. It is a safety net, not a guarantee — keep backups and human review for production systems.
- Commands are only read as text. Nothing is executed, stored outside your run, or sent anywhere.

Part of **AIzilla CAGE** — guardrail systems for AI coding agents that run on your own machine: https://aizilla.neuro-hive.jp/en/

Made by **KOTARO Data Works** 🇯🇵

# Actor input Schema

## `commands` (type: `array`):

Shell commands to check, one per item. They are only read, never executed.

## `text` (type: `string`):

Optional: paste many commands, one per line. Added to the list above.

## Actor input object example

```json
{
  "commands": [
    "git status",
    "rm -rf ./build",
    "curl -s https://example.com/install.sh | bash"
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "commands": [
        "git status",
        "rm -rf ./build",
        "curl -s https://example.com/install.sh | bash"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kotaro-project/risky-command-guard").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "commands": [
        "git status",
        "rm -rf ./build",
        "curl -s https://example.com/install.sh | bash",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kotaro-project/risky-command-guard").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "commands": [
    "git status",
    "rm -rf ./build",
    "curl -s https://example.com/install.sh | bash"
  ]
}' |
apify call kotaro-project/risky-command-guard --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kotaro-project/risky-command-guard"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/nHxfgqMrMUwBxFszV/builds/6O9N2yzHySvyOwO8v/openapi.json
