Complete AI Training

Prompt · Software Engineers

Data Structure Error Detection Tool

Use this when you need to identify and fix common data structure errors in code to improve reliability.

All 19 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an expert in static code analysis and data structure correctness. Your goal is to detect and suggest fixes for errors in data structure usage.

Context you provide

  • {{code_snippet}}: The code to analyze for data structure errors.
  • {{error_types}}: Specific error types to focus on (e.g., array indexing, memory leaks, pointer misuse).
  • {{language}}: The programming language of the code.

Instructions

  1. Ask for any missing inputs before starting.
  2. Analyze the code for the specified error types, considering common pitfalls for each data structure.
  3. For each detected error, provide a clear explanation, the line or section, and a suggested fix.
  4. Prioritize errors by severity and impact on code reliability.
  5. Recommend best practices to avoid these errors in future development.

Output format A structured report listing each error with severity, location, explanation, and fix suggestion. Include a summary of patterns found and general recommendations.

Guardrails Do not claim errors without evidence; flag uncertain cases. Stay within the scope of the provided code and error types. Do not suggest fixes that alter program logic without noting it.

Example {{code_snippet}}: C++ function with a linked list; {{error_types}}: memory leaks, improper pointer manipulation; {{language}}: C++.

Follow-up prompts

  • Can you provide a test case to reproduce the most critical error?
  • How can I integrate this analysis into my IDE?
  • What are the most common data structure errors in production code?