command-guard

Block dangerous shell commands before execution via a PreToolUse hook.

75|18|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/JKHeadley/instar --skill command-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: command-guard
Source: https://github.com/JKHeadley/instar/tree/main/skills/command-guard
Command: npx skills add https://github.com/JKHeadley/instar --skill command-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill protects Claude Code projects from accidental data loss, broken Git history, and credential leaks by blocking dangerous shell commands before they execute.

Core Features & Use Cases

  • Pre-execution command filtering: Intercepts Bash tool calls and stops risky operations like destructive file deletion, force pushes, hard resets, and database drops.
  • Security-focused guardrails: Helps teams enforce safer agent behavior when working with repositories, local environments, and production-like data.
  • Customizable policies: Lets you extend the blocklist for project-specific rules such as protected branches, sensitive config files, or deployment restrictions.
  • Use case: A developer asks Claude Code to clean a directory or update Git history, and the hook blocks the command until the action is explicitly reviewed.

Quick Start

Ask Claude Code to install the command-guard hook in your project so dangerous Bash commands are blocked before they can run.

Frequently Asked Questions about command-guard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I block destructive bash commands before they execute in Claude Code?

To block dangerous bash commands in Claude Code, install a PreToolUse hook in the .claude/settings.json file. This hook intercepts Bash tool calls, validates them against a blocklist, and stops risky operations like destructive deletions, force pushes, and database drops before execution.

What shell commands does Claude Code need protection against?

Claude Code projects need protection against destructive file deletions, Git force pushes, hard resets, database drops, and credential leaks. A command filtering hook intercepts these risky shell operations before they execute, returning blocking reasons to prevent accidental data loss or broken repository history.

Can I customize the blocklist for project-specific Git branches and config files?

Yes, you can customize the blocklist to include project-specific rules like protected Git branches, sensitive config files, or deployment restrictions. The command-guard hook allows you to extend its filtering policies to enforce safer agent behavior when working with repositories and local environments.

How does a PreToolUse hook validate bash commands in Claude Code?

A PreToolUse hook validates bash commands by using a Python filter that intercepts shell tool calls, checks them against a blocklist, and returns blocking reasons if dangerous operations are detected. When input cannot be parsed, the hook fails open to allow execution while avoiding false blocks.

Does the command-guard hook work with Claude Code projects using Bash tools?

Yes, the command-guard hook is designed specifically for Claude Code projects that use Bash tools and need protection against destructive deletions, force pushes, and database drops. It integrates directly via the .claude/settings.json file to intercept shell commands before execution.

What happens when the bash command filter cannot parse the input?

When the bash command filter cannot parse the input, it fails open and allows the command to execute. This design prevents the safety hook from accidentally blocking legitimate operations due to parsing errors, ensuring development workflows are not disrupted by false positives.