Agent skill

Tlaplus Guided Code Repair

by ArabelaTso in ArabelaTso/Skills-4-SE

Automatically repair C/C++ code violations detected by TLA+ model checking.

Apache-2.0Auto-check passed

Install Tlaplus Guided Code Repair

skills CLI
$ npx skills add ArabelaTso/Skills-4-SE --skill tlaplus-guided-code-repair -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ArabelaTso/Skills-4-SE tlaplus-guided-code-repair --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/tlaplus-guided-code-repair .claude/skills/tlaplus-guided-code-repair && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
tlaplus-guided-code-repair
GitHub stars
253
Token cost
~1.5k tokens
SKILL.md length
411 words
Files
5 (incl. scripts, references)
Skills in repo
150
Repo updated
First seen
Licence
Apache-2.0

At a glance

Automatically repair C/C++ code violations detected by TLA+ model checking.

  • Works in 6 steps: Parse the Counterexample → Analyze the Violation → Identify the Root Cause → …
  • TLC model checker reports an invariant violation
  • SKILL.md covers Repair Workflow and Quick Reference
  • Runs Python scripts from its folder; calls python and make

What it does

Tlaplus Guided Code Repair is an agent skill from ArabelaTso/Skills-4-SE. Automatically repair C/C++ code violations detected by TLA+ model checking. Takes a program, TLA+ specification, and TLC counterexample trace as input, then generates minimal code modifications to eliminate the violation. Use when: (1) TLC model checker reports an invariant violation, deadlock, or temporal property failure, (2) You have a counterexample trace and need to fix the corresponding code, (3) You need to understand how a TLA+ violation maps to program-level bugs, (4) You want to validate repairs by…

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts and reference files (for example `references/repair_patterns.md`, `references/tlaplus_to_cpp_mapping.md` and `scripts/parse_tlc_trace.py`).

It works with C++. The repository describes itself as: A curated list of 180+ useful Claude Skills for Software Engineering and resources for customizing AI for SE workflows. The licence is Apache-2.0.

When your agent uses it

  • TLC model checker reports an invariant violation
  • Temporal property failure
  • You have a counterexample trace and need to fix the corresponding code
  • You need to understand how a TLA+ violation maps to program-level bugs

Example prompts

  • “/tlaplus-guided-code-repair”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Parse the Counterexample
  2. Analyze the Violation
  3. Identify the Root Cause
  4. Generate the Repair
  5. Validate the Repair
  6. Explain the Repair

What it can do on your machine

Read from SKILL.md and the folder at commit 4f38503. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • make

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Tlaplus Guided Code Repair loads about 1.5k tokens when it runs, and up to ~4.7k if it reads all its reference files. Until then it costs about 165 tokens; SKILL.md has 411 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~165
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.7k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from ArabelaTso/Skills-4-SE at commit 4f38503, republished under its Apache-2.0 licence (© ArabelaTso). 411 words, ~1,488 tokens.

Download SKILL.mdSave it as .claude/skills/tlaplus-guided-code-repair/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
tlaplus-guided-code-repair
description
Automatically repair C/C++ code violations detected by TLA+ model checking. Takes a program, TLA+ specification, and TLC counterexample trace as input, then generates minimal code modifications to eliminate the violation. Use when: (1) TLC model checker reports an invariant violation, deadlock, or temporal property failure, (2) You have a counterexample trace and need to fix the corresponding code, (3) You need to understand how a TLA+ violation maps to program-level bugs, (4) You want to validate repairs by re-running TLC. Supports safety properties (invariants), liveness properties (temporal logic), and deadlock detection.

TLA+ Guided Code Repair

Automatically repair C/C++ code based on TLA+ model checking violations. This skill analyzes TLC counterexamples, identifies root causes in the implementation, and generates semantically justified repairs.

Repair Workflow

Follow this sequential process when given a TLA+ violation:

1. Parse the Counterexample

Use scripts/parse_tlc_trace.py to extract structured information from TLC output:

bash
python scripts/parse_tlc_trace.py trace.txt
# Or for JSON output:
python scripts/parse_tlc_trace.py --json trace.txt

This extracts:

  • Violation type (invariant, deadlock, temporal)
  • Violated property name
  • State trace with variable values at each step
2. Analyze the Violation

Read the reference guides to understand the violation:

  • references/repair_patterns.md - Common violations and repair strategies
  • references/tlaplus_to_cpp_mapping.md - How to map TLA+ to C/C++ code

Key analysis steps:

  1. Identify which invariant/property was violated
  2. Examine the state trace to find where the violation occurred
  3. Determine which TLA+ action led to the violation
  4. Map the TLA+ action to the corresponding C/C++ function

Example analysis:

Violation: Invariant BalanceNonNegative violated
Final state: balance = -50
Action: Withdraw (line 45 in spec)
Cause: withdraw() function allows amount > balance
3. Identify the Root Cause

Trace backwards from the violation to find the program-level bug:

Common root causes:

  • Missing precondition checks (guards)
  • Race conditions (missing synchronization)
  • Incorrect lock ordering (deadlocks)
  • Uninitialized variables
  • Missing notifications (liveness violations)

