Skip to content

Commit 0401324

Browse files
committed
Add first draft
1 parent b80de0a commit 0401324

File tree

1 file changed

+74
-12
lines changed

1 file changed

+74
-12
lines changed

docs/cody/prompts-guide.mdx

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Before you start writing prompts, preparing your codebase for Cody is essential.
2626

2727
## Treat Cody like a new team member
2828

29-
When using Cody, it's helpful to treat it like a new team member unfamiliar with your codebase. This approach helps ensure that you provide Cody with the necessary context and information to generate accurate and contextually aware answers.
29+
When using Cody, it's helpful to treat it like a new team member unfamiliar with your codebase. This approach ensures you provide Cody with the necessary context and information to generate accurate and contextually aware answers.
3030

3131
You should focus on providing Cody with all the necessary information, such as the codebase structure, function names, and any relevant docs. The more context and details you provide, the better Cody can assist you in generating relevant and accurate code. For example,
3232

@@ -68,7 +68,7 @@ function calc($i, $t) {
6868

6969
## Write clear code comments and docstrings
7070

71-
In addition to variable names, comments and docstrings are crucial in guiding Cody's understanding of your code. Treat them as a way to communicate with Cody, just like you would with a new engineer. Explain complex logic, algorithms, or project-specific concepts to give Cody context.
71+
In addition to variable names, comments, and docstrings are crucial in guiding Cody's understanding of your code. Treat them as a way to communicate with Cody, just like you would with a new engineer. Explain complex logic, algorithms, or project-specific concepts to give Cody context.
7272

7373
✅ Good example:
7474

@@ -97,13 +97,13 @@ You can learn more about context [here](/cody/capabilities/context).
9797

9898
## Selecting the right LLM
9999

100-
Cody offers a variety of LLMs for both chat and in-line edits by all the leading LLM providers. Each LLM has its strengths and weaknesses, so selecting the right one for your use case is important. For example, Claude 3.5 Sonnet and GPT-4o are powerful for code generation and provide accurate results. However, Gemini 1.5 Flash is a decent choice for cost-effective searches. So, you can always optimize your choice of LLM based on your use case.
100+
Cody offers a variety of LLMs for both chat and in-line edits by all the leading LLM providers. Each LLM has its strengths and weaknesses, so it is important to select the right one for your use case. For example, Claude 3.5 Sonnet and GPT-4o are powerful for code generation and provide accurate results. However, Gemini 1.5 Flash is a decent choice for cost-effective searches. So, you can always optimize your choice of LLM based on your use case.
101101

102102
Learn more about all the supported LLMs [here](/cody/capabilities/supported-models).
103103

104104
## 2. Prompting
105105

106-
Now that your code is well-prepared let's focus on writing effective prompts for Cody via the following best practices:
106+
Now that your code is well-prepared, let's focus on writing effective prompts for Cody via the following best practices:
107107

108108
## Provide specific information
109109

@@ -211,21 +211,21 @@ Try adding any supplementary details regarding comments, debugging guidelines, e
211211

212212
## Prompts Library
213213

214-
To accelerate and automate your work, you can leverage Cody's Prompt Library that helps you to build customizable building blocks (prompts), share your best prompts with your teammates, and enable site administrators to promote the best prompts to the rest of the organization.
214+
To accelerate and automate your work, you can leverage Cody's Prompt Library, which helps you build customizable building blocks (prompts), share your best prompts with your teammates, and enable site administrators to promote the best prompts to the rest of the organization.
215215

216-
The Prompt Library is a system for creating and sharing customizable prompts and are designed it specifically to cater scalability, repeatability, and flexibility.
216+
The Prompt Library is a system for creating and sharing customizable prompts. It is explicitly designed for scalability, repeatability, and flexibility.
217217

218-
You can learn more about the [Prompts and the Prompt Library here](/cody/capabilities/commands).
218+
Learn more about the [Prompts and the Prompt Library here](/cody/capabilities/commands).
219219

220220
## Example Prompts
221221

222-
Let's take a look at some examples of good and reusable prompts that you can create via the Prompt Library.
222+
Let's examine some examples of good and reusable prompts that you can create via the Prompt Library.
223223

224-
<Accordion title=" Prompt that specifies the language/framework version you are using">
224+
<Accordion title=" 1. Prompt that specifies the language/framework version you are using">
225225

226-
This prompt can help you if Cody does not generate code in the right language/framework version. For example,
226+
This prompt can help if Cody needs to generate code in the correct language/framework version. For example,
227227

228-
>Cody generating code snippets using a newer [Spring](https://spring.io/) version that's incompatible with your legacy Java application, which runs Spring 3.x. This mismatch leads to examples utilizing features from Spring Boot 2.x that your project doesn't support.
228+
>Cody generates code snippets using a newer [Spring](https://spring.io/) version that's incompatible with your legacy Java application, which runs Spring 3.x. This mismatch leads to examples utilizing features from Spring Boot 2.x that your project doesn't support.
229229
230230
The prompt to tackle this issue looks like this:
231231

@@ -238,5 +238,67 @@ Testing framework: JUnit 4"
238238
239239
```
240240

241-
By sharing this prompt with your team, everyone can ensure that Cody generates code compatible with your legacy system.
242241
</Accordion>
242+
243+
<Accordion title="2. Prompt that instructs Cody to follow your organization's styleguide">
244+
245+
This prompt can help if Cody needs to follow your organization's coding standards or styleguide. For example,
246+
247+
>Your organization follows a specific Python coding styleguide that mandates using snake_case for variable names and requires docstrings for all functions. However, Cody might generate code that doesn't adhere to these conventions, leading to inconsistency in your codebase.
248+
249+
The prompt to resolve this inconsistency will be:
250+
251+
```
252+
Generate Python code that adheres to our organization's style guide, which includes the following requirements:
253+
254+
Use snake_case for all variable and function names.
255+
Include docstrings for all functions, describing their purpose and parameters.
256+
Follow PEP 8 guidelines for code formatting, including indentation and line length.
257+
```
258+
259+
</Accordion>
260+
261+
<Accordion title="3. Prompt with enhanced generate-unit-tests capabilities">
262+
263+
This prompt can help you if you want to generate unit tests for your code based on a specific format. For example,
264+
265+
>You're working with Golang and need Cody to generate unit tests that comply with your team’s conventions. Your organization follows a specific structure for tests, including table-driven tests and `require` from the `testify` package for assertions. However, Cody might provide a simple test that does not align with your standards.
266+
267+
While you can use the default `generate-unit-tests` prompt but to get the desired output, you can customize e the prompt to include the following:
268+
269+
```
270+
Please generate Golang unit tests that adhere to the following conventions:
271+
272+
Use table-driven tests for different input cases.
273+
Use the require package from testify for assertions.
274+
Follow idiomatic Go test naming conventions and structure.
275+
```
276+
277+
</Accordion>
278+
279+
<Accordion title="4. An onboarding prompt for new team members">
280+
281+
This prompt can help you if you want to onboard new team members by providing them with a set of instructions or guidelines to get started with a project. For example,
282+
283+
```
284+
@repo tell me about this project and how to set it up.
285+
```
286+
287+
</Accordion>
288+
289+
<Accordion title="5. Customized code documentation prompt">
290+
291+
To encourage detailed and comprehensive docs of your codebase, you can create a prompt instructing Cody to generate documentation based on your styleguide. For example,
292+
293+
```
294+
Please generate a docstring for the given Python function that adheres to our team's documentation standards. The docstring should include:
295+
1. A brief summary of the function's purpose.
296+
2. A description of each parameter, including name, type, and purpose.
297+
3. The return value, including its type and description.
298+
4. Any raised exceptions, if applicable.
299+
5. Example usage of the function, where relevant.
300+
```
301+
302+
</Accordion>
303+
304+
You can share all these prompt examples with your team members to help them get started with Cody. If you want others to make the most of these, you can also promote the best prompts.

0 commit comments

Comments
 (0)