githubEdit

Directives

Directives allow security and engineering teams to govern how AI coding assistants operate across your organization, ensuring adherence to security policy, code standards, and approved workflows.

They have varying names across different coding assistants. For example, rules, instructions, commands, memories, skills, knowledge, workflows, hooks, and so on.

Snyk categorizes anything that guides an agent to produce code a certain way under the term "Directives" and offers code examples that you can use as they are, or customized to meet your needs.

Snyk provides the following directive types:

circle-info

Different coding assistants may require a different header or formatting for directives. Check the coding assistant's official documentation for formatting instructions.

Guardrail directives

Guardrail directives are automatically injected into agent interactions. They govern agent behavior by providing persistent context, setting security policies, and enforcing compliance rules.

Coding assistants have different mechanisms for how these types of directives are applied, but they are either appended to prompts or injected into the workflow when relevant.

circle-info

Non-determinism is a factor with LLM interactions and there can be scenarios where coding assistants do not append directives to prompts.

Secure at inception directives

There are many guardrail directives that your company may choose to implement, some of which may relate to security. Snyk's Secure at inception directives are code examples that can be used to ensure that AI-generated code is tested for security issues at the time of code generation.

The following directives can be customized to fit your organization's specific needs.

chevron-rightSecure at inception: SASThashtag

The following code snippet establishes the SAST constraint for new code and guides the agent through the mandated validation and remediation process:

- Always run snyk_code_scan tool for new first party code that is generated in a Snyk-supported language.

- If any security issues are found based on newly introduced or modified code or dependencies, attempt to fix the issues using the results context from Snyk.
- Rescan the code after fixing the issues to ensure that the issues were fixed and that there are no newly introduced issues.
- Repeat this process until no new issues are found.
chevron-rightSecure at inception: All Snyk productshashtag

The following code snippet extends the Secure at inception testing to include checks for Snyk Code, Snyk Open Source, Snyk Container, and Snyk IaC:

Command directives

Command directives are manually invoked by human developers or agents. They codify and standardize complex, multi-step engineering and security playbooks.

Remediation directives

Remediation directives, a category of command directive, trigger a full, end-to-end security remediation playbook that results in a secure pull request.

There are many command directives that companies may choose to implement, some of which may relate to security. Snyk's remediation directives are code examples that can be used to accelerate the remediation of pre-existing security issues.

The following directive can be customized to fit your organization's specific needs.

chevron-rightEnd-to-end vulnerability resolutionhashtag

This directive content guides the agent to:

  • Execute one or more security tests.

  • Filter the results if any parameters are provided.

  • Rescan to validate the security fix resolved the issues and did not introduce new ones.

Once executed, a pull request can be generated to review, approve, and merge into the codebase.

This directive is invoked by calling the directive in an agent chat interaction, for example, /snyk-fix. This is invoked without any arguments, which results in any detected findings being remediated, or it is invoked with specific Snyk product filters or other indications of which resulting findings should be fixed:

Last updated

Was this helpful?