|
| 1 | +--- |
| 2 | +name: "guardrails-developer-create-guardrails" |
| 3 | +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." |
| 4 | +license: "Apache-2.0" |
| 5 | +--- |
| 6 | + |
| 7 | +# Create Guardrails |
| 8 | + |
| 9 | +Use this skill when a developer wants help creating a guardrails configuration, not just reading documentation. |
| 10 | +The goal is to produce a small, working configuration first, then iterate based on the user's risk, model, app, and test cases. |
| 11 | + |
| 12 | +Use `guardrails-developer-guide` to look up canonical docs when needed. |
| 13 | +Do not duplicate full docs in this skill. |
| 14 | + |
| 15 | +## Documentation Source Rule |
| 16 | + |
| 17 | +When using NVIDIA NeMo Guardrails library documentation, use the Markdown documentation under `https://docs.nvidia.com/nemo/guardrails/`. |
| 18 | +Use `llms.txt` and page URLs ending in `.md` when loading documentation for agent context. |
| 19 | +When presenting references or citations to users, use the canonical human-readable docs links without `.md`. |
| 20 | + |
| 21 | +## First Questions |
| 22 | + |
| 23 | +Ask only what you need to choose a starting path: |
| 24 | + |
| 25 | +1. What kind of application are you guarding? |
| 26 | +2. Which model/provider or framework are you using? |
| 27 | +3. Which risk do you want to handle first? |
| 28 | +4. Do you want a quick catalog-based guardrail, a Colang flow, or a Python integration? |
| 29 | + |
| 30 | +If the user is unsure, recommend starting with the smallest working input/output rail and one concrete test prompt. |
| 31 | + |
| 32 | +## Choose The Starting Pattern |
| 33 | + |
| 34 | +| User goal | Starting pattern | |
| 35 | +| --- | --- | |
| 36 | +| Block harmful content | Content safety input/output rails | |
| 37 | +| Restrict topics | Topic control or topical rails | |
| 38 | +| Detect jailbreaks | Jailbreak protection or heuristics | |
| 39 | +| Mask or detect sensitive data | PII detection rails | |
| 40 | +| Reduce hallucinations in RAG | Retrieval/output fact-checking rails | |
| 41 | +| Control conversation flow | Colang dialog flows | |
| 42 | +| Guard tool calls or actions | Execution rails and action validation | |
| 43 | +| Integrate with LangChain or LangGraph | RunnableRails, middleware, or documented integration path | |
| 44 | + |
| 45 | +Route to the relevant docs page through `guardrails-developer-guide` before filling in details that depend on the current docs. |
| 46 | + |
| 47 | +## Create A Minimal Config |
| 48 | + |
| 49 | +Prefer a standard config folder layout: |
| 50 | + |
| 51 | +```text |
| 52 | +config/ |
| 53 | + config.yml |
| 54 | + prompts.yml |
| 55 | + rails.co |
| 56 | + actions.py |
| 57 | +``` |
| 58 | + |
| 59 | +Only create files that are needed: |
| 60 | + |
| 61 | +- Use `config.yml` for models, rails, streaming, tracing, and configuration. |
| 62 | +- Use `prompts.yml` when the selected rail needs custom prompt templates. |
| 63 | +- Use `.co` files when the solution needs Colang flows. |
| 64 | +- Use `actions.py` only when Python actions are required. |
| 65 | + |
| 66 | +When editing an existing app, preserve the user's project layout and avoid moving unrelated files. |
| 67 | + |
| 68 | +## Build Iteratively |
| 69 | + |
| 70 | +1. Start with one guardrail objective. |
| 71 | +2. Write the smallest config that exercises that objective. |
| 72 | +3. Add two or three test prompts: |
| 73 | + - a request that should pass, |
| 74 | + - a request that should be blocked or modified, |
| 75 | + - an edge case if the user has one. |
| 76 | +4. Run the config through the documented Python API, CLI chat, or server path that matches the user's setup. |
| 77 | +5. Inspect the result and adjust the rail, prompt, flow, or model configuration. |
| 78 | + |
| 79 | +Do not silently introduce live provider calls. |
| 80 | +Ask before running commands that require network access, credentials, paid APIs, Docker, or long-running services. |
| 81 | + |
| 82 | +## Testing And Verification |
| 83 | + |
| 84 | +For product users, verify with the smallest runnable example: |
| 85 | + |
| 86 | +- `nemoguardrails chat --config <config-path>` when using the CLI. |
| 87 | +- A short Python script with `RailsConfig.from_path(...)` and `LLMRails(...)` when embedding in an app. |
| 88 | +- The documented server endpoints when using the Guardrails API server. |
| 89 | + |
| 90 | +For repository contributors, unit tests must not call live LLM or provider services. |
| 91 | +Use repository test doubles and mocks according to `nemoguardrails/AGENTS.md`. |
| 92 | + |
| 93 | +## Security And Credentials |
| 94 | + |
| 95 | +- Never ask users to paste real API keys, tokens, or provider credentials into chat. |
| 96 | +- Use placeholders such as `<NVIDIA_API_KEY>`, `<OPENAI_API_KEY>`, and `<YOUR_ENDPOINT>`. |
| 97 | +- Explain where secrets should be set locally. |
| 98 | +- Do not write secrets into committed config examples. |
| 99 | + |
| 100 | +## Output Format |
| 101 | + |
| 102 | +When helping create guardrails, return: |
| 103 | + |
| 104 | +1. The chosen starting pattern and why. |
| 105 | +2. The files to create or edit. |
| 106 | +3. The proposed config or code snippets. |
| 107 | +4. The verification command or script. |
| 108 | +5. The test prompts and expected behavior. |
| 109 | +6. Follow-up improvements after the first working version. |
| 110 | + |
| 111 | +## Related Skills |
| 112 | + |
| 113 | +- Use `guardrails-developer-guide` for documentation lookup and product-usage questions. |
| 114 | +When editing this repository, follow `AGENTS.md` and any subtree `AGENTS.md` files that apply. |
0 commit comments