---
name: "guardrails-developer-create-guardrails"
description: "Helps developers create a NeMo Guardrails configuration for an LLM application. Use when users want to build, scaffold, configure, test, or iterate on input, output, retrieval, dialog, execution, Colang, or catalog-based guardrails. Trigger keywords - create guardrails, build guardrails, scaffold config, write rails, create config.yml, add input rails, add output rails, Colang flow, guardrails config, test guardrails."
license: "Apache-2.0"
title: guardrails-developer-create-guardrails
canonical_url: https://skilld.dev/gh/nvidia-nemo/guardrails/guardrails-developer-create-guardrails
last_updated: 2026-11-18T15:00:49.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install nvidia-nemo/guardrails/guardrails-developer-create-guardrails`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/guardrails-developer-create-guardrails`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/nvidia-nemo/guardrails/guardrails-developer-create-guardrails) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/guardrails-developer-create-guardrails`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/guardrails-developer-create-guardrails --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/guardrails-developer-create-guardrails --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Create Guardrails

Use this skill when a developer wants help creating a guardrails configuration, not just reading documentation.
The goal is to produce a small, working configuration first, then iterate based on the user's risk, model, app, and test cases.

Use `guardrails-developer-guide` to look up canonical docs when needed.
Do not duplicate full docs in this skill.

## Documentation Source Rule

When using NVIDIA NeMo Guardrails library documentation, use the Markdown documentation under `https://docs.nvidia.com/nemo/guardrails/`.
Use `llms.txt` and page URLs ending in `.md` when loading documentation for agent context.
When presenting references or citations to users, use the canonical human-readable docs links without `.md`.

## First Questions

Ask only what you need to choose a starting path:

1. What kind of application are you guarding?
2. Which model/provider or framework are you using?
3. Which risk do you want to handle first?
4. Do you want a quick catalog-based guardrail, a Colang flow, or a Python integration?

If the user is unsure, recommend starting with the smallest working input/output rail and one concrete test prompt.

## Choose The Starting Pattern

| User goal | Starting pattern |
| --- | --- |
| Block harmful content | Content safety input/output rails |
| Restrict topics | Topic control or topical rails |
| Detect jailbreaks | Jailbreak protection or heuristics |
| Mask or detect sensitive data | PII detection rails |
| Reduce hallucinations in RAG | Retrieval/output fact-checking rails |
| Control conversation flow | Colang dialog flows |
| Guard tool calls or actions | Execution rails and action validation |
| Integrate with LangChain or LangGraph | RunnableRails, middleware, or documented integration path |

Route to the relevant docs page through `guardrails-developer-guide` before filling in details that depend on the current docs.

## Create A Minimal Config

Prefer a standard config folder layout:

```text
config/
  config.yml
  prompts.yml
  rails.co
  actions.py
```

Only create files that are needed:

- Use `config.yml` for models, rails, streaming, tracing, and configuration.
- Use `prompts.yml` when the selected rail needs custom prompt templates.
- Use `.co` files when the solution needs Colang flows.
- Use `actions.py` only when Python actions are required.

When editing an existing app, preserve the user's project layout and avoid moving unrelated files.

## Build Iteratively

1. Start with one guardrail objective.
2. Write the smallest config that exercises that objective.
3. Add two or three test prompts:
   - a request that should pass,
   - a request that should be blocked or modified,
   - an edge case if the user has one.
4. Run the config through the documented Python API, CLI chat, or server path that matches the user's setup.
5. Inspect the result and adjust the rail, prompt, flow, or model configuration.

Do not silently introduce live provider calls.
Ask before running commands that require network access, credentials, paid APIs, Docker, or long-running services.

## Testing And Verification

For product users, verify with the smallest runnable example:

- `nemoguardrails chat --config <config-path>` when using the CLI.
- A short Python script with `RailsConfig.from_path(...)` and `LLMRails(...)` when embedding in an app.
- The documented server endpoints when using the Guardrails API server.

For repository contributors, unit tests must not call live LLM or provider services.
Use repository test doubles and mocks according to `nemoguardrails/AGENTS.md`.

## Security And Credentials

- Never ask users to paste real API keys, tokens, or provider credentials into chat.
- Use placeholders such as `<NVIDIA_API_KEY>`, `<OPENAI_API_KEY>`, and `<YOUR_ENDPOINT>`.
- Explain where secrets should be set locally.
- Do not write secrets into committed config examples.

## Output Format

When helping create guardrails, return:

1. The chosen starting pattern and why.
2. The files to create or edit.
3. The proposed config or code snippets.
4. The verification command or script.
5. The test prompts and expected behavior.
6. Follow-up improvements after the first working version.

## Related Skills

- Use `guardrails-developer-guide` for documentation lookup and product-usage questions.
When editing this repository, follow `AGENTS.md` and any subtree `AGENTS.md` files that apply.
