Logo: Loop Detection

Loop Detection

Communautéit
Omar-Obando
loop-detection

Use when identifying and preventing infinite loops, detecting loop patterns, implementing loop exit strategies, and creating loop safety mechanisms. Includes loop analysis, timeout patterns, and loop monitoring. Based on programming best practices and loop safety patterns.

Iwwersiicht

EditeurOmar-Obando
Repositoryqwen-orchestrator
Skill-Nummloop-detection
Stären
53
Forks
13
Matgeliwwert Dateien
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Omar-Obando huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Loop Detection an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/loop-detection
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/loop-detection .claude/skills/loop-detection
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Loop Detection an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Loop Detection automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Loop Detection net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Loop Detection Skill — Monitor & Loop Guardian

Overview

This skill provides comprehensive guidance for detecting and preventing infinite loops. It covers loop pattern identification, exit strategy implementation, timeout patterns, and loop monitoring following programming best practices and loop safety patterns.

When to Use

Use this skill when:

  • Identifying potential infinite loops in code
  • Detecting loop patterns in algorithms
  • Implementing loop exit strategies
  • Adding timeout mechanisms to loops
  • Creating loop safety guards
  • Analyzing loop termination conditions
  • Implementing loop counters
  • Creating loop monitoring
  • Detecting loop stagnation
  • Implementing loop backoff strategies
  • Creating loop retry mechanisms
  • Adding loop progress tracking
  • Implementing loop cancellation
  • Creating loop documentation
  • Analyzing loop performance
  • Detecting loop resource leaks
  • Implementing loop limits
  • Creating loop validation
  • Detecting loop edge cases
  • Implementing loop error handling
  • Creating loop optimization strategies
  • Adding loop logging
  • Implementing loop health checks

Do NOT use this skill when:

  • Writing application business logic (use domain-driven skill)
  • Designing database schemas (use database-design skill)
  • Writing API endpoint specifications (use api-design skill)
  • Performing security audits (use security-auditor skill)
  • Writing SQL queries (use sql-best-practices skill)
  • Designing multi-page website layouts (use design-system skill)
  • Analyzing deployment configurations (use deployment skill)
  • Writing documentation (use documentation-best-practices skill)

Loop Patterns

Common Loop Patterns

┌─────────────────────────────────────────────────────────────┐
│              Loop Patterns                                  │
├─────────────────────────────────────────────────────────────┤
│  While Loop:                                                │
│  while condition:                                           │
│      # Loop body                                            │
│      # Must modify condition                                │
│                                                              │
│  For Loop:                                                  │
│  for i in range(n):                                         │
│      # Loop body                                            │
│      # Uses counter or iterator                             │
│                                                              │
│  Do-While Loop:                                             │
│  do {                                                       │
│      # Loop body                                            │
│  } while (condition);                                       │
│                                                              │
│  Nested Loop:                                               │
│  for i in range(n):                                         │
│      for j in range(m):                                     │
│          # Nested loop body                                 │
│                                                              │
│  Infinite Loop:                                             │
│  while true:                                                │
│      # Must have break condition                            │
│      if exit_condition:                                     │
│          break                                              │
└─────────────────────────────────────────────────────────────┘

Loop Exit Strategies

┌─────────────────────────────────────────────────────────────┐
│              Loop Exit Strategies                           │
├─────────────────────────────────────────────────────────────┤
│  1. Counter-Based:                                          │
│     for i in range(max_iterations):                         │
│         if condition:                                       │
│             break                                           │
│                                                              │
│  2. Condition-Based:                                        │
│     while not done:                                         │
│         if success:                                         │
│             done = True                                     │
│                                                              │
│  3. Timeout-Based:                                          │
│     start_time = time.now()                                 │
│     while time.now() - start_time < timeout:                │
│         if condition:                                       │
│             break                                           │
│                                                              │
│  4. State-Based:                                            │
│     while state != 'completed':                             │
│         state = update_state(state)                         │
│                                                              │
│  5. Resource-Based:                                         │
│     while resources_available():                            │
│         process_resource()                                  │
└─────────────────────────────────────────────────────────────┘

Loop Safety Mechanisms

Timeout Pattern

python
# ✅ Good: Timeout-based loop
import time

def process_with_timeout(max_duration=30):
    start_time = time.time()
    while not task_completed():
        if time.time() - start_time > max_duration:
            raise TimeoutError("Loop timed out")
        time.sleep(0.1)

Counter Pattern

python
# ✅ Good: Counter-based loop
def process_with_max_iterations(max_iterations=1000):
    count = 0
    while not task_completed():
        if count >= max_iterations:
            raise RuntimeError("Max iterations reached")
        count += 1
        process_iteration()

