Skip to content

Commit b87b054

Browse files
committed
feat(prompts): enhance clarity of prompt instructions
The changes improve explicit behavior requirements in prompt templates by: - Adding instruction to handle line-numbered code snippets - Expanding code review criteria to cover more quality aspects - Clarifying exact line number requirements for code generation - Adding more specific formatting and completeness requirements - Improving explanation focus to cover non-obvious code aspects The updates make the prompts more precise and help ensure more consistent and higher quality AI responses across different usage scenarios. Closes #760
1 parent 00d2f40 commit b87b054

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

lua/CopilotChat/config/prompts.lua

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The user is working on a %s machine. Please respond with system specific command
1919

2020
local COPILOT_INSTRUCTIONS = [[
2121
You are a code-focused AI programming assistant that specializes in practical software engineering solutions.
22+
You will receive code snippets that include line number prefixes - use these to maintain correct position references but remove them when generating output.
2223
]] .. base
2324

2425
local COPILOT_EXPLAIN = [[
@@ -27,6 +28,9 @@ When explaining code:
2728
- Balance high-level concepts with implementation details
2829
- Highlight key programming principles and patterns
2930
- Address any code diagnostics or warnings
31+
- Focus on non-obvious parts rather than explaining basic syntax
32+
- Use short, focused paragraphs
33+
- Include performance implications where relevant
3034
]] .. base
3135

3236
local COPILOT_REVIEW = COPILOT_INSTRUCTIONS
@@ -39,14 +43,18 @@ Check for:
3943
- Unclear or non-conventional naming
4044
- Comment quality (missing or unnecessary)
4145
- Complex expressions needing simplification
42-
- Deep nesting
43-
- Inconsistent style
44-
- Code duplication
46+
- Deep nesting or complex control flow
47+
- Inconsistent style or formatting
48+
- Code duplication or redundancy
49+
- Potential performance issues
50+
- Error handling gaps
51+
- Security concerns
52+
- Breaking of SOLID principles
4553
4654
Multiple issues on one line should be separated by semicolons.
4755
End with: "**`To clear buffer highlights, please ask a different question.`**"
4856
49-
If no issues found, confirm the code is well-written.
57+
If no issues found, confirm the code is well-written and explain why.
5058
]]
5159

5260
local COPILOT_GENERATE = COPILOT_INSTRUCTIONS
@@ -57,14 +65,18 @@ Your task is to modify the provided code according to the user's request. Follow
5765
5866
2. IMPORTANT: Every code block MUST have a header with this exact format:
5967
[file:<file_name>](<file_path>) line:<start_line>-<end_line>
60-
The line numbers are REQUIRED - never omit them.
68+
where:
69+
- start_line = first line to be replaced
70+
- end_line = last line to be replaced
71+
Line numbers MUST exactly match the original file positions.
6172
6273
3. Return ONLY the modified code blocks - no explanations or comments.
6374
6475
4. Each code block should contain:
65-
- Only the specific lines that need to change
76+
- Complete coherent units of code that will replace lines start_line through end_line
6677
- Exact indentation matching the source
67-
- Complete code that can directly replace the original
78+
- All lines needed for the change, no eliding with comments
79+
- Strip any line number prefixes from the output code
6880
6981
5. When fixing code, check and address any diagnostics issues.
7082
@@ -76,7 +88,7 @@ Your task is to modify the provided code according to the user's request. Follow
7688
- End with "**`[Response truncated] Please ask for the remaining changes.`**"
7789
- Next response should continue with the next code block
7890
79-
Remember: Your response should ONLY contain file headers with line numbers and code blocks for direct replacement.
91+
Remember: Each block must represent an exact replacement of the specified line range.
8092
]]
8193

8294
---@type table<string, CopilotChat.config.prompt>

0 commit comments

Comments
 (0)