AI Safety Guardrails
Input/output safety filters for AI systems. Pluggable filter pipeline that sits between user and LLM boundaries, inspecting and filtering both directions. Ships with prompt-injection detection, PII redaction, content-policy enforcement, and token-limit guards. The filter registry pattern makes it trivial to add custom safety filters.
| Name | guardrails |
| Version | 0.1.0 |
| Category | ai-systems |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | ai, safety, guardrails, filters, typescript |
| Source | templates/guardrails |
Render it
Three front doors, one catalog. Pick whichever suits the caller.
# CLI
npx @nanohype/sdk render guardrails --out ./my-app
# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "guardrails", variables);
# MCP — from an agent
get_template({ name: "guardrails" })Prerequisites
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for the guardrails module |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toAI safety guardrails- Short project description for package.json and README
IncludePiibool — defaults totrue- Include PII detection filter
IncludeContentPolicybool — defaults totrue- Include content policy filter
IncludeTestsbool — defaults totrue- Include test suite
What it produces
22 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.
.env.example
.gitignore
biome.json
package.json
README.md
src/guardrails/bootstrap.ts
src/guardrails/filters/__tests__/pii.test.ts
src/guardrails/filters/__tests__/pipeline.test.ts
src/guardrails/filters/__tests__/prompt-injection.test.ts
src/guardrails/filters/content-policy.ts
src/guardrails/filters/index.ts
src/guardrails/filters/pii.ts
src/guardrails/filters/prompt-injection.ts
src/guardrails/filters/registry.ts
src/guardrails/filters/token-limit.ts
src/guardrails/filters/types.ts
src/guardrails/index.ts
src/guardrails/pipeline.ts
src/guardrails/types.ts
src/logger.ts
tsconfig.json
vitest.config.tsComposes with
- Pairs with
agentic-loop - Pairs with
mcp-server-ts - Pairs with
ts-service - Pairs with
rag-pipeline - Nests inside
monorepo
Composites that use it
- Enterprise AI Infrastructure — Full enterprise AI stack with agents, tool servers, safety guardrails, evaluation, prompt management, observability, and Kubernetes deployment..
- AI Evaluation Suite — Standalone evaluation infrastructure with test harness, versioned prompts, and guardrails validation.
- Multi-Agent System — Multi-agent architecture with A2A protocol peers, MCP tool servers, and an orchestrating agent.
- Safe AI Agent — AI agent with safety guardrails, evaluation harness, and prompt management.