Protect Folders

    1

    Protect specific folders from being modified or deleted by Claude Code agents using shell hooks and native permissions.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Protect Folders

    Example session with this skill installed

    I want to protect the 'raw_data' and 'infrastructure_configs' folders from any changes. Put them in read-only mode for the agent.

    • Read your context and instructions
    • Compiled the protect folders

    I have configured the protection layers for raw_data and infrastructure_configs. I deployed the guard script, updated the project settings, and verified the hook with test tool calls.

    Folder Protection Configuration

    ComponentStatusDetails
    Protected PathsActiveraw_data, infrastructure_configs
    Native PermissionsAppliedEdit and Write denied for both directories
    Shell GuardInstalled.claude/hooks/guard.py
    Hook ValidationPassedRead (ls) allowed; Write (rm) blocked
    Audit LogActive~/.claude-guardrails/guards/refusals.jsonl
    // .claude/settings.json updates
    {
      "env": {
        "GUARDRAILS_PROTECTED_PATHS": "raw_data,infrastructure_configs"
      },
      "permissions": {
        "deny": [
          "Edit(/raw_data/**)",
          "Write(/raw_data/**)",
          "Edit(/infrastructure_configs/**)",
          "Write(/infrastructure_configs/**)"
        ]
      },
      "hooks": {
        "PreToolUse": {
          "matcher": "Bash|PowerShell",
          "command": "python3 -I \"$CLAUDE_PROJECT_DIR/.claude/hooks/guard.py\""
        }
      }
    }
    

    Next steps

    1. Restart your Claude Code session to load the new hook and permission settings.
    2. If a legitimate command is blocked, you can run it manually in your standard terminal.
    3. Review ~/.claude-guardrails/guards/refusals.jsonl to see a history of any blocked actions.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Manually managing agent permissions is error-prone and often ignored until a destructive command is executed. This skill implements a multi-layer defense to protect sensitive directories from accidental modification or deletion by Claude Code agents.

    What it does

    • Multi-layer protection combines Claude's native tool permissions with a Python-based shell command inspector.
    • Read-only enforcement allows agents to use ls, cat, and grep while blocking destructive operations like rm, mv, or redirection.
    • Fail-closed logic ensures that any error in the guard script or ambiguity in the command results in an immediate refusal.
    • Local auditing logs all blocked attempts to a local JSONL file for security review.

    How it works

    1. Target selection begins by asking the user to specify relative paths for protection, such as data/ or config/.
    2. Hook deployment installs a specialized Python script into the project's .claude/hooks/ directory.
    3. Configuration merge updates .claude/settings.json with path-specific Edit and Write deny rules and the PreToolUse hook.
    4. Validation check runs automated test cases against the installed guard to verify it blocks writes and permits reads before completion.

    Frameworks & tools

    Uses the Python standard library (compatible with python3) and integrates directly with Claude Code's native JSON configuration and hook system.

    Why this beats prompting it yourself

    Prompting an agent not to touch a folder is easily bypassed by complex shell chains or context loss. This skill installs an execution-level barrier that inspects the raw command text before it reaches the shell, providing a tangible safety net that persists across sessions.

    Use cases

    • Protecting datasets from accidental deletion during data analysis tasks.
    • Securing configuration files or environment templates from unauthorized agent modification.
    • Locking reference docs to ensure an agent only reads documentation without attempting to "fix" it.

    Known limitations

    Does not prevent the execution of pre-written scripts on disk or obfuscated paths built dynamically. Requires a local Python interpreter. Not a substitute for a full OS-level sandbox.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.

    Requires Python 3. Does not block scripts written to disk then executed or commands where paths are built dynamically inside a language REPL. Refusals apply only to Claude Code tool use.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 11 days ago

    • Free with an Agensi account

    Software
    PythonGit

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables
    Listed11 days ago

    What's inside

    Frequently Asked Questions

    It installs a Python-based shell hook and updates your Claude Code configuration to block destructive commands (like rm or mv) at the execution level while still allowing read-only access for analysis.

    This skill is specifically designed for the Claude Code CLI and integrates directly with its native hook system and JSON settings.

    No, the skill relies on a fail-closed Python script that inspects commands before they reach the shell, ensuring protection remains active even if the agent forgets its initial instructions.

    The purchase includes the setup automation, the specialized Python guard script, and a validation suite to ensure your folders are correctly locked down after installation.

    Yes, during the setup process, you can specify multiple relative paths (such as `src/config/` or `data/`) to be placed under read-only protection.

    While highly effective against standard shell commands, it does not prevent the execution of pre-existing scripts on your disk or OS-level bypasses; it is meant as a guardrail, not a full sandbox.

    New in LLM Ops

    Free