Mastering Salesforce Development : Best Practices for Cursor Agent Rules & Workflows
Jan 29, 2026
Show More Show Less
View Video Transcript
0:07
Hello everyone. In this video, we are
0:10
going to see how to master Salesforce
0:13
development.
0:15
Whenever we use uh wipe coding or if we
0:19
use any AI assistant,
0:24
whenever we have a complex use case, we
0:28
make use of white coding or we make use
0:31
of some A assistant to get some help.
0:35
The code that is generated
0:38
by this a agents
0:43
will be sometimes uh accurate or it
0:47
might have some mistakes.
0:52
If you wanted to fine-tune the code
0:55
which is getting generated from this AA
0:59
assistance
1:00
then we have to instruct the
1:03
A assistance so that it can give us a
1:06
better optimized code.
1:10
Every time when we prompt
1:13
we have to copy paste the best practices
1:19
and the way it should produce the
1:21
content
1:24
and then it is a manual effort.
1:29
Let's see how to automate this. I have
1:32
been a Salesforce developer for more
1:34
than 15 years.
1:37
Whenever I wrote write code
1:40
based on the experience,
1:42
I fine-tune the code. I try to avoid
1:46
using SQL or TML operations inside a for
1:49
loop. So these are all some basic things
1:52
which is there in my mind.
1:55
But a assistance sometimes may miss some
2:00
best practices and the standard
2:02
practices.
2:04
In some companies we have center of
2:07
excellence or COE.
2:10
In that we will be having some standard
2:13
guidelines. We can also make use of
2:16
those standard guidelines
2:18
and uh um request the A assistants to
2:22
generate a optimized code. I am using
2:27
cursor for my day-to-day development
2:29
activities. In cursor we have
2:33
rule rule option. Using that rule option
2:37
we can define the standard and best
2:39
practices so that the agents will make
2:43
use of the instructions that are
2:45
available in the rule and then it will
2:48
make use of that to produce the content.
2:53
There are different levels of rules that
2:55
can be set in cursor. One is project
2:59
rules
3:01
user the other one is user rules we also
3:04
have team rules and then we have
3:05
agents.md
3:07
each rule have their own purposes
3:12
I'm going to make use of user role so
3:15
that uh it is stored in my uh PC and uh
3:20
it is global to the cursor environment
3:23
uh in my particular machine and then uh
3:27
if If I prompt anything to my AA agent,
3:31
it will make use of the user rule and
3:34
then it will try to generate the
3:35
content.
3:39
Let's see how to do that. So if you go
3:41
to cursor
3:44
in cursor settings
3:47
go to rules skills uh sub agents. Here
3:53
under rules you can click new and then
3:56
you can select whether it should be user
3:57
rule, project rule or if you wanted to
4:00
add it from a GitHub you can add it. You
4:03
will see this uh particular uh option
4:07
agents MD only if you have a paid
4:10
version.
4:13
Okay, you can click user rule and then
4:17
it will create it. In this user r rule
4:21
you can define the rules.
4:25
So this is the rule I have set. This is
4:28
the critical instruction I have given.
4:32
Whenever we write uh Salesforce Apex or
4:36
lightning web component or lightning
4:37
aura component we always add comments so
4:40
that it will be helpful for other
4:43
developers and architects to understand
4:45
the code. So this is the documentation
4:48
and formatting. Um like it should give
4:51
four spaces for indent like that I have
4:55
given all the information.
4:59
So this one is for apex
5:02
this one is for javascript
5:05
and u in apex it should always have w
5:09
with sharing so that uh uh we are not
5:12
missing any security issues. I have
5:14
asked to make use of enforcing field
5:18
level security with the help of
5:20
security. Inaccessible like that I have
5:23
given so many instructions. Even when it
5:25
writes a trigger, I have instructed to
5:28
check if there is an already uh an
5:30
existing trigger. If there is an
5:32
existing trigger, there should be one
5:34
trigger per object. So, make use of that
5:37
particular existing trigger like that I
5:38
have given. And for SQL, I have given
5:41
some instruction. For lightning web
5:43
component I have given some instruction
5:46
for um agent force development and as
5:49
well as for flow development. I have
5:51
given some examples uh some instructions
5:55
whenever we develop apex class we have
5:58
to develop apex test classes also for
6:01
it. So I have given how what are all the
6:06
best practices it should follow so that
6:09
it generates
6:11
uh a test class with all the
6:13
instructions that are available in this
6:15
rule.
6:18
Let's see a demo. So here
6:21
I'm going to ask
6:24
create a trigger
6:27
on contact object
6:31
and update account
6:35
record with number of contacts.
6:45
Now since I have given all these uh
6:48
rule, it should follow all these uh
6:50
rules and then it should generate the
6:52
code content for me.
7:01
So this is the prompt I have given
7:04
create a trigger on contact object and
7:05
update account record with number of
7:07
contacts.
7:09
So it is trying to generate the code for
7:11
me now.
7:33
So it will make use of
7:36
all the best practices that are laid out
7:38
here and then it will generate the Apex
7:42
code for us.
7:51
So it is creating
7:56
See it already found an existing
7:58
trigger.
8:03
So it is making use of all the
8:05
instructions that are available in the
8:07
rule.
8:20
So,
8:22
so now if I confirm these information,
8:25
it will generate the code for me.
8:28
So make use of rules in cursor and
8:34
mention all the best practices you are
8:36
practicing it for in in your Salesforce
8:39
development so that the A assistant
8:43
generated code will follow all the
8:45
instructions that are uh applied in the
8:48
rule.
8:50
Please check the video description. In
8:52
the video description I have shared my
8:54
blog post. From the blog post, you
8:56
should be able to get the sample rule
8:58
that I have used in my cursor IDE.
9:04
You can use this as a reference.
9:11
I hope it was helpful.
9:20
Thank you for watching.
#Internet Software
