Skip to content

Prompt Engineering Tips

Prompt engineering is the core methodology for crafting effective instructions for AI models such as VJSP. Well-written prompts can enhance output quality, reduce error rates, and optimize overall workflows.

General Principles

  • Clarity and Specificity

    Clearly articulate your request to avoid ambiguity.

    • Negative Example: Fix this code.

    • Positive Example: Fix the bug in the calculateTotal function that causes incorrect return values.

  • Provide Context

    Use context referencing to specify exact files, folders, or issues to address.

    • Positive Example: @/src/utils.ts Refactor the calculateTotal function using async/await syntax.
  • Task Decomposition

    Break complex tasks into smaller, well-defined subtasks.

  • Example Guidance

    If a specific coding style or design pattern is required, include a reference example in your prompt.

  • Specify Output Format

    If a particular format (e.g., JSON, Markdown) is needed, explicitly state it in the prompt.

  • Iterative Refinement

    If the initial output does not meet expectations, feel free to refine and improve the prompt wording.

Think First, Act Later

Guiding VJSP to follow a “Think First, Act Later” workflow often improves task completion quality:

  1. Analysis Phase

    Ask VJSP to analyze existing code, identify problem areas, or outline an overall solution strategy.

  2. Planning Phase

    Have VJSP list concrete steps required to complete the task.

  3. Execution Phase

    Instruct VJSP to implement the solution step by step according to the plan.

  4. Review Phase

    After completing each step, rigorously review the output before proceeding to the next step.

Using Custom Instructions

Custom instructions can further tailor VJSP’s behavior. There are two types:

  • Global Custom Instructions

    Apply across all functional modes.

  • Mode-Specific Custom Instructions

    Apply only to specific functional modes (e.g., coding mode, architecture design mode, Q&A mode, debugging mode, or custom mode).

Custom instructions are integrated into the system prompt, providing continuous guidance to the model. They can be used to:

  • Enforce coding style standards
  • Specify preferred libraries or frameworks
  • Define project-specific development conventions
  • Adjust VJSP’s output tone or interaction style

For more details, refer to the Custom Instructions section.

Handling Ambiguity

When a prompt contains ambiguity or missing information, VJSP may respond in one of two ways:

  • Autonomous Inference

    Make its best guess based on existing knowledge, though the result may not align with actual requirements.

  • Ask Clarifying Questions

    Use the ask_followup_question tool to request clarification from the user.

To minimize unnecessary communication overhead, provide clear and specific instructions from the outset.

Leveraging Feedback Mechanisms

If VJSP’s output does not meet expectations, use the following feedback methods:

  1. Reject the Proposed Action

    Click the “Reject” button when VJSP suggests an action that doesn’t match your needs.

  2. Explain the Rejection Reason

    When rejecting, provide a clear explanation to help the model learn from mistakes.

  3. Reword the Request

    Try rephrasing the original task or adding more specific instructions.

  4. Manually Edit the Output

    If only minor issues exist, directly edit the generated content before confirming acceptance.

Example Comparison

CategoryPositive ExampleNegative Example
Code Refactoring@/src/components/Button.tsx Refactor the Button component to replace the useReducer hook with the useState hookFix this button component
File CreationCreate a new file utils.py and implement a calculate_average function that takes a list of numbers and returns their averageWrite some Python code
Bug Fixing@problems Fix all errors and warnings in the current fileFix all the problems

By following these techniques, you can write highly effective prompts and fully leverage VJSP’s capabilities.