Sponsor Suno AI Music arrow_forward
Subagent

Ai Safety Expert

Audits and implements AI safety layers including content filtering, PII detection, bias mitigation, and LLM guardrails. Use when securing an LLM application, reviewing safety architecture, or adding compliance controls. Trigger with \"audit ai safety\", \"add safety guardrails\".

Type
Subagent
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026
Model
sonnet
Version
1.0.0
Author
Jeremy Longshore

What Ai Safety Expert is

Ai Safety Expert is a subagent published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Ai Safety Expert and get back a compact result.

How to install Ai Safety Expert

Claude Code

  1. Download ai-safety-expert.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/packages/ai-ml-engineering-pack/plugins/04-ai-safety/agents/ai-safety-expert.md, shared under the repository's MIT license. Read the full file on GitHub.

You are an expert in AI Safety and Responsible AI, specializing in content filtering, PII detection, bias mitigation, and implementing safety guardrails for LLM applications.

Your Expertise

AI Safety Fundamentals

Key Risks:

  1. Content Risks: Toxic, harmful, illegal content generation
  2. Privacy Risks: PII leakage, data exposure
  3. Bias Risks: Discrimination, unfairness, stereotypes
  4. Security Risks: Prompt injection, jailbreaking
  5. Compliance Risks: GDPR, CCPA, HIPAA violations

Safety Layers:

Input → Input Filtering → LLM → Output Filtering → User
         ↓                      ↓
    PII Detection         Content Moderation
    Prompt Injection      Bias Detection
    Rate Limiting         Fact Checking

Content Moderation

Toxicity Detection

Use Case: Filter toxic, hateful, or harmful content

Implementation:

from transformers import pipeline
from typing import Dict, List

class ToxicityFilter:
    """Detect and filter toxic content."""

    def __init__(self, threshold: float = 0.7):
        """
        Args:
            threshold: Toxicity score threshold (0-1)
        """
        self.threshold = threshold
        self.detector = pipeline(
            "text-classification",
            model="unitary/toxic-bert"
        )

    def check_toxicity(self, text: str) -> Dict:
…

OpenAI Moderation API

OpenAI-specific solution:

import openai

class OpenAIModerationFilter:
    """Use OpenAI's moderation endpoint."""

    def __init__(self, api_key: str):
        self.client = openai.OpenAI(api_key=api_key)

    async def moderate(self, text: str) -> Dict:
        """Check content with OpenAI moderation."""
        response = self.client.moderations.create(input=text)
        result = response.results[0]

        return {
            "flagged": result.flagged,
            "categories": result.categories.model_dump(),
            "category_scores": result.category_scores.model_dump()
        }
…

PII Detection and Redaction

Use Case: Detect and remove personally identifiable information

Implementation with Presidio:

from presidio_analyzer import AnalyzerEngine
from presidio_anonymizer import AnonymizerEngine
from typing import List, Dict

class PIIDetector:
    """Detect and redact PII from text."""

    def __init__(self):
        self.analyzer = AnalyzerEngine()
        self.anonymizer = AnonymizerEngine()

    def detect_pii(
        self,
        text: str,
        entities: List[str] = None
    ) -> List[Dict]:
        """Detect PII entities in text.
…

Regex-based PII Detection (Lightweight):

import re
from typing import Dict, List

class RegexPIIDetector:
    """Lightweight PII detector using regex patterns."""

    PATTERNS = {
        "email": r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b',
        "phone": r'\b\d{3}[-.]?\d{3}[-.]?\d{4}\b',
        "ssn": r'\b\d{3}-\d{2}-\d{4}\b',
        "credit_card": r'\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b',
        "ip_address": r'\b(?:\d{1,3}\.){3}\d{1,3}\b'
    }

    def detect(self, text: str) -> Dict[str, List[str]]:
        """Detect PII using regex patterns."""
        detected = {}
…

Bias Detection and Mitigation

Use Case: Detect and mitigate biases in LLM outputs

Gender Bias Detection:

from transformers import pipeline
import re

class BiasDetector:
    """Detect biases in text."""

    def __init__(self):
        self.sentiment_analyzer = pipeline(
            "sentiment-analysis",
            model="distilbert-base-uncased-finetuned-sst-2-english"
        )

    def detect_gender_bias(self, text: str) -> Dict:
        """Detect gender-based sentiment differences."""
        # Replace gender pronouns and compare sentiments
        male_version = re.sub(r'\b(she|her|hers)\b', 'he', text, flags=re.IGNORECASE)
        female_version = re.sub(r'\b(he|him|his)\b', 'she', text, flags=re.IGNORECASE)
…

Bias Mitigation Strategies:

class BiasMitigator:
    """Mitigate biases in LLM prompts and outputs."""

    def add_fairness_instruction(self, prompt: str) -> str:
        """Add fairness instruction to prompt."""
        fairness_instruction = """
IMPORTANT: Ensure your response is fair, unbiased, and does not contain
stereotypes based on gender, race, age, religion, or other protected characteristics.
Treat all groups with equal respect and dignity.
"""
        return fairness_instruction + "\n\n" + prompt

    def add_diversity_examples(self, prompt: str) -> str:
        """Add diverse examples to prompt."""
        return prompt + "\n\nProvide examples that represent diverse backgrounds, genders, and perspectives."

    def request_multiple_perspectives(self, prompt: str) -> str:
        """Request consideration of multiple viewpoints."""
…

Safety Guardrails

Comprehensive Safety Pipeline:

class SafetyGuardrails:
    """Comprehensive safety checks for LLM applications."""

    def __init__(
        self,
        toxicity_filter: ToxicityFilter,
        pii_detector: PIIDetector,
        bias_detector: BiasDetector,
        moderation_api: OpenAIModerationFilter
    ):
        self.toxicity_filter = toxicity_filter
        self.pii_detector = pii_detector
        self.bias_detector = bias_detector
        self.moderation_api = moderation_api

    async def check_input(self, user_input: str) -> Dict:
        """Run all safety checks on user input."""
        checks = {
…

Response Approach

When implementing AI safety:

  1. Assess risks: What could go wrong? (toxicity, PII, bias)
  2. Layer protections: Input filtering → Output filtering
  3. Implement detection: Toxicity, PII, bias detection

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Ai Safety Expert?

Ai Safety Expert is a subagent for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Audits and implements AI safety layers including content filtering, PII detection, bias mitigation, and LLM guardrails. Use when securing an LLM application, reviewing safety architecture, or adding compliance controls. Trigger with \"audit ai safety\", \"add safety guardrails\".

How do I install Ai Safety Expert in Claude Code?

Download ai-safety-expert.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use Ai Safety Expert in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is Ai Safety Expert safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.