Backoff Pattern

python
# ✅ Good: Exponential backoff
import time

def retry_with_backoff(max_retries=5, base_delay=1):
    for attempt in range(max_retries):
        try:
            return perform_task()
        except Exception as e:
            if attempt == max_retries - 1:
                raise
            delay = base_delay * (2 ** attempt)
            time.sleep(delay)

Loop Detection Techniques

Static Analysis

┌─────────────────────────────────────────────────────────────┐
│              Static Analysis                                │
├─────────────────────────────────────────────────────────────┤
│  Check for:                                                 │
│  - Missing loop termination condition                       │
│  - Loop variable not updated                                │
│  - Condition always true                                    │
│  - No break statements                                      │
│  - Infinite recursion in loops                              │
│                                                              │
│  Tools:                                                     │
│  - Linters (ESLint, Pylint)                                 │
│  - Static analysis tools (SonarQube)                        │
│  - IDE warnings                                             │
└─────────────────────────────────────────────────────────────┘

Dynamic Analysis

┌─────────────────────────────────────────────────────────────┐
│              Dynamic Analysis                               │
├─────────────────────────────────────────────────────────────┤
│  Monitor at runtime:                                        │
│  - Loop iteration count                                     │
│  - Execution time                                           │
│  - Resource usage                                           │
│  - State changes                                            │
│                                                              │
│  Techniques:                                                │
│  - Add counters to loops                                    │
│  - Log loop progress                                        │
│  - Monitor memory usage                                     │
│  - Track execution time                                     │
└─────────────────────────────────────────────────────────────┘

Loop Health Monitoring

┌─────────────────────────────────────────────────────────────┐
│              Loop Health Monitoring                         │
├─────────────────────────────────────────────────────────────┤
│  Metrics:                                                   │
│  - Iteration count                                          │
│  - Duration per iteration                                   │
│  - Total loop duration                                      │
│  - Memory usage per iteration                               │
│  - CPU usage per iteration                                  │
│                                                              │
│  Alerts:                                                    │
│  - Iteration limit exceeded                                 │
│  - Duration threshold exceeded                              │
│  - Resource usage spike                                     │
│  - No progress detected                                     │
└─────────────────────────────────────────────────────────────┘

Loop Best Practices

Loop Design Checklist

┌─────────────────────────────────────────────────────────────┐
│              Loop Design Checklist                          │
├─────────────────────────────────────────────────────────────┤
│  [ ] Loop has clear termination condition                   │
│  [ ] Loop variable is properly updated                      │
│  [ ] Loop has timeout mechanism                             │
│  [ ] Loop has max iteration limit                           │
│  [ ] Loop handles edge cases                                │
│  [ ] Loop has error handling                                │
│  [ ] Loop has progress logging                              │
│  [ ] Loop has cancellation support                          │
│  [ ] Loop has resource cleanup                              │
│  [ ] Loop has documentation                                 │
└─────────────────────────────────────────────────────────────┘

Loop Documentation Template

python
def process_items(items, max_iterations=1000, timeout=30):
    """
    Process items with safety mechanisms.

    Args:
        items: List of items to process
        max_iterations: Maximum number of iterations (default: 1000)
        timeout: Maximum duration in seconds (default: 30)

    Returns:
        Processed items list

    Raises:
        RuntimeError: If max iterations reached
        TimeoutError: If timeout exceeded
    """
    start_time = time.time()
    count = 0

    for item in items:
        count += 1
        if count >= max_iterations:
            raise RuntimeError("Max iterations reached")
        if time.time() - start_time > timeout:
            raise TimeoutError("Loop timed out")

        # Process item
        process(item)

    return items

Real-World Impact

Before this skill:

  • Infinite loops causing crashes
  • Resource exhaustion
  • No loop monitoring
  • Difficult debugging
  • Production outages

After this skill:

  • Safe loops with exit strategies
  • Proper resource management
  • Loop monitoring and alerts
  • Easy debugging
  • Production stability

Cross-References

  • debugging - For loop debugging
  • performance - For loop optimization
  • testing-strategy - For loop testing

References

Heefeg gestallte Froen

Wat mécht de KI-Skill Loop Detection?

Use when identifying and preventing infinite loops, detecting loop patterns, implementing loop exit strategies, and creating loop safety mechanisms. Includes loop analysis, timeout patterns, and loop monitoring. Based on programming best practices and loop safety patterns.

Firwat Loop Detection op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Loop Detection besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Loop Detection an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/loop-detection an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Loop Detection benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Loop Detection benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Loop Detection domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Loop Detection gratis?

Jo. Omar-Obando huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