Skip to main content

Apply Context Strategies for Common Development Tasks

Learning Objectives

After completing this unit, you’ll be able to:

  • Apply recommended context combinations for common development tasks.
  • Describe how the org connection enriches AI responses beyond file-level context.
  • Identify strategies for building context iteratively to improve results.

Matching Context to the Task

You now know what types of context are available. This unit covers practical strategies for providing the right context for common Salesforce development tasks.

Different tasks need different context. The table below shows recommended combinations for the most common Salesforce development scenarios. Each combination is designed to give the agent enough information to act on your specific situation rather than offer generic advice.

Scenario

Context to Combine

Deployment failure

Files + Last Terminal Output + Workspace Problems

Test failures

Test class + Main class + Last Terminal Output

Component development

Component files + Database + Related Apex

Integration debugging

Service classes + Last Terminal Output + Files

These are just suggested starting points. If the agent's first response misses something, attach more context and ask again.

The Difference Context Makes: A Deployment Example

Say a deployment fails with a field-does-not-exist error. Without context, you paste the error into chat and ask what's wrong. The agent gives you a general answer about field API names.

With Files (the affected class), Last Terminal utput (the full error trace), and Workspace Problems (all current validation errors) attached, the agent can see that the field is referenced in line 47 of your Apex class, that it's named Renewal_Status__c in your code but doesn't appear in the org error, and that two other problems in the Problems panel are related. It can suggest the fix, verify it against your schema if Database is also attached, and check whether the same field is referenced elsewhere in the files you've provided.

That's the difference between a diagnosis and a guess.

How the Org Connection Enriches Agent Responses

Beyond the context you attach manually, your connected org provides continuous awareness. When Agentforce Vibes is connected to your development org and operating in Agent mode, the agent can take direct action inside your local environment: analyzing code, querying metadata, and verifying assumptions against your real org.

This org awareness changes how you prompt. With a general AI tool, you'd describe your data model: "I have an Account object with a custom field called SLA_Tier__c, a picklist with values Gold, Silver, Bronze." With Database context attached, you reference it: "Write a validation rule for SLA_Tier__con Account." The agent knows the field exists, its type, and its picklist values.

The cognitive overhead of translating your org's specifics into AI-readable descriptions goes away. What's left is the work.

Iterative Context: Add More as You Go

You don't always need to provide all the context up front. In practice, effective context provision is often iterative.

  • Start with your intent. Describe what you're trying to accomplish.
  • Add specific context. Reference the files, objects, or errors most relevant to the task.
  • Respond to what the AI shows you. If the AI's suggestion misses something, add the context it's missing. ("Also attach the Account sObject from Database" or "Check Last Terminal Output for the actual error.")
  • Refine and repeat. Each round of context narrows the AI toward a more precise solution.

This iterative approach works well because it mirrors how you'd work with a team member. You explain the problem, they ask clarifying questions (or you notice where they're off track), and you provide more detail until the solution clicks.

Persistent Context: Skills and Rules

Everything covered in this unit so far is session-level context; you attach it at the start of a conversation, and it applies to that session. Agentforce Vibes also supports persistent context that carries across every session automatically.

Skills and Rules live in the .vibes/folder in your project. A Skill encodes a repeatable pattern, like your team's trigger framework, your test data factory, your LWC naming conventions. A Rule enforces a constraint, like bulkification requirements, governor limit checks, security standards. Once defined, they load automatically without any manual attachment.

This is the answer to "do I have to re-attach the same context every session?" For project-level patterns and standards, you don't. You write them once as a Skill or Rule, and the agent applies them from that point forward.

The practical split: Use session-level context (@ picker, file uploads) for task-specific information that changes between conversations. Use Skills and Rules for team conventions and standards that should apply to everything. Getting this balance right is one of the bigger context efficiency gains available to teams working with Agentforce Vibes at scale.

Context Relevance vs. Volume

More context generally improves results, but relevance matters more than volume.

Do:

  • Provide context directly related to your current task.
  • Include examples of the patterns you want the AI to follow.
  • Reference error messages and outputs rather than describing them from memory.

Don't:

  • Reference every file in your project when you only need help with one.
  • Provide conflicting examples that demonstrate different patterns.

The agent's context window has limits; very large or numerous files may be truncated (managed automatically). If you're working with very large files, consider using the right-click Agentforce: Add to Context option on specific selections rather than attaching the entire file.

There's also a timing consideration. Context attached from a previous task doesn't automatically stop applying. If you've been working on a trigger framework and shift to a UI task without clearing your attached context, the agent may try to reconcile the two when they have nothing to do with each other. Clear attached context when switching tasks. It takes seconds and removes a source of subtle, hard-to-diagnose drift in the agent's responses.

When to Start a New Session

Context accumulates across a conversation. The agent uses your full conversation history when responding, which helps with continuity but creates a problem on long sessions: earlier context can start influencing responses in ways you don't intend. If you asked the agent to follow a particular pattern three hours ago and that pattern no longer applies to your current task, the agent may still be working from it.

The practical threshold: when you switch to a substantially different task, start a new chat session. Re-attach the context that's relevant to the new work. This takes less time than you'd expect, and it produces cleaner output than continuing a session that's accumulated context from multiple unrelated tasks.

One sign that a session has run long: the agent's responses start referencing files or decisions from earlier in the conversation that aren't relevant to what you just asked. That's the time to start fresh, not to keep prompting.

Know What Context Can't Cover

Good context improves output. It doesn't eliminate the need for review, and understanding why helps you work with the agent more effectively.

The agent can see your sObject schema, but not your undocumented business rules. If your org has a validation rule that rejects records when a picklist value is "Legacy" and the opportunity stage is "Closed Won," that logic isn't in your metadata. The agent will generate code that passes schema checks and fails in production. For tasks that involve business rules like these, include a description in your prompt. Database context doesn't cover it.

The agent can also see your file contents, but not your intent. If an existing class has a known bug that you haven't fixed, attaching it as a pattern to follow passes the bug forward. When you use Files context to demonstrate team patterns, point to your best examples.

Think of context as a briefing before the agent starts work. A good briefing covers what's in the codebase, what the business requires, and any exceptions to the normal patterns.

As you continue to learn about the many features of Agentforce Vibes, remember that the foundation stays the same: better context in, better code out.

Resources

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback