troubleshoot-and-fix
Skill1 starsChanged 7 days agoMITView on GitHub
Universal, language-independent framework for diagnosing, troubleshooting, and fixing software bugs, exceptions, regressions, and performance issues. Refers to language-specific developer skills (python-developer, typescript-developer, react-developer, java-developer, csharp-developer) for runtime idioms and conventions. Enforces a strict 3-iteration circuit breaker to prevent infinite token-burning retry loops, providing an empirical diagnostic escalation summary when options are exhausted. When direct reproduction is blocked by heavy dependencies or environment limits, it systematically extracts the problematic logic, generates realistic mock fixtures, and executes an isolated reproduction harness (via nodejs-executor MCP or standalone scratch scripts) to verify the fix before porting it back. Use when asked to "troubleshoot and fix", "debug this error", "fix this bug", "solve runtime exception", "diagnose issue", "reproduce and fix bug", or "debug failing code".
In this repository32 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-orchestratorSkill
- algorithmic-complexity-analyzerSkill
- api-securitySkill
- architectural-planningSkill
- caching-queues-reviewerSkill
- code-reviewerSkill
- csharp-developerSkill
- design-pattern-detectorSkill
- detect-overengineeringSkill
- github-security-scanner-hookSkill
- java-developerSkill
- legacy-code-modernizationSkill
- llm-as-judgeSkill
- load-memorySkill
- nodejs-executorSkill
- playwright-bdd-testerSkill
- powershell-writerSkill
- python-api-writerSkill
- python-developerSkill
- python-linterSkill
- react-developerSkill
- remote-pod-log-analyzerSkill
- save-memorySkill
- scan-halucinated-testsSkill
- scan-repo-readmeSkill
- skill-creatorSkill
- sql-connectorSkill
- sql-executorSkill
- sync-github-forksSkill
- trace-code-contextSkill
- typescript-developerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
23 rules. About 0 are common, 18 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Tightly coupled or blocked environments: When reproducing the bug inside the full project is blocked by missing cloud credentials, heavy …
- Distinctive: line 43
Attempt 1: Test primary hypothesis based on initial stack trace and symptom analysis.
- Distinctive: line 44
Attempt 2: If Attempt 1 fails, step back, re-evaluate assumptions, and test an alternative hypothesis.
- Distinctive: line 45
Attempt 3: If Attempt 2 fails, isolate the minimal invariant or probe environmental/configuration boundaries.
- Distinctive: line 47
If after 3 distinct attempts the defect is not cleanly resolved and verified, STOP IMMEDIATELY.
- Distinctive: line 55
When the circuit breaker trips, present this structured post-mortem to the user:
- Distinctive: line 116
Before touching code, collect concrete ground truth:
- Distinctive: line 139
If reproduction is fast and direct → Reproduce directly in the project and proceed to Phase 4.
- Distinctive: line 140
If reproduction is blocked, slow, or tightly coupled → Immediately proceed to Phase 3 (Isolated Extraction & Mocking).
- Distinctive: line 146
When direct execution is blocked, extract the logic into a standalone, runnable testbed to achieve sub-second feedback loops.
- Distinctive: line 152
Keep only the pure business calculation or state machine logic.
- Distinctive: line 155
Create synthetic data fixtures covering both the baseline and the failure trigger:
- Very specific: line 163
When connected to the nodejs-executor MCP server, execute the extracted logic and mock fixtures directly in strict sandbox mode without …
- Distinctive: line 176
Use the included helper script or create a standalone script:
- Distinctive: line 197
Attempt 1: Test primary hypothesis. If verified, proceed to Phase 4.
- Distinctive: line 198
Attempt 2: If Attempt 1 fails, reformulate assumptions and test alternative hypothesis.
- Distinctive: line 199
Attempt 3: If Attempt 2 fails, isolate boundary conditions or minimal invariants.
- Very specific: line 200
Circuit Breaker Halt: If all 3 attempts fail, do not continue looping.
- Very specific: line 217
Run type checks (tsc --noEmit, mypy, pyright).
- Distinctive: line 218
Run existing unit/integration tests to confirm no secondary regressions.
- Very specific: line 227
Search the codebase for similar vulnerable patterns (e.g., using grep or pattern detection).
- Very specific: line 228
If a null-check was missing in calcTax(), check calcDiscount() and calcShipping().
- Distinctive: line 281
Update the extracted function:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Troubleshoot and Fix Skill
A universal, language-independent troubleshooting and repair framework. This skill provides an empirical, evidence-driven methodology to diagnose root causes, isolate failures, synthesize mock testbeds, verify fixes without guessing, prevent regressions, and enforce a strict 3-iteration circuit breaker to prevent runaway token expenditure.
1. Language-Independent Architecture & Skill Delegation
This skill defines the diagnostic and verification process, but delegates language idioms, runtime baselines, and architectural patterns to the dedicated developer skills:
| Target Ecosystem | Delegated Developer Skill | Domain Focus Delegated to Skill |
| Python (3.10–3.13) | python-developer | Asyncio event loops, typing.Protocol, Pydantic validation, pytest fixtures, memory leaks. |
| TypeScript / Node.js | typescript-developer | ESM/CommonJS quirks, TS strictness, async/await promises, Prisma/Drizzle ORM boundaries, Vitest/Jest. |
| React (18 & 19, RSC) | react-developer | Hook dependency arrays, stale closures, infinite re-render loops, Server vs Client Component boundaries. |
| Java / Spring Boot | java-developer | JVM threading, null safety, Spring dependency injection cycles, transaction boundaries, JUnit 5. |
| C# / .NET (8 & 9) | csharp-developer | DI lifetime validation (captive dependencies), async/await deadlocks, EF Core tracking/split queries, Span memory safety, xUnit. |
| Other (Go, Rust, C++, etc.) | Standard toolchain | Identify language version, package manager, and native test runner via discovery. |
2. When to Use This Skill
- Investigating runtime crashes, unhandled exceptions, and 500 errors.
- Fixing logic defects where code runs without crashing but yields incorrect calculations or corrupt state.
- Troubleshooting intermittent or flaky failures (race conditions, async timing issues, cache staleness).
- Resolving build failures, transpilation errors, or dependency conflicts.
- Tightly coupled or blocked environments: When reproducing the bug inside the full project is blocked by missing cloud credentials, heavy databases, slow build cycles, or monolithic architecture.
3. Circuit Breaker & Token-Budget Guardrail (Max 3 Hypotheses)
To prevent infinite trial-and-error loops, runaway token consumption, and speculative code churn, agents executing this skill must adhere to the 3-Iteration Circuit Breaker:
- Iteration Budget:
- Attempt 1: Test primary hypothesis based on initial stack trace and symptom analysis.
- Attempt 2: If Attempt 1 fails, step back, re-evaluate assumptions, and test an alternative hypothesis.
- Attempt 3: If Attempt 2 fails, isolate the minimal invariant or probe environmental/configuration boundaries.
- Circuit Breaker Trip & Immediate Halt:
- If after 3 distinct attempts the defect is not cleanly resolved and verified, STOP IMMEDIATELY.
- Do not guess, brute-force, or make speculative random edits.
- Revert unverified exploratory changes in the main working tree to prevent workspace corruption (
git restoreor clean scratch code). - Preserve reproduction testbeds in
scratch/repro/so diagnostic artifacts remain available. - Output the Out-of-Options Escalation Summary immediately.
Out-of-Options Escalation Summary Template
When the circuit breaker trips, present this structured post-mortem to the user:
## 🛑 Troubleshooting Circuit Breaker: Out of Options Summary
### 1. Defect & Reproduction Baseline
- **Symptom / Error**: `<Exact error message or incorrect output>`
- **Failing Location**: `<File path & line number>`
- **Reproduction Testbed**: `scratch/repro/repro_<issue>.<ext>` (Status: Reproduced in isolation)
### 2. Hypotheses Tested & Ruled Out
| Attempt | Hypothesis / Suspected Root Cause | Action Taken | Empirical Outcome / Why It Failed |
|:---:|---|---|---|
| **1** | e.g. Null dereference in `calcTax()` | Added optional chaining `item?.tax` | Failed: Upstream API returned string `"null"` instead of primitive `null`. |
| **2** | e.g. String-to-number type coercion | Added `Number(item.tax)` parsing | Failed: Handled tax, but caused NaN in downstream aggregation `calcTotal()`. |
| **3** | e.g. Schema mismatch in payload parser | Coerced in DTO mapper | Failed: Broke existing serialization contract on line 88. |
### 3. What Was Ruled Out vs. Remaining Unknowns
- **Ruled Out**: e.g., The issue is not an async race condition or DB lock; it is deterministic data transformation.
- **Remaining Unknowns**: e.g., Why the upstream service sends string `"null"` instead of omitting the key.
### 4. Environmental & External Blockers Identified
- e.g., Unable to verify upstream service schema without access to staging environment or external third-party webhook logs.
### 5. Recommended Next Steps for Developer
1. Inspect the upstream webhook payload contract at the API gateway level.
2. Add a runtime schema sanitizer before the payload enters the domain layer.
3. Review reproduction testbed in `scratch/repro/repro_<issue>.<ext>`.4. The 5-Phase Troubleshoot & Fix Protocol
[Phase 1: Ingestion & Triage]
│
▼
[Phase 2: Direct Reproduction Assessment]
├── (Can reproduce directly in project?) ──► [Direct Fix & Test] ──┐
│ │
└── (BLOCKED / Complex / Missing deps?) │
│ │
▼ │
[Phase 3: Isolated Extraction & Mocking] │
├── Step 1: Slice minimal code unit │
├── Step 2: Synthesize mock data & boundary fixtures │
├── Step 3: Run standalone harness & confirm failure │
└── Step 4: Fix and verify in isolation │
│ │
▼ ▼
[Phase 4: Backporting & Integration Verification] <─────────────────┘
│
▼
[Phase 5: Regression Proofing & Blast Radius Audit]Phase 1: Symptom & Error Triage
Before touching code, collect concrete ground truth:
- Classify the Defect:
- Crash / Panic: Uncaught exception, null pointer, segmentation fault, out-of-memory.
- Logic / State Corruption: Wrong output, off-by-one, silent truncation, incorrect aggregation.
- Concurrency / Timing: Race condition, deadlocks, stale closures, unhandled promise rejection.
- Boundary / Interface: Type mismatch between client and server, schema desynchronization.
- Collect Evidence:
- Exact error message and full stack trace (filename, line number, call stack).
- Expected behavior vs. actual observed behavior.
- Minimal input payload triggering the failure.
Phase 2: Direct Reproduction Assessment
Determine if the bug can be reproduced cleanly in the current project environment:
- Check Project Test Suite: Can a test be run or added directly via
pytest,npm test,vitest,mvn test? - Assess Environmental Blockers:
- Does reproduction require live AWS/GCP/Azure credentials not available in sandbox?
- Does it require spinning up multiple microservices, Docker containers, or live databases?
- Does the full build or test suite take 10+ minutes to execute a single iteration?
- Decision Rule:
- If reproduction is fast and direct → Reproduce directly in the project and proceed to Phase 4.
- If reproduction is blocked, slow, or tightly coupled → Immediately proceed to Phase 3 (Isolated Extraction & Mocking).
Phase 3: The Isolated Extraction & Mocking Strategy
When direct execution is blocked, extract the logic into a standalone, runnable testbed to achieve sub-second feedback loops.
Step 1: Slice the Minimal Code Unit
Extract strictly the function, algorithm, class, or state transition containing the suspected defect into a scratch directory (scratch/repro/):
- Eliminate framework wrappers, HTTP controllers, and ORM decorators.
- Turn database queries into plain array operations or in-memory map lookups.
- Keep only the pure business calculation or state machine logic.
Step 2: Synthesize Realistic Mock Data & Boundary Fixtures
Create synthetic data fixtures covering both the baseline and the failure trigger:
- Baseline Input: Valid input where the logic is expected to succeed.
- Trigger Input: The exact edge-case payload triggering the defect (e.g.
null,undefined, empty list[], negative number, unicode string, malformed timestamp). - Mock Dependencies: Stub out external services (mock HTTP responses, fake storage, deterministic clock/timer).
Step 3: Scaffold and Execute the Standalone Harness
Option A — In-Memory Sandbox Execution via nodejs-executor MCP (Fastest for JS/TS):
When connected to the nodejs-executor MCP server, execute the extracted logic and mock fixtures directly in strict sandbox mode without creating temporary files:
{
"name": "execute_code",
"arguments": {
"language": "typescript",
"sandboxMode": "strict",
"code": "import assert from 'node:assert/strict';\n// Extracted logic + mock fixtures here"
}
}Option B — Standalone Scratch Harness Script (All Languages): Use the included helper script or create a standalone script:
# Initialize isolated harness (Node.js or Python)
node .github/skills/troubleshoot-and-fix/scripts/isolate-runner.js init --name <issue-slug> --lang <ts|js|python|java|csharp>
# or
python .github/skills/troubleshoot-and-fix/scripts/isolate-runner.py init --name <issue-slug> --lang <python|ts|js|java|csharp>Execute the standalone file directly:
- Python:
python scratch/repro/repro_<issue>.py - TypeScript:
node --experimental-strip-types scratch/repro/repro_<issue>.ts(ornpx tsx scratch/repro/repro_<issue>.ts) - JavaScript:
node scratch/repro/repro_<issue>.js - Java:
java scratch/repro/Repro_<issue>.java - C#:
dotnet script scratch/repro/Repro_<issue>.cs(ordotnet test)
[!IMPORTANT] Confirm Failure First: The harness must fail with the exact same error or incorrect output as observed in production. Never modify the logic until reproduction is confirmed.
Step 4: Fix and Verify in Isolation
- Iterate on the extracted code inside the standalone testbed with a hard budget of 3 attempts:
- Attempt 1: Test primary hypothesis. If verified, proceed to Phase 4.
- Attempt 2: If Attempt 1 fails, reformulate assumptions and test alternative hypothesis.
- Attempt 3: If Attempt 2 fails, isolate boundary conditions or minimal invariants.
- Circuit Breaker Halt: If all 3 attempts fail, do not continue looping. Stop, revert working tree changes, keep
scratch/repro/artifacts, and deliver the Out-of-Options Escalation Summary.
- Re-run the standalone harness until:
- The failing edge-case test passes.
- The baseline happy-path test still passes (no regression).
- Additional boundary conditions (e.g. empty inputs, zeroes, large payloads) pass.
Phase 4: Backporting & Integration Verification
Once proven in isolation, port the verified solution back to the source codebase:
- Respect Existing Code Conventions:
- Refer to the respective developer skill (
python-developer,typescript-developer,react-developer,java-developer,csharp-developer) to ensure the ported fix matches project idiomatic patterns (e.g. error types, immutability, async style).
- Refer to the respective developer skill (
- Apply Minimal Diff:
- Modify only what is necessary to solve the defect. Avoid unnecessary refactoring or style churning in the fix commit.
- Verify with Ground Truth:
- Run type checks (
tsc --noEmit,mypy,pyright). - Run existing unit/integration tests to confirm no secondary regressions.
- Run type checks (
Phase 5: Regression Proofing & Blast Radius Audit
- Add Permanent Regression Test:
- Convert the mock fixture from Phase 3 into a permanent unit or integration test in the project's native test directory.
- Audit Blast Radius:
- Search the codebase for similar vulnerable patterns (e.g., using
grepor pattern detection). - If a null-check was missing in
calcTax(), checkcalcDiscount()andcalcShipping().
- Search the codebase for similar vulnerable patterns (e.g., using
- Document Root Cause:
- Provide a clear post-mortem summary: What failed, Why it failed (root cause), and How it was resolved and verified.
4. Practical Example: Extraction & Mocking Walkthrough
Scenario:
A Node.js backend throws TypeError: Cannot read properties of undefined (reading 'price') inside a complex GraphQL resolver connected to AWS DynamoDB and Stripe. Direct local reproduction is blocked because AWS credentials and live Stripe webhooks are required.
Step 1 & 2: Extract to Standalone Scratch File
Extract the calculation function into scratch/repro/repro_cart_total.ts and generate mock fixtures:
// scratch/repro/repro_cart_total.ts
import assert from 'node:assert/strict';
// Extracted logic
interface CartItem {
id: string;
sku: string;
pricing?: { price: number; currency: string } | null;
}
function calculateSubtotal(items: CartItem[]): number {
// BUGGY CODE: items[i].pricing might be undefined or null for discontinued items
return items.reduce((acc, item) => acc + item.pricing.price, 0);
}
// Mock Data
const mockDiscontinuedCart: CartItem[] = [
{ id: '1', sku: 'A1', pricing: { price: 50, currency: 'USD' } },
{ id: '2', sku: 'DISCONTINUED', pricing: null }, // Trigger
];
// Execution
try {
const total = calculateSubtotal(mockDiscontinuedCart);
assert.equal(total, 50);
console.log('✔ Test Passed');
} catch (err) {
console.error('❌ Reproduced exact crash in isolation:', err.message);
}Step 3: Run & Confirm Failure
npx tsx scratch/repro/repro_cart_total.ts
# Output: ❌ Reproduced exact crash in isolation: Cannot read properties of null (reading 'price')Step 4: Fix and Validate in Isolation
Update the extracted function:
function calculateSubtotal(items: CartItem[]): number {
return items.reduce((acc, item) => acc + (item.pricing?.price ?? 0), 0);
}Re-run harness → ✔ Test Passed.
Step 5: Backport to Actual Resolver
Safely apply the optional chaining and nullish coalescing back to the production file with complete confidence.
References
- Troubleshoot and Fix Reference Guide — Bug taxonomy, mock data generation cookbook, concurrency debugging patterns, and isolation templates across languages.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

