ai-agent-guardrails
БесплатноБез исполняемых скриптовНе проверенApply safety controls when an LLM agent has authority to act on real systems. Covers blast-radius classification, dry-run-first patterns, out-of-band approval…
от majiayu000★ 31 звезда на GitHubОб этом скилле
AI Agent Guardrails
LLMs make confident wrong decisions at scale. The cost of one wrong decision used to be one wrong commit; the cost of one wrong decision by an agent loop can be 30 wrong commits, 100 deleted DB rows, or a whole production site refactored into nonsense in 90 seconds.
This skill is a design checklist — not a runtime tool. It tells you what to put in place before giving an agent write access to anything that matters.
When to invoke
- Designing a new agent, scheduled job, or autonomous workflow
- Granting an existing LLM access to a higher-tier credential or new tool
- After an agent did something unintended (start here; do not just tighten one prompt)
- Reviewing a third-party agent (e.g. an MCP that takes broad actions) before connecting it
The core idea — blast radius
Classify every action an agent can take by what happens if it fires when it should not have.
| Tier | Example | Reversible? | Required guard |
|---|---|---|---|
| 1 | Read a local file, run a query | Trivially | None |
| 2 | Modify a single local file, write to a sandbox | Yes, with backup | Backup before action |
| 3 | Mutate a staging service or shared dev resource | Recoverable in minutes | Dry-run mode + explicit confirm |
| 4 | Production-data write, customer-visible change | Recoverable in hours, with effort | Approval gate + audit log + rollback plan |
| 5 | Send mail, spend money, modify DNS, deploy, push to main | Sometimes irreversible, externally visible | Out-of-band approval + rate limit + kill switch |
Every tool an agent can call belongs to exactly one tier. If you cannot say which, classify up.
Pattern: dry-run-first
For tier ≥ 3, every write tool should support an explicit dry-run that produces the exact diff/plan that would be applied. The agent runs dry-run first by default; only after the operator approves the plan does it run the real action.
Implementation sketch:
type WriteToolResult =
| { mode: "dryrun"; plan: ChangeSet; estimate: ImpactEstimate }
| { mode: "apply"; applied: ChangeSet; receipt: string };
async function update_widget(args: Args, opts: { dryrun: boolean }) {
const plan = computePlan(args);
if (opts.dryrun) return { mode: "dryrun", plan, estimate: estimateImpact(plan) };
const receipt = await applyPlan(plan);
return { mode: "apply", applied: plan, receipt };
}
The orchestration prompt makes dry-run the default; switching to apply requires a literal token (e.g. user clicks "Approve plan #abc123" out-of-band).
Pattern: approval gates (out-of-band)
For tier ≥ 4, approval must happen on a channel the agent does not control. The most common right-sized patterns:
- Telegram / Slack / Discord bot button — agent posts a one-line summary + plan diff, waits for human button click before executing. Tokens for approval are single-use and short-lived (≤ 15 min).
- Email click-link — for slower-tempo actions. Click-link must be HMAC-signed and single-use.
- Manual ticket assignment — agent files a ticket and stops; human moves it to "approved" and a separate worker picks it up.
Anti-pattern: asking the LLM "are you sure?" in the same conversation. The LLM will say yes.
Pattern: scope locking
Forbid wildcards and cross-resource actions at the tool layer, not the prompt layer.
- ❌
delete_posts(filter)→ agent might passfilter={} - ✅
delete_post(id)— one id per call, plus a per-conversation cap (e.g. ≤ 5 deletions before forcing a checkpoint)
Other variants:
- Path allowlists — file-system tools accept only paths under a configured root
- Domain allowlists — outbound HTTP tools allow only known hosts
- Time-bounded sessions — credentials valid only during the active session, refreshed externally
Pattern: idempotency
Every state-changing tool should accept (or compute) an idempotency key, and the backend should de-duplicate on it. This survives:
- Agent retries after a tool-result parsing failure
- Network blips that re-run the same call
- Double-clicks on the approval button
Without idempotency, a retry storm can multiply the blast radius without any of the guards firing.
Pattern: separate read and write agents
Run analysis in a read-only agent with read-only credentials. When an action is decided, hand off to a second, narrowly-scoped write agent with a fresh credential and a single, well-defined task. This:
- Prevents the analyzing agent from acting on injected content it read
- Makes the audit trail clean (decision → action is a hand-off, not a single opaque step)
- Lets you use a cheaper model for read and a stricter one for write
Pattern: kill switch and rate limit
Every agent must have:
- A kill switch the operator can hit without logging into the agent's environment (a feature flag, a DNS record the agent checks, a config file the agent reads on every tool call). It must default to off when unreachable.
- A per-minute and per-hour cap on write tool calls. The agent is paus
Установить ai-agent-guardrails в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл ai-agent-guardrails?
Apply safety controls when an LLM agent has authority to act on real systems. Covers blast-radius classification, dry-run-first patterns, out-of-band approval gates, scope locking, idempotency, kill switches, and rollback strategies. Invoke when designing an autonomous agent, when granting an LLM write access to production, or after an agent makes an unexpected change.
Как установить скилл ai-agent-guardrails?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ai-agent-guardrails запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic