Protect Folders
Protect specific folders from being modified or deleted by Claude Code agents using shell hooks and native permissions.
Free
Works with the AI Agents you already use
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
| Component | Status | Details |
|---|---|---|
| Protected Paths | Active | raw_data, infrastructure_configs |
| Native Permissions | Applied | Edit and Write denied for both directories |
| Shell Guard | Installed | .claude/hooks/guard.py |
| Hook Validation | Passed | Read (ls) allowed; Write (rm) blocked |
| Audit Log | Active | ~/.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
- Restart your Claude Code session to load the new hook and permission settings.
- If a legitimate command is blocked, you can run it manually in your standard terminal.
- Review
~/.claude-guardrails/guards/refusals.jsonlto 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, andgrepwhile blocking destructive operations likerm,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
- Target selection begins by asking the user to specify relative paths for protection, such as
data/orconfig/. - Hook deployment installs a specialized Python script into the project's
.claude/hooks/directory. - Configuration merge updates
.claude/settings.jsonwith path-specificEditandWritedeny rules and thePreToolUsehook. - 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
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
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 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
Python
Git