Infinite Loop Detector

Find and fix infinite loops causing application hangs

6/11/2026
Prompt
My application appears to be stuck in an infinite loop. Help me identify and fix it.

**Code section that hangs:**
```{{LANGUAGE}}
{{CODE}}
```

**Programming Language:** {{LANGUAGE}}
**Loop type:** {{LOOP_TYPE}}
**Expected termination condition:** {{EXPECTED_TERMINATION}}
**Inputs that cause the hang:** {{INPUTS}}

Please provide:
1. **Loop Analysis**: Identify why the termination condition is never met
2. **Variable Tracking**: Show how loop variables change (or don't)
3. **Edge Cases**: Identify inputs that cause infinite iteration
4. **Fixed Code**: Provide corrected loop with proper termination
5. **Guard Conditions**: Add safeguards to prevent infinite loops
6. **Timeout Mechanisms**: Suggest timeout patterns if appropriate
7. **Testing Strategy**: Tests to catch infinite loop conditions

Or press ⌘C to copy

Variables (5)

Replace these placeholders with your own content before using the prompt.

[{LANGUAGE][{CODE][{LOOP_TYPE][{EXPECTED_TERMINATION][{INPUTS]

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...