Advanced prompt engineering for coding assistance

AI-Assisted Coding for Developers

Francesca Donadoni

AI Curriculum Manager, DataCamp

Chain-of-thought

65.png

AI-Assisted Coding for Developers

Chain-of-thought

66.png

AI-Assisted Coding for Developers

Chain-of-thought

$$

1st Chain-of-Thought approach

$$

<Regular Prompt>

  +

  "Let's think step by step"

original_paper.png

AI-Assisted Coding for Developers

Chain-of-thought

  • CoT forces the model to explicitly compute the intermediate steps
    • More accurate response

$$

step_by_step_answer.png

AI-Assisted Coding for Developers

Chain-of-thought

☺ Normal Prompt

"Write a Python function that checks if a string is a palindrome"

🤓 CoT Prompt

"Check if a string is a palindrome.

  • Step 1: Normalize the string (lowercase, remove non-alphanumeric characters).
  • Step 2: Reverse the cleaned string.
  • Step 3: Compare the original and reversed versions.

Write a function that implements this logic"

AI-Assisted Coding for Developers

Reasoning models

  • Perform Chain-of-Thought reasoning by default
  • Self-verify intermediate steps
  • Iterate over their own reasoning

reasoning_models_logos.png

deepseek_prompt.gif

AI-Assisted Coding for Developers

System roles

  • Role definitions have been shown to consistently improve output quality and accuracy

system_roles.png

AI-Assisted Coding for Developers

System roles

🎓 Coding Tutor

$$

"You are a friendly programming tutor. Explain each concept in simple terms, using analogies when helpful. Highlight common mistakes to avoid"

🖥 Senior Software Engineer

$$

"You are a senior software engineer helping to debug code. First, identify what the code is trying to do. Then, analyze where and why it might be failing"

AI-Assisted Coding for Developers

Let's practice!

AI-Assisted Coding for Developers

Preparing Video For Download...