Logo di Model Guided Code Repair

Model Guided Code Repair

Community
ArabelaTso
model-guided-code-repair

Automatically repair code violations of temporal properties using model-checking counterexamples as guidance. Use when working with formal verification results, temporal logic property violations (LTL, CTL), model checking counterexamples, or when asked to repair property violations, fix counterexamples, repair temporal properties, fix model checking violations, or repair code based on counterexamples. Applicable to concurrent systems, state machines, synchronization issues, safety/liveness properties, and resource management violations.

Panoramica

Pubblicato daArabelaTso
RepositorySkills-4-SE
Nome della skillmodel-guided-code-repair
Stelle
258
Fork
25
File inclusi
1
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 1

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da ArabelaTso su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Model Guided Code Repair in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/model-guided-code-repair
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git /tmp/Skills-4-SE
mkdir -p .claude/skills
cp -r /tmp/Skills-4-SE/skills/model-guided-code-repair .claude/skills/model-guided-code-repair
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Model Guided Code Repair in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Model Guided Code Repair non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Model Guided Code Repair non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Model-Guided Code Repair

Overview

This skill enables automatic repair of code that violates temporal properties by analyzing model-checking counterexamples. It reasons about the root cause of violations at the model level, proposes minimal and semantically justified code modifications, and validates repairs through re-verification or test generation.

Repair Workflow

Follow this sequential process when repairing temporal property violations:

1. Analyze Input

Gather and understand three required inputs:

  • Program source code: The code containing the violation
  • Violated temporal property: The formal specification (LTL, CTL, or natural language description)
  • Counterexample trace: The execution path demonstrating the violation

Read all inputs carefully. If the temporal property is in natural language, formalize it first.

2. Understand the Counterexample

Trace through the counterexample step-by-step:

  • Identify the sequence of states and transitions
  • Map counterexample states to program locations (line numbers, function calls)
  • Identify variable values at each step
  • Pinpoint the exact moment the property is violated

Output: A clear narrative of the execution path leading to the violation.

3. Identify Root Cause

Analyze why the violation occurs:

  • Missing guards: Are conditions missing that should prevent certain transitions?
  • Incorrect ordering: Are operations executed in the wrong sequence?
  • Race conditions: Are there synchronization issues in concurrent code?
  • Missing state updates: Are variables not being updated correctly?
  • Incorrect logic: Are conditional expressions wrong?

Output: A precise diagnosis of the model-level cause.

4. Propose Repair Strategy

Design a minimal repair that:

  • Directly addresses the root cause
  • Preserves intended program behavior
  • Minimizes code changes
  • Maintains code readability

Common repair strategies:

  • Add guards: Insert conditional checks to prevent invalid transitions
  • Reorder operations: Adjust execution sequence to satisfy temporal ordering
  • Add synchronization: Insert locks, semaphores, or barriers for concurrent code
  • Update state management: Fix variable assignments or state transitions
  • Strengthen preconditions: Add assertions or input validation

Output: A clear repair plan with justification.

5. Generate Repaired Code

Implement the repair:

  • Make minimal, targeted changes to the source code
  • Clearly mark what was changed (comments or annotations)
  • Ensure the repair is syntactically correct
  • Preserve existing code style and conventions

Output: Modified source code with changes clearly indicated.

6. Validate the Repair

Verify that the repair resolves the violation:

Option A: Re-run Model Checker

  • Execute the model checker on the repaired code
  • Verify the temporal property now holds
  • Check that no new violations were introduced

Option B: Generate and Run Tests

  • Create test cases based on the counterexample
  • Generate additional tests for edge cases
  • Execute tests and verify they pass
  • Ensure existing tests still pass (regression testing)

Output: Validation results showing the property is satisfied.

7. Document the Repair

Provide a comprehensive explanation:

  • Root cause: What caused the violation
  • Repair strategy: Why this approach was chosen
  • Minimality justification: Why this is the smallest necessary change
  • Behavior preservation: How intended functionality is maintained
  • Validation results: Evidence that the repair works

Output Format

Structure the final output as follows:

## Repaired Code

[Modified source code with changes clearly marked]

## Changes Made

- [Line X]: [Description of change]
- [Line Y]: [Description of change]

## Root Cause Analysis

[Explanation of what caused the violation]

## Repair Strategy

[Why this repair approach was chosen]
[Why it is minimal and semantically justified]

## Behavior Preservation

[How the repair maintains intended program behavior]

## Validation Results

[Model checking results OR test execution results]
[Confirmation that the property now holds]

Common Scenarios

Safety Property Violations

Example: "The system must never enter an error state"

  • Look for missing error checks or exception handling
  • Add guards to prevent invalid state transitions
  • Validate with assertions or model checking

Liveness Property Violations

Example: "Every request must eventually be processed"

  • Look for deadlocks, infinite loops, or missing progress conditions
  • Add fairness constraints or progress guarantees
  • Validate with liveness checking or timeout tests

Synchronization Issues

Example: "Shared resources must be accessed atomically"

  • Look for race conditions or missing locks
  • Add synchronization primitives (mutexes, semaphores)
  • Validate with concurrency testing or model checking

State Machine Violations

Example: "State transitions must follow the specified protocol"

  • Look for missing state checks or incorrect transition logic
  • Add state validation or fix transition conditions
  • Validate with state machine verification

Tips for Effective Repairs

  • Start simple: Try the minimal fix first before complex refactoring
  • Preserve structure: Maintain the original code architecture when possible
  • Consider side effects: Ensure repairs don't break other properties
  • Document assumptions: Note any assumptions made during repair
  • Test thoroughly: Validate beyond just the violated property
  • Iterate if needed: If the first repair doesn't work, analyze why and adjust

Integration with Model Checkers

This skill works with various model checking tools:

  • SPIN: For Promela models and LTL properties
  • NuSMV/nuXmv: For SMV models and CTL/LTL properties
  • CBMC: For C programs with assertions
  • Java PathFinder: For Java programs
  • TLA+: For TLA+ specifications

When counterexamples are provided in tool-specific formats, translate them into a clear execution trace before analysis.

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Model Guided Code Repair?

Automatically repair code violations of temporal properties using model-checking counterexamples as guidance. Use when working with formal verification results, temporal logic property violations (LTL, CTL), model checking counterexamples, or when asked to repair property violations, fix counterexamples, repair temporal properties, fix model checking violations, or repair code based on counterexamples. Applicable to concurrent systems, state machines, synchronization issues, safety/liveness properties, and resource management violations.

Perché usare Model Guided Code Repair su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Model Guided Code Repair è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Model Guided Code Repair in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/model-guided-code-repair. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Model Guided Code Repair?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Model Guided Code Repair?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Model Guided Code Repair: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Model Guided Code Repair è gratuita?

Sì. È pubblicata su GitHub da ArabelaTso con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