Advanced Debugging Prompts

Use structured prompts for codebase audits, fragile updates, and performance optimization.

Heavy-duty prompts for deep debugging, system reviews, and optimization scenarios.

Sometimes you need more than a quick fix. These structured prompt templates help you dig into complex problems, audit your codebase, and optimize performance systematically.


Full System Review (Codebase Audit)

If your project has grown large or you suspect there are structural issues, a codebase audit prompt can help. This asks Prototyper to analyze the entire project for cleanliness, architecture, and misplaced code.

Example prompt:

Perform a comprehensive audit of the entire codebase to check if the
architecture is clean, modular, and optimized:

- Identify any files, components, or logic that are in the wrong place
  or could be better organized. Are there any instances of code that
  don't belong in their current file (misplaced logic)?
- Evaluate if we have a clear separation of concerns (e.g., data handling
  vs UI vs state management). Point out any overly coupled sections of code.
- Highlight any areas of the code that are overly complex or not following
  best practices.
- Provide a report with specific recommendations to improve structure and
  maintainability, without making any code changes yet.

Break down the suggestions into an ordered list of steps we could take,
from most critical to optional enhancements.

(This is a read-only analysis; do not modify the code during this audit.)

The AI might respond with something like:

  1. Separate API calls from components: The ProjectList component is directly fetching data. Suggestion: move data fetching to a dedicated hook or context.
  2. Reduce coupling in Task logic: The task completion toggle is updating both state and directly writing to localStorage. Refactor to have a single source of truth.
  3. Organize utility functions: There are utility functions in App.tsx that would be better placed in a utils folder.

Safe Approach for Fragile Updates

When changing delicate areas (authentication flows, payment processing, core algorithms), prepend a cautionary guideline to prevent bugs.

Example prompt:

The next change is in a critical part of the app, so proceed with utmost caution.

- Carefully examine all related code and dependencies before making changes.
- Avoid any modifications to unrelated components or files.
- If there's any uncertainty, pause and explain your thought process before
  continuing.
- Ensure thorough testing after the change to confirm nothing else is affected.

Task: Update the user authentication logic to support OAuth login via Google,
on top of existing email/password without breaking either flow.

(Be extremely careful and double-check each step during implementation.)

Use this strategy for fragile sections: authentication, payment processing, data migration—anything where a small mistake can break a lot.


Performance Optimization Check

If your app works correctly but is slow or resource-heavy, use this prompt to analyze performance.

Example prompt:

Our app is functional but seems sluggish. Please analyze the project for
performance bottlenecks and suggest optimizations:

- Check for any unnecessary database or network calls (e.g., duplicate
  fetches or N+1 query patterns).
- Identify components that might be re-rendering too often or doing heavy
  work on the main thread.
- Look at our use of assets (images, scripts): are there any large bundles
  or unoptimized assets affecting load time?
- Suggest improvements like caching frequently used data, using React memo
  or lazy loading where appropriate, and any other ways to speed up the app.

Provide the analysis and recommendations in a list. Do not make code changes
yet – just tell us what to improve for better performance.

Handling Persistent Errors

When errors keep coming back in slight variations, the root cause isn't being addressed. Here's a strategy:

  1. Ask what's been tried: Use: "What solutions have we tried so far for this error?" This helps avoid repeating the same fixes.

  2. Get a simple explanation: "Explain in simple terms why this error occurs." This reveals if the problem is truly understood.

  3. Consider alternatives: Ask: "Given this error keeps happening, can we try a different approach to achieve the goal?"

  4. Revert and replay: In worst cases, roll back a few steps, then proceed with smaller changes.


Root Cause vs. Symptom

Always ask "why did this happen?" not just "what to do now?" Finding the root cause means fixes stay fixed.

Example:

I see you fixed the null pointer error by adding a check, but why was it null in the first place? Can we address that cause?


Rollback Strategy

Don't hesitate to roll back if code has become tangled by a series of bad fixes. It's often faster to rewind and try a different approach.

Communicate the rollback:

I reverted the project to before the notifications feature. Let's implement it again, but more carefully this time.