Mapping strategy:

  • TLA+ guards → C++ precondition checks
  • TLA+ atomic actions → C++ critical sections
  • TLA+ state variables → C++ member variables/globals
  • TLA+ action sequences → C++ function call chains
4. Generate the Repair

Create a minimal, semantically justified code modification:

Repair principles:

  • Minimal: Change only what's necessary to fix the violation
  • Justified: Every change should enforce a specific TLA+ property
  • Preserving: Don't break existing functionality

Common repair patterns:

Pattern A: Add precondition check

cpp
// Before
void withdraw(int amount) {
    balance -= amount;  // Can violate balance >= 0
}

// After - enforces invariant: balance >= 0
bool withdraw(int amount) {
    if (amount > balance) return false;  // Guard from TLA+ spec
    balance -= amount;
    return true;
}

Pattern B: Add synchronization

cpp
// Before - race condition
void increment() {
    counter++;
}

// After - enforces atomic action from TLA+ spec
void increment() {
    std::lock_guard<std::mutex> lock(mtx);
    counter++;
}

Pattern C: Fix lock ordering

cpp
// Before - potential deadlock
void transfer(Account& from, Account& to, int amount) {
    std::lock_guard<std::mutex> lock1(from.mtx);
    std::lock_guard<std::mutex> lock2(to.mtx);
    // ...
}

// After - consistent ordering prevents deadlock
void transfer(Account& from, Account& to, int amount) {
    Account* first = &from < &to ? &from : &to;
    Account* second = &from < &to ? &to : &from;
    std::lock_guard<std::mutex> lock1(first->mtx);
    std::lock_guard<std::mutex> lock2(second->mtx);
    // ...
}
Show full SKILL.md (157 more words)Show less
5. Validate the Repair

Re-run TLC model checker to verify the violation is fixed:

bash
python scripts/run_tlc.py spec.tla --config spec.cfg

Run existing tests to ensure no regressions:

bash
# Run your test suite
make test
# or
./run_tests.sh

Validation checklist:

  • TLC passes without violations
  • All existing tests still pass
  • The repair addresses the root cause (not just symptoms)
  • No new violations introduced
6. Explain the Repair

Provide a clear explanation of:

  1. What was violated: Which TLA+ property failed
  2. Why it failed: The root cause in the C++ code
  3. How the repair fixes it: What the code change enforces
  4. Validation results: TLC output and test results

Example explanation:

Violation: Invariant BalanceNonNegative (balance >= 0) was violated.

Root Cause: The withdraw() function at line 45 in account.cpp did not check
if the withdrawal amount exceeds the current balance, allowing negative balances.

Repair: Added precondition check `if (amount > balance) return false;` before
the balance update. This enforces the TLA+ guard condition from the Withdraw
action in the specification.

Validation: TLC model checking now passes with no violations. All 15 existing
unit tests pass. The repair is minimal and preserves existing functionality.

Quick Reference

When you receive:

  • TLC trace output → Use parse_tlc_trace.py to extract violation info
  • Invariant violation → Check repair_patterns.md section 1
  • Deadlock → Check repair_patterns.md section 2
  • Temporal property violation → Check repair_patterns.md section 3
  • Need to map TLA+ to C++ → Read tlaplus_to_cpp_mapping.md

Output format:

  1. Repaired C++ code (with comments explaining changes)
  2. Validation results (TLC output, test results)
  3. Explanation (violation → cause → repair → justification)

© ArabelaTso, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (scripts, references) in skills/tlaplus-guided-code-repair of ArabelaTso/Skills-4-SE.

  • SKILL.md
  • references/repair_patterns.md
  • references/tlaplus_to_cpp_mapping.md
  • scripts/parse_tlc_trace.py
  • scripts/run_tlc.py

Open the folder on GitHubat commit 4f38503

Compare with similar skills

Tlaplus Guided Code Repair next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Tlaplus Guided Code Repair compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Tlaplus Guided Code Repair this skillArabelaTso/Skills-4-SE253—~1.5kAutomated safety check: PassApache-2.0
Paddle BuildPaddlePaddle/Paddle24k—~1kAutomated safety check: PassApache-2.0
Fory Releaseapache/fory4.6k—~2.9kAutomated safety check: PassApache-2.0
ONNX Runtime Shape Inference Safety Auditmicrosoft/onnxruntime22k—~3.3kAutomated safety check: PassMIT
Code Audit3stoneBrother/code-audit8931 repos~2.7kAutomated safety check: PassNone
Qt C++ Code Reviewx-tools-author/x-tools1.1k2 repos~4.3kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Paddle Build

    PaddlePaddle/Paddle

    A skill your agent uses when needing to compile, rebuild, or install Paddle from source after code changes.

    24k GitHub stars~1k tokensUpdated 8 days ago
    AI & LLM EngineeringAuto-check passed
  • Fory Release

    apache/fory

    Prepare an Apache Fory release candidate from a clean release branch, including the version bump, RC tag, JVM staging, ASF source artifacts, SVN upload, and vote email.

    4.6k GitHub stars~2.9k tokensUpdated yesterday
    Auto-check passed
  • Official

    Finds and fixes out-of-range output writes in ONNX Runtime operator shape-inference functions where a getNumOutputs guard admits too few outputs.

    22k GitHub stars~3.3k tokensUpdated today
    SecurityAuto-check passed
  • Code Audit

    3stoneBrother/code-audit

    Professional code security audit skill covering 55+ vulnerability types.

    893 GitHub starsUsed in 1 repo~2.7k tokens
    SecurityAuto-check passed
  • Qt C++ Code Review

    x-tools-author/x-tools

    Read-only review of Qt6 C++ code that combines a deterministic lint script with six parallel analysis agents and reports only high-confidence issues.

    1.1k GitHub starsUsed in 2 repos~4.3k tokens
    DevelopmentAuto-check passed
  • Translation

    doxygen/doxygen

    Keeps all Doxygen and Doxywizard translations up to date across three mechanisms: translator C++ classes (src/translatorxx.h), Qt .ts locale files for the Doxywizard GUI (addon/doxywizard/i18n/)…

    6.6k GitHub stars~5.2k tokensUpdated 8 days ago
    Writing & ContentAuto-check passed

