---
schema_version: "1"
id: 3ffbc1750d6037e6035c604eec71cd6614be2ecbc4114efe4aa4bb53c2667f30
title: Rules
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforcedx/agentforcevibes/guides/files/afv-rules.md
canonical_url: https://developer.salesforce.com/docs/platform/agentforcevibes/guide/afv-rules.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b42e42bd931ca668db83cb68f47b6c10044c03be7c312237dce97aeddafaf7e5
products:
  - Agentforce Vibes Developer Guide
  - salesforcedx
---
# Rules

Rules are persistent instructions that the agent follows in every interaction. They encode standards that should always apply—coding conventions, architectural constraints, safety guardrails—so you don't have to repeat them in every prompt. Unlike Skills (which activate on-demand), Rules are always active.

## Types of Rules

The Rules panel groups rules by scope:

- **Project**—rules scoped to your current workspace, stored in `.vibes/rules/`. Commit them to version control so the whole team shares the same standards.
- **Global**—rules that apply across all your workspaces regardless of project.
- **Salesforce**—built-in rules that ship with Agentforce Vibes for core behavioral guidelines and safety.

### Built-in Salesforce Rules

Examples of included Salesforce rules:

| Rule                      | Description                                      |
| :------------------------ | :----------------------------------------------- |
| `a4v-expert-global-rule`  | Core Agentforce Vibes behavioral guidelines      |
| `production-guardrails`   | Safety constraints for production org operations |
| `metadata-best-practices` | Metadata retrieval and deployment standards      |

The full list of Salesforce rules appears in the Toolkit panel.

## View and Manage Rules

1. Open the Agentforce Vibes panel and click the **Toolkit** tab.
2. Click **Rules**.

The panel shows all rules with a toggle to enable or disable each one. Click the **...** menu next to a rule to edit or delete it.

## Create a Rule

1. Click **+ Add Rule** in the Rules panel.
2. Enter a **Name** in kebab-case (for example, `apex-naming-conventions`).
3. Select a **Scope**: Project or Global.
4. Select an **Application** mode:
   - **Always**—the rule applies to every interaction.
   - **File pattern**—the rule applies only when the agent works with files that match a glob pattern (for example, `**/*.cls`).
5. Write the content in markdown—the rule instructions that the agent should follow.
6. Click **Add Rule**.

For example, a rule that enforces Apex naming standards:

- **Name:** `apex-naming-conventions`
- **Scope:** Project
- **Application:** File pattern (`**/*.cls`)
- **Content:** `Class names use PascalCase. Method names use camelCase. Test classes end with "Test" suffix. Constants use SCREAMING_SNAKE_CASE.`

The agent applies this rule automatically whenever it generates or modifies `.cls` files.

## Application Modes

Rules support two application modes that control when the agent applies them:

- **Always**—the rule is active in every interaction regardless of what files are involved. Use for broad standards like "never deploy to production without running tests."
- **File pattern**—the rule activates only when the agent works with files matching a specific glob pattern. Use for language-specific or file-type-specific conventions (for example, `**/*.cls` for Apex rules, `**/*.html` for LWC template rules).

## Considerations

- Salesforce rules can't be edited or deleted. You can only toggle them on or off.
- Project rules override global rules when both define the same guidance.
- Rules consume context in every interaction. Keep them concise and focused on a single concern per rule.
- Use file patterns to reduce noise. A rule about Apex conventions doesn't need to load when the agent is working on LWC HTML templates.

## See Also

- [Skills](https://developer.salesforce.com/docs/platform/agentforcevibes/guide/afv-skills.md)
- [Permissions and Safety](https://developer.salesforce.com/docs/platform/agentforcevibes/guide/afv-permissions-safety.md)
