> ## Documentation Index
> Fetch the complete documentation index at: https://potpieai-feat-cli-setup.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Trace and Fix Bugs

In this tutorial, you'll learn how to use Debug in Potpie to trace a reported issue to its origin in the knowledge graph and get a fix at the source, not a symptom patch.

To understand how Debug works, see the [Debug mode page](/build-flow/debug-an-issue).

<Steps>
  <Step title="Describe the issue">
    Paste an error message, stack trace, or describe the unexpected behavior. Include any context about when it occurs.

    <img src="https://mintcdn.com/potpieai-feat-cli-setup/RjcDtgma2Y5eRJIQ/images/agent-debug.png?fit=max&auto=format&n=RjcDtgma2Y5eRJIQ&q=85&s=cad5d2cb2fea6ea26fe961bf035e28a7" alt="Describing the issue" width="1438" height="815" data-path="images/agent-debug.png" />

    <Tip>
      Follow up messages within the same session retain full context. Start with a high-level symptom and narrow to the root cause across subsequent turns.
    </Tip>
  </Step>

  <Step title="Bug analysis">
    The **Debug Agent** applies its **eight step methodology** automatically: validating the behavior, traversing code paths, pinning the **root cause**, and generating a targeted fix.

    <img src="https://mintcdn.com/potpieai-feat-cli-setup/RjcDtgma2Y5eRJIQ/images/debug-chat.png?fit=max&auto=format&n=RjcDtgma2Y5eRJIQ&q=85&s=e3b97b0cd44af0723eceb4c8313ce482" alt="Bug analysis and targeted fix" width="2936" height="1664" data-path="images/debug-chat.png" />
  </Step>
</Steps>
