
Code Debugging
- 1.3k installs
- 255 repo stars
- Updated February 27, 2026
- lingzhi227/agent-research-skills
code-debugging provides documented workflows for Debug experiment code with structured error analysis. Categorize errors, apply targeted fixes with retry logic, and use reflection to prevent recurring issues.
About
The code-debugging skill 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. # 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 | Category | Examples | Severity | |----------|----------|----------| | SyntaxError | Invalid syntax, indentation | Low | | ImportError | Missing module, wrong name | Low | | RuntimeError | Division by zero, shape mismatch | Medium | | TimeoutError | Infinite loop, too slow | Medium | | OutputError | Missing files, wrong format | Medium | | LogicError | Wrong results, 0% accuracy | High | ### 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.
- `$0` - Error message, stderr output, or code file with issues
- `$1` - Optional: the code that produced the error
- Debug patterns and state machine: `~/.claude/skills/code-debugging/references/debug-patterns.md`
- Read the error traceback (last 1500 chars if truncated)
- Identify the exact line and variable causing the error
Code Debugging by the numbers
- 1,284 all-time installs (skills.sh)
- +37 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #245 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
code-debugging capabilities & compatibility
- Capabilities
- `$0` error message, stderr output, or code fil · `$1` optional: the code that produced the erro · debug patterns and state machine: `~/.claude/ski · read the error traceback (last 1500 chars if tru · identify the exact line and variable causing the
- Use cases
- documentation · planning
What code-debugging says it does
# Code Debugging Systematically debug experiment code with structured error categorization and fix strategies.
Read the error traceback (last 1500 chars if truncated) 2.
npx skills add https://github.com/lingzhi227/agent-research-skills --skill code-debuggingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.3k |
|---|---|
| repo stars | ★ 255 |
| Security audit | 3 / 3 scanners passed |
| Last updated | February 27, 2026 |
| Repository | lingzhi227/agent-research-skills ↗ |
How do I use code-debugging for the task described in its SKILL.md triggers?
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 produ.
Who is it for?
Teams invoking code-debugging when the user request matches documented triggers and prerequisites.
Skip if: Skip when cached docs are missing, the request is a negative trigger, or another sibling skill owns the workflow.
When should I use this skill?
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
What you get
Step-by-step guidance grounded in code-debugging documentation and reference files.
- error classification report
- prioritized fix plan
- resolved agent-generated code
By the numbers
- Defines an 11-level CodeProblem severity hierarchy
- Sourced from data-to-paper, AI-Scientist-v2, and AgentLaboratory
Files
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
| Category | Examples | Severity |
|---|---|---|
| SyntaxError | Invalid syntax, indentation | Low |
| ImportError | Missing module, wrong name | Low |
| RuntimeError | Division by zero, shape mismatch | Medium |
| TimeoutError | Infinite loop, too slow | Medium |
| OutputError | Missing files, wrong format | Medium |
| LogicError | Wrong results, 0% accuracy | High |
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 failingRules
- 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
Code Debugging Patterns
Extracted from data-to-paper (debugger.py, run_issues.py), AI-Scientist-v2, and AgentLaboratory.
Error Severity Hierarchy (data-to-paper)
class CodeProblem(IndexOrderedEnum):
NoCode = 'No code' # Most severe
IncompleteBlock = 'Incomplete block'
NotSingleBlock = 'Not single block'
StaticCheck = 'Static check'
TimeoutError = 'Timeout error'
RuntimeError = 'Runtime error'
SyntaxError = 'Syntax error'
MissingOutputFiles = 'Missing output files'
NonBreakingRuntimeIssue = 'Non-breaking runtime issue'
OutputFileCallingSyntax = 'Output file calling syntax'
OutputFileContentA = 'Output file content first check'
OutputFileContinuity = 'Check dependency on previous output'
OutputFileContentB = 'Output file content second check'
OutputFileCompilation = 'Output file failed compilation'
OutputFileAnnotation = 'Output file annotation'
AllOK = 'All OK' # Least severeRunIssue Structure (data-to-paper)
@dataclass
class RunIssue:
code_problem: CodeProblem # Severity category
category: str # e.g., "Importing packages", "Timeout"
item: str # Specific file/function name
issue: str # Problem description
instructions: str # How to fix
comment: str # Internal note
requesting_small_change: bool # Minor fix vs major rewrite
forgive_after: int # Forgive after N occurrences (None = never)Fix Strategy State Machine (data-to-paper)
Action Matrix
Stage 0 Stage 1 Stage 2
(initial) (1st revision) (2nd revision)
incomplete regen0 regen1 regen1
not_single_block leave regen1 regen2
static_check repost0 repost0/regen1 regen2
run_failed repost0 repost0/leave repost1
missing_files repost0 repost0/leave repost0/regen1
run_completed repost0 repost0 repost0Action Definitions
- repost[N]: Rewind conversation to stage N, post code as fresh response
- Stage 0: "Here is the code to perform the requested analysis:"
- Stage 1: "Here is the revised code to perform the requested analysis:"
- regen[N]: Delete messages back to stage N, regenerate from scratch
- Resets
requesting_small_changeflag
- leave: Keep current response, post issue feedback requesting small change
Conditional Actions (A/B)
When action contains "/": action1/action2
- If current problem severity ≥ previous: use action1
- Else: use action2
Common Error Patterns
Device Mismatch (PyTorch)
RuntimeError: Expected all tensors to be on the same device
Fix: Add .to(device) or ensure consistent device placementShape Mismatch
RuntimeError: mat1 and mat2 shapes cannot be multiplied
Fix: Check tensor dimensions, add .reshape() or .view()Missing Data Normalization
Symptom: Loss is NaN or Inf
Fix: Add input normalization, check for zero-divisionOff-by-One Indexing
IndexError: index X is out of bounds for axis Y with size Z
Fix: Check loop bounds, array indexingIncorrect Loss Function
Symptom: Training loss doesn't decrease
Fix: Match loss function to task type:
- Classification: CrossEntropyLoss (not MSE)
- Regression: MSELoss (not CrossEntropy)
- Multi-label: BCEWithLogitsLossAutomated Code Repair Prompt (AgentLaboratory)
You are a code repair specialist. Given:
1. The original code
2. The error message
3. The traceback
Identify the root cause and apply a MINIMAL fix:
- Do not rewrite working code
- Fix only the lines causing the error
- Preserve the original logic and structure
- Explain why the error occurredTruncation Rules
- Error output: Keep last 1500 characters of stderr
- Stack trace: Keep the last frame (most relevant)
- Code context: Show 5 lines before/after the error line
Reflection After Fix
After fixing the error:
1. Why did this error occur?
2. Which specific lines caused it?
3. What was the fix (line-by-line)?
4. What pattern should be avoided in future?Related skills
Forks & variants (2)
Code Debugging has 2 known copies in the catalog totaling 13 installs. They canonicalize to this original listing.
- lingzhi227 - 12 installs
- lingzhi227 - 1 installs
FAQ
What does code-debugging do?
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
When should I use code-debugging?
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
What are common prerequisites?
--- name: code-debugging description: Debug experiment code with structured error analysis.
Is Code Debugging safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.