- Home
- Skills
- Agents & Orchestration
- Least-Privilege Claude Code Sub-Agents
More screenshots
Works with the AI Agents you already use
Least-Privilege Claude Code Sub-Agents
Build or harden sub-agents with limits set in front matter and hooks, then test that forbidden actions are blocked.
Free
Least-Privilege Claude Code Sub-Agents
Example session with this skill installed
Build a read-only security reviewer sub-agent for this repo and prove it cannot write files.
- Read your context and instructions
- Compiled the least-privilege claude code
I added a security-reviewer agent to your repo. It can read files and run a short list of read-only git commands, nothing more. Every write command I sent the installed guard in this agent's name came back blocked. The live Claude Code probes are still yours to run.
.claude/agents/security-reviewer.md (front matter; the body sets out its process and output table)
name: security-reviewer
description: Reviews uncommitted changes or named files in this repo for security bugs and returns findings ranked by severity, with a fix for each. Use when code that handles input, file paths, auth, secrets or shell calls has changed. Triggers on "security review", "check this diff for vulnerabilities", "review my changes for security".
tools: Read, Grep, Glob, Bash
model: sonnet
It needs git diff, so Bash is granted and held by a settings-level guard (.claude/hooks/agent_commands.json) to git status, git diff with --cached or --stat, and git log --oneline -N. No Write, Edit, web or MCP.
Checks I ran
- Linter before the guard:
1 FAIL, 1 WARN("read-only role has Bash with no PreToolUse guard"). After:0 FAIL, 0 WARN,--stricttoo. - The skill's 55 unit tests passed. Against the installed guard, 9 ran and passed, and 7 MCP tests were skipped because that guard is not installed here.
- 16 hook payloads piped into the installed guard. An excerpt:
| Command as security-reviewer | Exit |
|---|---|
git diff, git diff --cached, git status --short | 0 |
touch probe.txt, echo probe > probe.txt, git diff > probe.txt | 2 |
git diff --output=probe.txt, python3 -c "open(...).write(...)" | 2 |
git status; rm README.md, git add -A, git checkout -- app/files.py | 2 |
probe.txt does not exist afterwards. The main session and unlisted agents pass through, so your own shell is untouched.
Your Claude Code is 2.1.280, so I left out onFailure: block (it needs 2.1.295). Until you upgrade and add it, moving the guard script turns the shell limit off.
Next steps
- Run the live probes in
references/verification.mdsection B: list tools, then createscratch/probe.txt, then runpython3 --version. - Ask it to review your staged change.
app/routes.pypasses a query-string value intoread_upload, a path traversal it should catch. - Commit the agent,
settings.jsonand.claude/hooks/together.
Connects securely to your tools. The creator never sees your data.
About this skill
Most Claude Code sub-agents are one typo away from having every permission in the session. Leave out the tools line and the agent inherits every built-in and every connected MCP server, while a misspelled field is ignored without any error. A prompt that says "never edit files" enforces nothing.
This skill has your agent build sub-agents whose limits Claude Code itself enforces. It writes a least-privilege allow-list in front matter from eight permission shapes (air-gapped scanner, reviewer, researcher, single MCP server, connector, guarded shell, one forbidden action, inherit on purpose). It writes a description that routes correctly and finishes with a smoke test that tries the forbidden actions and checks the filesystem afterwards.
For limits front matter cannot express, it includes two PreToolUse guard scripts you add as hooks: one holds an agent's Bash to an exact list of commands, the other holds an MCP server to a fixed list of its tools, so any tool name not on the list is refused. There is also a linter that catches silent mistakes in existing agents, and a hand-off script for splitting a job into its own operator folder with a deny list for unattended runs. All four scripts are standard-library Python with 55 unit tests. The Bash guard was also tested live against a real sub-agent. The MCP guard has unit tests only, with no live MCP server test, so smoke-test it on yours.
Front-matter facts were checked against the Claude Code docs in November 2026, including the traps. A Bash rule in disallowedTools removes the whole shell, and a hook lets calls through when its script is missing unless you set onFailure: block.
Needs Claude Code and Python 3.9 or later. For teams running several sub-agents, or any agent that reads untrusted input.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Agents & Orchestration.
It cannot stop damage done through a tool the agent is allowed to use, such as sending data out in a WebFetch URL. The MCP guard has unit tests only, with no live MCP server test, so smoke-test it on yours. Front-matter hooks may not fire in headless (claude -p) runs, so prove them with a live probe.
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 13 days ago
- Free with an Agensi account
- Software
- Claude Code
Python 3.9+
Git