cd /news/ai-tools/pi-prompt-before-dangerous-commands · home topics ai-tools article
[ARTICLE · art-98683] src=perrotta.dev ↗ pub= topic=ai-tools verified=true sentiment=· neutral

pi: prompt before dangerous commands

Pi, an extension for the earendil-works coding agent, now prompts users for confirmation before executing dangerous shell commands such as `rm -rf`, `terraform destroy`, and destructive Git operations, instead of blocking them outright. The update, made by developer Thiago Perrotta in the dangerous-command-guard/guard.ts file, uses the tool_call event and ctx.ui.confirm to ask for approval in interactive sessions, while print and JSON modes still fail closed. All 48 tests pass.

read1 min views1 publishedAug 16, 2026

Previously.

Problem statement: my Pi extension blocked dangerous shell commands outright, even when I had already preserved the state they could destroy.

The guard parses every bash

tool call with tree-sitter, catching commands such as rm -rf

, terraform destroy

, and destructive Git operations. Today it did exactly what I had asked:

% git -C "$(brew --repo thiagowfx/pancake)" reset --hard origin/master
git reset --hard is blocked - discards changes irreversibly

Blocking remains the right default, but an interactive session can ask me. Pi extensions can intercept the tool_call event and open a confirmation dialog through

ctx.ui

.The change in dangerous-command-guard/guard.ts:

-  pi.on("tool_call", async (event) => {
+  pi.on("tool_call", async (event, ctx) => {
     if (event.toolName !== "bash") return;

     const command = event.input.command;
     if (typeof command !== "string") return;

     const blocked = await findBlockedCommand(command);
-    if (blocked) return { block: true, reason: blocked.reason };
+    if (!blocked) return;
+    if (!ctx.hasUI) return { block: true, reason: blocked.reason };
+
+    const allowed = await ctx.ui.confirm(
+      "Allow dangerous command?",
+      `${blocked.command}\n\n${blocked.reason}`,
+    );
+    if (!allowed) return { block: true, reason: "Blocked by user" };
   });

Interactive Pi now s for approval. Print and JSON modes have no UI, so they still fail closed. Safe commands never prompt.

The tests exercise all three decisions:

✔ extension prompts before dangerous bash tool calls (0.66225ms)
ℹ tests 48
ℹ pass 48
ℹ fail 0

Same guardrails, with an escape hatch operated by a human rather than a model.

🤖 *Drafted with *

/bloggify

.— § —

Reply via [email](mailto:serendipity@perrotta.dev?subject=Reply to: pi: prompt before dangerous commands)

── more in #ai-tools 4 stories · sorted by recency
── more on @pi 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/pi-prompt-before-dan…] indexed:0 read:1min 2026-08-16 ·