PluginBench
Skill
Pass
Audit score 90

code-debugging

lingzhi227/agent-research-skills

Debug experiment code with structured error analysis and retry logic.

What is code-debugging?

Systematically diagnoses and fixes errors in experiment code by categorizing issues (syntax, runtime, logic), analyzing root causes, and applying targeted fixes with reflection. Use when experiment code fails or produces incorrect results.

  • Categorizes errors into six types (SyntaxError, ImportError, RuntimeError, TimeoutError, OutputError, LogicError) with severity levels
  • Analyzes root causes by reading tracebacks and identifying exact lines, variables, and common patterns (device mismatch, shape mismatch, missing normalization)
  • Applies fix strategies tailored to error type: direct fixes for syntax/import, retry loops for runtime, reflection for logic errors, optimization for timeouts
  • Implements retry logic with up to 4-5 fix attempts before changing approach
  • Reflects on fixes to explain why errors occurred and prevent recurring issues
  • Verifies fixes don't introduce new errors and maintains error history

How to install code-debugging

npx skills add https://github.com/lingzhi227/agent-research-skills --skill code-debugging
Claude Code
Cursor
Windsurf
Cline

How to use code-debugging

  1. 1.Provide the error message, stderr output, or code file with issues to the skill
  2. 2.Optionally include the code that produced the error for context
  3. 3.The skill will categorize the error and identify its severity level
  4. 4.Review the root cause analysis and proposed fix strategy
  5. 5.Execute the fix and verify it resolves the issue without introducing new errors
  6. 6.Review the reflection summary to understand the error pattern and avoid it in future code

Use cases

Good for
  • Fixing shape mismatches or device mismatches in tensor operations during model training
  • Debugging 0% accuracy by checking accuracy calculation and data pipeline issues
  • Resolving infinite loops or timeout errors by reducing dataset size or adding early stopping
  • Correcting off-by-one indexing errors and missing data normalization steps
  • Addressing ImportError and missing module dependencies in experiment scripts
Who it's for
  • Machine learning researchers and engineers debugging training code
  • Data scientists troubleshooting experiment failures
  • Anyone iterating on experimental code with systematic error analysis

code-debugging FAQ

What error categories does this skill handle?

Six categories: SyntaxError (low severity), ImportError (low), RuntimeError (medium), TimeoutError (medium), OutputError (medium), and LogicError (high severity).

How many times will the skill retry a fix?

Up to 4-5 fix attempts before changing approach. For syntax/import errors it attempts a direct fix once; for runtime errors it retries up to 4 times; for logic errors it reflects and considers alternative methods.

What should I do if the skill can't fix the error?

After 4-5 attempts, the skill will suggest changing approach or regenerating the code from scratch rather than continuing to patch the same issue.

How does this handle logic errors like 0% accuracy?

For logic errors, the skill first checks the accuracy calculation itself, then traces through the data pipeline to identify where correct values are lost or transformed incorrectly.

What common patterns does the skill look for?

Device mismatch (CPU vs GPU tensors), shape mismatch in matrix operations, missing data normalization, off-by-one indexing errors, and incorrect loss functions for the task type.

Full instructions (SKILL.md)

Source of truth, from lingzhi227/agent-research-skills.


name: code-debugging description: Debug experiment code with structured error analysis. Categorize errors, apply targeted fixes with retry logic, and use reflection to prevent recurring issues. Use when experiment code fails or produces incorrect results. argument-hint: [error-or-code]

Code Debugging

Systematically debug experiment code with structured error categorization and fix strategies.

Input

  • $0 — Error message, stderr output, or code file with issues
  • $1 — Optional: the code that produced the error

References

  • Debug patterns and state machine: ~/.claude/skills/code-debugging/references/debug-patterns.md

Workflow

Step 1: Categorize the Error

CategoryExamplesSeverity
SyntaxErrorInvalid syntax, indentationLow
ImportErrorMissing module, wrong nameLow
RuntimeErrorDivision by zero, shape mismatchMedium
TimeoutErrorInfinite loop, too slowMedium
OutputErrorMissing files, wrong formatMedium
LogicErrorWrong results, 0% accuracyHigh

Step 2: Analyze Root Cause

  1. Read the error traceback (last 1500 chars if truncated)
  2. Identify the exact line and variable causing the error
  3. Check for common patterns:
    • Device mismatch (CPU vs GPU tensors)
    • Shape mismatch in matrix operations
    • Missing data normalization
    • Off-by-one errors in indexing
    • Incorrect loss function for task type

Step 3: Apply Fix Strategy

For syntax/import errors: Direct fix, single attempt For runtime errors: Fix and rerun, up to 4 retries For logic errors: Reflect on approach, consider alternative methods For timeout: Reduce dataset size, optimize bottleneck, add early stopping

Step 4: Reflect and Prevent

After fixing:

  1. Explain why the error occurred
  2. Identify which lines caused it
  3. Describe the fix line-by-line
  4. Note patterns to avoid in future code

Fix Strategy State Machine

Stage 0 (first attempt) → repost code as fresh
Stage 1 (second attempt) → repost or leave depending on severity
Stage 2 (third attempt) → regenerate from scratch if still failing

Rules

  • Prefer minimal targeted edits over full rewrites
  • Maximum 4-5 fix attempts before changing approach
  • Always truncate long error outputs to last 1500 characters
  • After fixing, verify the fix doesn't introduce new errors
  • Keep error history to avoid repeating the same mistakes
  • If 0% accuracy: check accuracy calculation first, then check data pipeline

Related Skills

  • Upstream: experiment-code
  • See also: paper-to-code, data-analysis