What makes an effective rule
Include facts the agents cannot infer from the code on their own. Describe your codebase so the agents understand what they read and which attacks are realistic:- The primary languages and frameworks you use on the frontend and backend.
- The entry points where untrusted input arrives, such as the package that holds your HTTP handlers.
- The authentication and authorization enforcement points, such as the middleware that protects your API routes and the file it lives in.
- The trust boundaries in your code, identified by file or directory.
- The sinks and sanitizers specific to your project, named exactly.
- The sources of secrets and configuration, such as a secrets manager loaded at boot rather than values hardcoded in source.
- The deployment shape, such as a static frontend with all authorization enforced server-side.
What not to include in a rule
AI context rules are reference evidence, not instructions, so the agents ignore anything that tries to override their built-in behavior. Do not include the following:- Instructions to turn off a detection category, such as telling the agents not to report SQL injection.
- Instructions to ignore real secrets, such as hardcoded credentials. The agents always report them.
- Demands for a finding that the code evidence does not support.
- Generic security advice, such as OWASP, CWE, or phrases like validate all input. It says nothing about your code, so the agents ignore it.
- Secrets, tokens, private keys, personal data, or verbatim source code. Reference sensitive code by its file path and symbol name instead.
Automatic context from repository files
During a scan, Endor Labs also builds context automatically. It reads guidance files in your repository along with prior reviewer decisions, grounds them against your code, and uses them alongside the rules you create. Reviewer feedback takes precedence over the rules you write, and the most recent decision takes precedence when reviewers disagree over time. By default, a scan reads these files when they are within the scan scope:CLAUDE.md, and files under.claude/agents/and.claude/rules/.AGENTS.md..cursorrules, and files under.cursor/rules/..github/copilot-instructions.md.SKILL.mdfiles, such as.claude/skills/<name>/SKILL.md.memory.md.
Create an AI context rule
Create a rule to give the agents guidance about your code. You can enable or disable a rule at any time after you create it. To create an AI context rule:- Select Policies from the user menu.
- Select AI Context Rules.
- Select Create AI Context.
- Enter the following details:
- AI Context Name: A name that identifies the rule.
- Context: The guidance the agents read. Describe the codebase, the conditions to look for, or background about the project.
- Under Scope, select the namespace the rule applies to. By default, the rule applies to all projects in the namespace.
- To limit the rule to specific projects, use Inclusions:
- Click Add more under Inclusions.
- Select the projects you want to include.
- Click Update.
- Optionally, enter the tags of the projects you want to include.
- To exclude specific projects, use Exclusions:
- Click Add more under Exclusions.
- Select the projects you want to exclude.
- Click Update.
- Optionally, enter the tags of the projects you want to exclude.
- Click Create AI Context.

Manage AI context rules
You can edit, clone, delete, enable, or disable a rule at any time. Update or delete a rule when the code it describes moves or changes, so the agents do not work from stale guidance. Edit a rule to update its name, context, or scope.- Select Policies from the user menu.
- Select AI Context Rules.
- Click the vertical three dots next to the rule you want to edit.
- Select Edit.
- Update the AI context name, context, inclusions, or exclusions.
- Click Update AI Context.
- Select Policies from the user menu.
- Select AI Context Rules.
- Click the vertical three dots next to the rule you want to clone and select Clone.
- Update the AI context name, context, inclusions, and exclusions for the new rule.
- Click Create AI Context.
- Select Policies from the user menu.
- Select AI Context Rules.
- Click the vertical three dots next to the rule you want to remove and select Delete.
Example AI context rules
Adapt the names and paths in these examples to your own code.Authentication happens in another service
Authentication happens in another service
Authentication is handled upstream, so the agents stop flagging missing authentication in this service but keep reporting missing resource authorization.
A dependency provides the sanitizer
A dependency provides the sanitizer
A shared library sanitizes HTML, so the agents suppress XSS findings on output that passes through it while still reporting sinks that bypass it.
A required authentication mechanism for every endpoint
A required authentication mechanism for every endpoint
Every protected endpoint must use a specific middleware, so the agents report routes registered without it and leave public routes alone.
Tenant boundary fields
Tenant boundary fields
Specific fields enforce tenant isolation, so the agents report routes that scope queries by user instead of by tenant.
Custom admin model and low-noise scope
Custom admin model and low-noise scope
Admin actions need two separate checks and some directories are out of scope, so the agents catch incomplete admin checks and suppress findings in non-production paths.