Rego Language Support
Rego is declarative rather than imperative and might be a programming style developers are not used to. The Styra extension provides support to reduce your learning curve:
- Syntax highlighting for Rego files
- Built-in Rego language examples (via VS Code Intellisense)
Open any Rego file and type rego
to see the list of available snippets shown in the following screenshot.

The first snippet, rego__help
provides a brief introduction to using Rego snippets and Styra DAS snippets. If you select any other Rego snippet from the list above, you will see the elements shown in the following screenshot.
- The trigger phrase.
- The short description.
- The long description.
- Inserted description for the current item, which is pasted into the editor.
- The documentation link.
- Package/import header that allows the code block to execute if you copy/paste it to the Rego playground.
- Sample data, surrounded by START/END comments for clarity.
- Code, with annotations as necessary.

A new Rego developer needs to learn how to apply a set of conditions by either conjunction or disjunction. Those are the first two in the list of snippets: rego_ex_CONDITION_AND
and rego_ex_CONDITION_OR
. Each example provides runnable code. Copy the entire inserted block into the Rego playground and select Evaluate to see what it does. We want you to have these at your fingertips to reduce the number of times you have to reference the Rego documentation.
The Styra VS Code extension also provides policy snippets (only for available for the Kubernetes System type).
Policy snippets are installed in a project when you connect to Styra DAS through the following:
Styra Link: Initialize
command in VS Codestyra link init
from the Styra CLI
When you update the Styra extension at a later date and it contains any snippet updates, those will be automatically updated in your project.
Styra provides many Kubernetes policy snippets. As you type, VS Code Intellisense displays a filtered list of snippets, as shown in the following screenshot.
