Skip to content

Prompt System

MyDeskBot's prompt system is the core component responsible for generating and managing prompts that interact with AI models.

Prompt Principles

What is a Prompt

A Prompt is the input text that interacts with an AI model, which:

  • 📝 Defines Tasks - Clearly tells the AI what to do
  • 🎯 Provides Context - Gives the AI enough background information
  • 📋 Specifies Format - Defines the output format and structure
  • ⚙️ Sets Constraints - Limits the AI's behavior and output

Prompt Structure

MyDeskBot's prompts typically include:

  1. System Prompt

    • Defines the AI's role and goals
    • Sets behavioral guidelines
    • Specifies response style
  2. User Prompt

    • User's specific request
    • Relevant context information
    • Input data
  3. Auxiliary Information

    • Examples (Few-shot)
    • Constraints
    • Output format

Built-in Prompts

Code Completion

You are a code completion assistant. Complete the code snippet based on the provided context. Maintain consistent code style and follow best practices.

Context: [Relevant code, files]

Code to complete: [Selected code]

Completed code: :::

Code Review

You are a professional code review expert. Review the following code and identify issues and improvement suggestions.

Review criteria:

  1. Code quality: readability, maintainability
  2. Potential issues: bugs, security vulnerabilities
  3. Performance: performance optimization opportunities
  4. Best practices: follow industry best practices

Code: [Code snippet]

Please output in the following format: 🔴 Critical issues 🟡 Moderate issues 🟢 Improvement suggestions ✅ Good practices

Code Refactoring

You are a code refactoring expert. Refactor the following code to improve readability, maintainability, and performance.

Refactoring principles:

  1. Maintain functionality unchanged
  2. Improve code quality
  3. Follow SOLID principles
  4. Add necessary comments

Original code: [Code snippet]

Refactored code: [Refactored code]

Refactoring explanation: [Explanation of refactoring]

Documentation Generation

You are a technical documentation writing expert. Generate clear documentation for the following code.

Documentation requirements:

  1. Include function/class purpose description
  2. Parameter descriptions (type, meaning)
  3. Return value description
  4. Usage examples
  5. Notes and considerations

Code: [Code snippet]

Generated documentation:

Custom Prompts

Prompt Formats

MyDeskBot prompts support two variable formats:

V1 Format (Traditional)

Uses Handlebars template syntax, variables are wrapped in three curly braces:

{{{ input }}}
{{{ @currentFile }}}
{{{ @codebase }}}

V1 format requires explicit specification of user input with {{{ input }}}.

Use the @ symbol to reference context providers, more concise and intuitive:

@currentFile
@codebase
@file

V2 format automatically appends user input to the end of the prompt, no manual specification required.

This document uses V2 format for all examples.

Format Recognition Rules

MyDeskBot automatically recognizes prompt formats through the following rules:

  1. Recognized as V1 format if the prompt contains {{{ input }}}
  2. Otherwise recognized as V2 format

If a prompt contains both {{{ input }}} and @variable, it will be recognized as V1 format. In this case, @variable must be wrapped with {{{ }}} to be rendered.

Therefore, in practice, you should not mix the two formats. Choose one uniformly.

Prompt Variables

Prompts use the @ symbol to reference context providers:

ProviderDescription
@fileReference specific file
@urlReference URL content
@clipboardClipboard content
@repo-mapRepository map
@currentFileCurrent file
@osOperating system info
@problemsProblem list
@codebaseCodebase content
@treeFile tree
@openOpen files
@debuggerDebug info
@terminalTerminal output
@diffDiff content

Creating Custom Prompts

You can create custom prompts in two ways:

Method 1: Configuration File

Define prompts in your config.yaml:

yaml
# ~/.mydeskbot/config.yaml
prompts:
  - name: "My Custom Prompt"
    description: "Prompt for specific tasks"
    prompt: |
      You are a professional developer assistant

      Current file:

      @currentFile

Method 2: Prompt File

Create a separate prompt file in ~/.mydeskbot/prompts/:

yaml
# ~/.mydeskbot/prompts/code-review.prompt
name: "Code Review"
description: "Review code quality, security, and performance"
prompt: |
  You are a senior code review engineer, focused on code quality, security, and performance.

  Review the following code:

  @currentFile

  Output format:
  1. List of issues
  2. Severity level
  3. Fix suggestions

When using a prompt file, it will be automatically converted to an available slash command.

Using Custom Prompts

Type / in the chat input box to trigger slash commands, then select your defined prompt:

/prompt-name

You can also type the prompt name directly after the / to use it.

Advanced Techniques

Few-shot Learning

Provide examples to improve results:

You are a code conversion assistant. Convert JavaScript code to TypeScript.

Example 1: Input:

javascript
function greet(name) {
  return "Hello " + name;
}

Output:

typescript
function greet(name: string): string {
  return "Hello " + name;
}

Example 2: Input:

javascript
const users = [
  { name: "Alice", age: 25 },
  { name: "Bob", age: 30 },
];

Output:

typescript
interface User {
  name: string;
  age: number;
}

const users: User[] = [
  { name: "Alice", age: 25 },
  { name: "Bob", age: 30 },
];

Now convert the following code: Input:

javascript
{
  code;
}

Output:

typescript

Chain of Thought

Guide AI to reason step by step:

You are a problem-solving expert. Please think step by step and solve the problem.

Problem: Specific problem description

Please think through the following steps:

  1. Understand the problem
  2. Analyze requirements
  3. Design solution
  4. Implement solution
  5. Verify results

Step 1: Understand the problem AI's thought process

Step 2: Analyze requirements ...

Final answer:

Self-Correction

Ask AI to check and improve:

You are a code review expert.

Task:

  1. Generate code
  2. Review the generated code
  3. If there are issues, fix the code
  4. Review again

Original request: User's request

Step 1: Generate code AI generates code

Step 2: Review code AI reviews its own code

Step 3: Fix code (if needed) AI fixes code

Final code:

Best Practices

1. Clear Instructions

Good prompt:

Create a Python function that calculates the number of working days between two dates (excluding weekends and holidays). Function signature: def count_workdays(start_date: date, end_date: date) -> int

Bad prompt:

Write a function to calculate dates

2. Provide Context

With context:

This is a Django view function that handles user registration. Current issues with the code:

  1. No email format validation
  2. Password is not encrypted before storage

Please improve this function.

Code:

python
Actual code content

Without context:

Improve this function

3. Specify Format

With format specified:

Explain the following concept using this format:

  1. Definition
  2. Example code
  3. Use cases
  4. Notes and considerations

Concept: JavaScript closure

Without format specified:

Explain closures

4. Set Constraints

With constraints:

Generate a quicksort algorithm. Constraints:

  • Language: Python
  • Code lines: Not more than 20 lines
  • Add detailed comments
  • Include usage examples