# Workflow Patterns

Agentforce Vibes has two modes: Chat and Plan Mode. In Chat, the agent figures out the right approach based on your prompt — whether that means answering a question, generating code, debugging an issue, or coordinating parallel work. Use Plan Mode when you want a structured plan to review and approve before the agent executes.

## When to Use Chat

Use Chat for most tasks. Describe what you want and the agent determines how to handle it. Examples:

- Reading unfamiliar Apex code and asking what it does
- Querying org metadata to understand object relationships
- Generating a trigger + handler + test class from a description of the business logic
- Scaffolding an LWC with an Apex controller, event handling, and CSS
- Debugging a failing test class or tracing why a trigger isn't firing
- Writing a batch Apex class with proper start/execute/finish methods

The agent uses your org context, active Skills, and Rules to produce accurate, org-aware output. Create a Checkpoint before any complex execution so you can roll back if needed.

**What to verify after execution:**

- Do generated Apex classes follow bulkification patterns?
- Are SOQL (Salesforce Object Query Language) queries selective and outside of loops?
- Do test classes cover positive, negative, and bulk scenarios?
- Are field-level security and object permissions handled correctly?
- Does the code reference real fields and objects from your org (not placeholder names)?

## When to Use Plan Mode

Use Plan Mode when the work is complex enough that you want to see and approve the approach before anything executes. Examples:

- Designing a trigger framework that spans a handler class, test class, and custom metadata configuration
- Scoping an LWC (Lightning Web Component) feature that requires an Apex controller, wire adapters, and Jest tests
- Breaking down a complex integration into sequenced tasks with dependencies
- Any multi-file feature where execution order matters

Plan Mode produces a structured plan with Goals, Non-Goals, Approach, and numbered Tasks. No files change until you click **Approve Plan**.

**What to verify:** Review the plan for completeness. Does it account for all the objects, permissions, and test scenarios you need? Are there dependencies it missed?

## Anti-Patterns: When to Slow Down

Some tasks benefit from more careful handling regardless of mode.

**Security-sensitive logic that requires line-by-line review:**

- Encryption/decryption implementations
- Authentication and authorization flows
- Code that handles PII (Personally Identifiable Information) or financial data
- Sharing rule and permission set configurations that control data access

Use Plan Mode to get a recommended approach, then review every generated change carefully before accepting.

**Org-specific business rules the agent can't infer:**

- Complex validation logic based on undocumented business processes
- Integration mappings that depend on external system contracts not visible in your project
- Workflow behavior that exists only in production configuration (not code)

Provide these as explicit context or Rules before prompting. Don't let the agent guess business logic.

**Configuration-heavy work where Setup UI is faster:**

- Building permission sets and profiles
- Creating page layouts and record types
- Configuring sharing rules and org-wide defaults

Use Chat to understand what you need, then configure manually in Setup.

## Quick Reference

| You want to...                                       | Use       |
| :--------------------------------------------------- | :-------- |
| Ask a question, explore code, or understand metadata | Chat      |
| Generate code, debug, or execute a well-defined task | Chat      |
| Map out a multi-step feature before any files change | Plan Mode |
| Review and approve the approach for a complex build  | Plan Mode |

## See Also

- [What Is Agentic Development](/docs/platform/agentforcevibes/guide/afv-agentic-dev.md)
- [Plan Mode](/docs/platform/agentforcevibes/guide/afv-plan-mode.md)
- [Permissions and Safety](/docs/platform/agentforcevibes/guide/afv-permissions-safety.md)
