agentleFS
mmccallammccalla/coding-agent-skill-library/skills/guardrails-safety-patterns/SKILL.md

guardrails-safety-patterns

Skill4 starsChanged 5 months agoApache-2.0View on GitHub

Use when implementing input validation, output filtering, tool restrictions, policy enforcement, secure coding controls, destructive-tool guardrails, approval gates, or safe agent behaviour.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when an agent can affect files, systems, users, data, external services, security posture, compliance, or public outputs.

    line 21
  2. Distinctive:

    Never weaken authentication or authorisation without explicit approval.

    line 49
  3. Distinctive:

    Never disable tests, linting or security checks to make a build pass.

    line 50
  4. Distinctive:

    Never run destructive shell commands without a clear reversible plan.

    line 51
  5. Very specific:

    Use skills_docs/security/OWASP_ASI_CROSSWALK.md for the shared risk map.

    line 66

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Guardrails and Safety Patterns

When to use

Use this skill when an agent can affect files, systems, users, data, external services, security posture, compliance, or public outputs. Apply it to both coding-agent behaviour and application code generated by the agent.

Objective

Apply layered deterministic controls that constrain unsafe inputs, tool use, outputs, and escalation paths.

Procedure

  1. Validate and classify incoming requests against scope, safety, and policy rules.
  2. Restrict tools and permissions to the minimum required for the task.
  3. Sandbox execution and constrain file, network, and data access.
  4. Validate outputs, schemas, and generated artefacts before release.
  5. Escalate to human review when risk exceeds the safe automation threshold.
  6. Record policy decisions, tool use, and outcomes for audit.

Layered guardrail model

  1. Input validation: reject malformed, malicious, irrelevant or out-of-scope requests.
  2. Policy classification: identify safety, security, privacy, legal and domain constraints.
  3. Tool restrictions: allow only the minimum tool permissions needed.
  4. Execution sandboxing: isolate code execution and file writes.
  5. Output validation: check generated content, code, schemas and artefacts before release.
  6. Human escalation: pause when risk exceeds the safe automation threshold.
  7. Audit logging: record decisions, tool use and policy outcomes.

Coding-agent controls

  • Never print secrets.
  • Never weaken authentication or authorisation without explicit approval.
  • Never disable tests, linting or security checks to make a build pass.
  • Never run destructive shell commands without a clear reversible plan.
  • Validate generated code for injection risks, unsafe deserialisation and overbroad permissions.

Implementation guidance

Represent policies as code where possible. Use schema validation, allowlists, sandbox boundaries, static analysis and dependency scanning before relying on LLM judgement.

Guardrails

  • Defence in depth is required; a prompt is not a security boundary.
  • Fast, low-cost models may be used as pre-screeners, but deterministic checks should enforce hard rules.
  • Escalate rather than improvise on safety-critical uncertainty.

OWASP ASI mapping

Use skills_docs/security/OWASP_ASI_CROSSWALK.md for the shared risk map.

ASI riskGuardrail control
ASI01 Agent Goal HijackValidate requested goals against authorised scope before planning or tool execution.
ASI03 Identity and Privilege AbuseEnforce task-scoped permissions and deny privileged actions without explicit approval.
ASI05 Unexpected Code ExecutionSandbox generated code and block unreviewed shell, SQL or infrastructure execution.
ASI10 Rogue AgentsAdd audit logging, behavioural anomaly checks and containment paths for agents that drift from scope.

Related skills

  • apply-laws-of-ai — safety-law hierarchy when material AI/instruction risk is present
  • human-in-the-loop — approval for high-risk actions
  • tool-use-and-function-calling — least-privilege tool execution

References

Verification

  • Input and output validation exist.
  • Tool permissions are least-privilege.
  • Sensitive data handling is explicit.
  • Unsafe actions require approval.
  • Audit trail is available.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.