Skip to content

Context-aware shell safety engine that blocks dangerous commands before execution

Notifications You must be signed in to change notification settings

khanak0509/safe-shell

Repository files navigation

Safe Shell

AI-powered safety layer for your terminal. Intercepts commands, analyzes risk, and blocks dangerous actions before they run.

🎥 Demo

Watch the demo

Note: Click the image or here to watch the demo video.

⚡ Setup

  1. Install Dependencies
    pip install -r requirements.txt
  2. Configure Environment Create a .env file with your Gemini API key:
    GOOGLE_API_KEY=your_api_key_here
  3. Activate Source the integration script (add to ~/.zshrc for persistence):
    source safe_shell.sh

🚀 Usage

Just use your terminal as normal. Safe Shell runs silently in the background.

  • Safe Commands: Run instantly.
    echo "Hello"  # ✅ Runs immediately
  • Risky Commands: Prompt for confirmation.
    npm install   # ⚠️  Ask: Execute? [y/N]
  • Dangerous Commands: Blocked by default.
    rm -rf /      # 🚫 BLOCK

🧠 Workflow

graph TD
    Start((Cmd)) --> Norm[Normalize]
    Norm --> Ctx[Collect Context]
    Ctx --> Rules[Rule Check]
    Rules --> Risk[Risk Adjustment]

    Risk -->|Low/None| Safe[Allow]
    Risk -->|Med/High| LLM[AI Analysis]

    Safe --> Exec((Execute))
    LLM --> Decision{Decision}

    Decision -->|Safe| Exec
    Decision -->|Warn| Confirm[Ask User]
    Decision -->|Block| Block[Stop]

    style Start fill:#fff,stroke:#333,stroke-width:2px
    style Exec fill:#fff,stroke:#333,stroke-width:2px
    style Block fill:#fff,stroke:#333,stroke-width:2px
Loading

About

Context-aware shell safety engine that blocks dangerous commands before execution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published