A prompt example provides step-by-step instructions for using GitLab Duo to accomplish a specific development or business task.
A prompt example should answer the questions:
These pages should be precise and easy to scan. They do not replace other documentation types on the site, but instead complement them. They should not be full of links or related conceptual or task information.
FormatPrompt examples should be in this format:
title: Title (active verb + object, like "Refactor legacy code")
---
One-sentence description of when to use this approach.
- Time estimate: X-Y minutes
- Level: Beginner/Intermediate/Advanced
- Prerequisites: What users need before starting
(To populate these items, see the guidance that follows this example.)
## The challenge
1-2 sentence description of the specific problem this solves.
## The approach
Brief description of the overall strategy and which GitLab Duo tools to use (usually 2-4 key phrases).
### Step 1: [Action verb]
[Specify which GitLab Duo tool to use] Brief description of what this step accomplishes.
```plaintext
Prompt template with placeholders in [brackets]
```
Expected outcome: What should happen when this prompt is used.
### Step 2: [Action verb]
[Specify which GitLab Duo tool to use] Brief description of what this step accomplishes.
```plaintext
Next prompt template with placeholders in [brackets]
```
Expected outcome: What should happen when this prompt is used.
## Tips
- Specific actionable advice for better results
- Common pitfalls to avoid
- How to iterate if first attempt doesn't work
## Verify
Ensure that:
- Quality check 1 - specific and measurable
- Quality check 2 - specific and measurable
- Quality check 3 - specific and measurable
Prompt example topic titles
For the title text, use the structure active verb
+ noun
. For example:
Refactor legacy code
Debug failing tests
Generate API documentation
Avoid these topic titles:
How to [do something]
. Instead, use the active verb structure.Using GitLab Duo for [task]
. Instead, focus on the task itself.Tips and tricks
. Instead, incorporate advice into specific examples.Code generation
when you mean something specific like Generate REST API endpoints
.Use these guidelines to assign difficulty levels:
Be specific about which GitLab Duo tools are needed. Common prerequisites include:
Provide realistic time ranges based on complexity:
Expected outcomes should be specific and measurable. For example:
Do: Detailed analysis identifying 3-5 specific improvement areas with code examples
Do not: Analysis of the code
Do: Complete refactored class with improved method names and added tests
Do not: Better code
Always use [descriptive_name]
format for placeholders. Make placeholders specific:
[ClassName]
or [file_path]
or [specific_framework]
[name]
or [thing]
or [item]
Structure prompts with:
Tips should provide:
Avoid generic advice. Be specific about what works for this particular use case.
Verification checklistCreate 3-5 specific, measurable checks that users can perform to validate success. Focus on:
The following topic tried to cover too many different scenarios in one example. It was unclear when to use each approach and the prompts were too generic.
title: Using GitLab Duo for Development Tasks
---
You can use GitLab Duo to help with coding. Here are some ways:
- Generate code
- Fix bugs
- Write tests
- Refactor code
Ask GitLab Duo to help you with your task.
After
The information is clearer when split into a focused prompt example:
title: Refactor legacy code
---
Follow these guidelines when you need to improve performance, readability,
or maintainability of existing code.
- Time estimate: 15-30 minutes
- Level: Intermediate
- Prerequisites: Code file open in IDE, GitLab Duo Chat available
## The challenge
Transform complex, hard-to-maintain code into clean, testable components
without breaking functionality.
## The approach
Analyze, plan, and implement using GitLab Duo Chat and Code Suggestions.
### Step 1: Analyze
Use GitLab Duo Chat to understand the current state. Select the code you want to refactor, then ask:
```plaintext
Analyze the [ClassName] in [file_path]. Focus on:
1. Current methods and their complexity
2. Performance bottlenecks
3. Areas where readability can be improved
4. Potential design patterns that could be applied
Provide specific examples from the code and suggest applicable refactoring patterns.
```
Expected outcome: Detailed analysis with specific improvement suggestions.
## Tips
- Start with analysis before jumping to implementation.
- Select specific code sections when asking Chat for analysis.
- Ask Chat for specific examples from your actual code.
- Reference your existing codebase patterns for consistency.
- Let Code Suggestions help with syntax as you implement Chat's recommendations.
## Verify
Ensure that:
- Generated code follows your team's style guide.
- New structure actually improves the identified issues.
- Tests cover the refactored functionality.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4