More from ArabelaTso/Skills-4-SE

All 150 skills in this repo
  • Framework Migration Assistant

    ArabelaTso/Skills-4-SE

    Automatically migrate Python web applications between frameworks (Flask → FastAPI, Django → FastAPI).

    253 GitHub stars~1.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Metamorphic Test Generator

    ArabelaTso/Skills-4-SE

    Generate test cases using metamorphic testing by applying transformations based on metamorphic properties.

    253 GitHub stars~798 tokensUpdated 1 mo ago
    Auto-check passed
  • Reproduction Trace Instrumenter

    ArabelaTso/Skills-4-SE

    Instruments programs to capture execution traces specifically for reproducing reported bugs, enabling consistent replay and diagnosis of failures.

    253 GitHub stars~2.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Spring Mvc To Boot Migrator

    ArabelaTso/Skills-4-SE

    Automatically migrate Spring MVC applications to Spring Boot.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • State Snapshot Instrumenter

    ArabelaTso/Skills-4-SE

    Instrument programs (Python, C/C++, Java) to capture snapshots of key program states at runtime, including variables, memory, and call stacks.

    253 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Questions about Tlaplus Guided Code Repair

What does Tlaplus Guided Code Repair do?

Automatically repair C/C++ code violations detected by TLA+ model checking. Tlaplus Guided Code Repair is an agent skill from ArabelaTso/Skills-4-SE. Automatically repair C/C++ code violations detected by TLA+ model checking.

When should I use Tlaplus Guided Code Repair?

Tlaplus Guided Code Repair fits situations like: TLC model checker reports an invariant violation; temporal property failure; you have a counterexample trace and need to fix the corresponding code; you need to understand how a TLA+ violation maps to program-level bugs.

How do I install Tlaplus Guided Code Repair in Claude Code?

Run `npx skills add ArabelaTso/Skills-4-SE --skill tlaplus-guided-code-repair -a claude-code`. Or copy the skill folder (skills/tlaplus-guided-code-repair in ArabelaTso/Skills-4-SE) into .claude/skills/tlaplus-guided-code-repair in your project. Claude Code loads it when a task matches its description.

How do I install Tlaplus Guided Code Repair in Codex?

Run `npx skills add ArabelaTso/Skills-4-SE --skill tlaplus-guided-code-repair -a codex`. Or copy the skill folder (skills/tlaplus-guided-code-repair in ArabelaTso/Skills-4-SE) into .agents/skills/tlaplus-guided-code-repair in your project. Codex loads it when a task matches its description.

Can I use Tlaplus Guided Code Repair in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ArabelaTso/Skills-4-SE --skill tlaplus-guided-code-repair -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/tlaplus-guided-code-repair, .gemini/skills/tlaplus-guided-code-repair, .github/skills/tlaplus-guided-code-repair and .opencode/skills/tlaplus-guided-code-repair in your project.

What does Tlaplus Guided Code Repair need to run?

Going by SKILL.md and its folder, Tlaplus Guided Code Repair needs Python for the scripts in its folder and the command-line tools its instructions call (python and make). Our summary lists: Python 3.

Does Tlaplus Guided Code Repair access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Tlaplus Guided Code Repair safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Tlaplus Guided Code Repair use?

Tlaplus Guided Code Repair is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Tlaplus Guided Code Repair use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.3k tokens, read only when the agent opens those files.

What are the alternatives to Tlaplus Guided Code Repair?

Skills that share tags, products or a category with Tlaplus Guided Code Repair: Paddle Build (PaddlePaddle/Paddle, 24k stars), Fory Release (apache/fory, 4.6k stars), ONNX Runtime Shape Inference Safety Audit (microsoft/onnxruntime, 22k stars) and Code Audit (3stoneBrother/code-audit, 893 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Tlaplus Guided Code Repair?

ArabelaTso (a GitHub user) maintains it in ArabelaTso/Skills-4-SE, which has 253 GitHub stars. The repository holds 150 skills in this directory. The repository was last updated on August 21, 2026.

Source: ArabelaTso/Skills-4-SE on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.