[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75MF83R4ZEXDNJ20XHTC6XH":3,"skill-same:01M75MF83R4ZEXDNJ20XHTC6XH":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M75MF83R4ZEXDNJ20XHTC6XH","matlab-debugging",null,"Diagnose MATLAB errors and unexpected behavior. Breakpoints, workspace inspection, try-catch diagnostics, and common error patterns. Use when debugging functions, tracing errors, inspecting variables, or diagnosing runtime failures.","stanfish06\u002Fskillquarium","stanfish06","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F93099613?v=4","01M75F1CK4ZW109ZK3T26VN52F","Zhiyuan","01M75F1CM53VH6F79DZ8GXKKES",12,"BSD-2-Clause","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-debugging\u002FLICENSE.md","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-debugging\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: matlab-debugging\ndescription: Diagnose MATLAB errors and unexpected behavior. Breakpoints, workspace inspection, try-catch diagnostics, and common error patterns. Use when debugging functions, tracing errors, inspecting variables, or diagnosing runtime failures.\nlicense: MathWorks BSD-3-Clause\nmetadata:\n  author: MathWorks\n  version: \"2.0\"\n---\n\n# Investigating and Debugging MATLAB Code with MCP Tools\n\nYou have access to a live MATLAB session via MCP tools. Use them to actively\ninvestigate code — whether debugging errors, understanding behavior, or answering\nquestions about how MATLAB code works. Don't just guess from code alone.\n\n## When to Use\n\n- User encounters a MATLAB error message or unexpected result\n- User wants to set breakpoints or inspect variable state\n- Tracing why a function produces wrong output\n- NaN\u002FInf values appearing unexpectedly\n- A MATLAB MCP tool returns an error or exception — including runtime errors, syntax errors, undefined function\u002Fvariable errors, or failed test results\n- User asks \"why is my MATLAB code not working\", \"help me debug\", or shares a MATLAB stack trace\n\n## When NOT to Use\n\n- Code quality review without a runtime problem — use `matlab-reviewing-code` instead\n- Performance profiling — use performance optimization workflows\n- Writing tests for correctness — use `matlab-testing` instead\n- Understanding MATLAB APIs or language features without a specific bug\n\n## Static Analysis vs Runtime Debugging\n\nNot every issue needs the live MATLAB session. Choose the right approach:\n\n- **Static analysis is enough** when: syntax errors, unused variables, obvious\n  logic mistakes, or issues visible from reading the source code alone. Use the\n  `Read` tool and `check_matlab_code`.\n- **Runtime debugging is needed** when:\n  - The error depends on actual data values, types, or dimensions\n  - The output is wrong but the code looks correct\n  - The user says \"it doesn't work\" but the code looks fine — check actual data\n  - You need to know what variables contain at a specific point in execution\n\nWhen in doubt, start with static analysis. Escalate to runtime debugging when\nyou can't determine the root cause from source alone.\n\n## Auto-Trigger on MATLAB Errors\n\nWhen a MATLAB MCP tool returns an error (runtime error, syntax error, undefined\nfunction\u002Fvariable, dimension mismatch, failed assertion, etc.), **do not silently\nmove on or guess at a fix**. Instead:\n\n1. **Recognize the error** — Look for patterns like `Error using ...`,\n   `Undefined function or variable`, `Index exceeds ...`, `Error in ...`,\n   MATLAB stack traces, or failed test results in MCP tool output.\n2. **Ask the user for permission** — Before launching into investigation, offer:\n   > \"I noticed a MATLAB error: `\u003Cbrief error summary>`. I can use the\n   > matlab-debugging skill to dig into this — inspect variables, trace the\n   > call stack, and identify the root cause. Want me to investigate?\"\n3. **Proceed only after confirmation** — Once the user agrees, follow the\n   investigation workflow below.\n\nThis applies whether the error came from the user running code, or from you\nrunning code on the user's behalf (e.g., verifying a fix, running tests).\n\n## Available Tools\n\n| Tool | Use For |\n|------|---------|\n| `mcp__matlab__run_matlab_file` | **Run .m scripts** — prefer this for executing user scripts and verifying fixes |\n| `mcp__matlab__evaluate_matlab_code` | Quick diagnostics: inspect variables, evaluate expressions, test small snippets |\n| `mcp__matlab__check_matlab_code` | Static analysis of .m files (warnings, unused vars, potential issues) |\n| `mcp__matlab__run_matlab_test_file` | Run a MATLAB test file |\n| `mcp__matlab__detect_matlab_toolboxes` | List installed toolboxes — use when \"Undefined function\" may be a missing toolbox |\n\n**Prefer `run_matlab_file` over `evaluate_matlab_code` for running scripts.** Only\nuse `evaluate_matlab_code` for short diagnostic commands (checking a variable,\ntesting an expression, etc.) — not for re-running entire scripts inline.\n\n## Workflow\n\n### 1. Understand the Goal\n\nDetermine what the user needs:\n- **Debugging** — runtime error, wrong output, unexpected behavior\n- **Understanding** — how does this code work, what does this function do\n- **Investigating** — why does this variable have this value, where does this data come from\n- **Exploring** — what functions are available, how is this codebase structured\n\n### 2. Gather Information via MATLAB\n\nUse `mcp__matlab__evaluate_matlab_code` to run diagnostic commands.\n\n**Read source code:** Use the `Read` tool for .m files on disk — not MATLAB's\n`type` or `dbtype`. Only use MATLAB's `which` to locate files you haven't\nfound yet, and `which -all` to check for shadowing.\n\n**Preview large data:** Use `varName(1:min(5,end),:)` or `head(T)` to preview\nslices instead of dumping entire variables.\n\n**Runtime debugging — check desktop mode first:**\n\nBefore using breakpoints, check if MATLAB has a desktop:\n```matlab\ndesktop('-inuse')  % true = desktop mode, false = no-desktop\n```\n\n**Desktop mode (`desktop('-inuse')` returns `true`):**\n\nUse the full breakpoint workflow:\n\n1. **Set a breakpoint before running:**\n   ```matlab\n   dbstop if error          % Pause on any error\n   dbstop if caught error   % Pause on error inside try-catch (silent failures)\n   dbstop if warning        % Pause when a warning is issued\n   dbstop if naninf         % Pause on NaN or Inf\n   dbstop in file at line   % Pause at a specific line\n   ```\n2. **Run the code** via `run_matlab_file` — MATLAB pauses at the breakpoint.\n3. **Inspect the call stack:**\n   ```matlab\n   dbstack                  % See full call stack with file names and line numbers\n   ```\n4. **`whos` to see what's in scope** — check variable names, sizes, and types\n   before inspecting any values. For large arrays\u002Ftables, preview a slice\n   (`varName(1:5,:)`, `head(T)`) instead of displaying the whole thing.\n5. **Navigate frames and inspect variables in each scope:**\n   ```matlab\n   dbup                     % Move up one frame (toward caller)\n   dbdown                   % Move back down (toward callee)\n   ```\n   After `dbup`\u002F`dbdown`, variable inspection commands operate in that\n   frame's local scope — use this to check inputs\u002Foutputs at each level.\n6. **Resume or exit:**\n   ```matlab\n   dbcont                   % Continue execution to next breakpoint or end\n   dbquit                   % Exit debug mode entirely\n   dbclear all              % Remove all breakpoints when done\n   ```\n\n**Note:** Interactive stepping (`dbstep`) is unreliable via MCP — each\n`evaluate_matlab_code` call is a separate command, so step state may not\npersist.\n\n**No-desktop mode (`desktop('-inuse')` returns `false`):**\n\n**Do NOT use `dbstop if error`, `dbstop if naninf`, `dbstop if warning`, or\nany breakpoint that pauses execution.** In no-desktop mode, pausing breakpoints\ncause the MCP eval to hang indefinitely.\n\nUse these strategies instead:\n\n1. **try-catch wrappers** — Wrap suspect code to capture the error and\n   inspect state after failure:\n   ```matlab\n   try\n       result = suspectFunction(data);\n   catch ME\n       fprintf('Error: %s\\n', ME.message);\n       fprintf('In: %s line %d\\n', ME.stack(1).name, ME.stack(1).line);\n       whos  % Show variables in scope at failure\n   end\n   ```\n\n2. **Tracer conditional breakpoints** — Use `dbstop` with a condition\n   that always returns `false` so MATLAB never actually pauses, but prints\n   the value as a side effect. Define a tracer function:\n   ```matlab\n   function out = tracer(val)\n       disp(val);\n       out = false;\n   end\n   ```\n   Then set a conditional breakpoint that calls it:\n   ```matlab\n   dbstop in myScript at 42 if tracer(myVar)\n   ```\n   When line 42 executes, MATLAB evaluates `tracer(myVar)`, which prints\n   the value and returns `false` — execution continues without pausing.\n   This probes variables at specific lines without modifying the source file.\n   Remove tracer breakpoints when done: `dbclear all`\n\n3. **Run then inspect** — For scripts, run via `run_matlab_file`, then use\n   `evaluate_matlab_code` to inspect workspace variables after execution.\n   The base workspace persists across MCP calls within a session.\n\n### 3. Investigate Iteratively\n\nThis is the core of debugging — use your judgment:\n\n- **Read the relevant source code** to understand intent\n- **Inspect variables** that appear on or near the failing line\n- **Evaluate sub-expressions** to isolate which part fails\n- **Test hypotheses** by running small snippets in MATLAB\n- **Be selective** — don't dump the entire workspace. Only inspect what is relevant\n  to the problem. If there are 7 variables in scope but only 2 are used on the\n  failing line, inspect those 2.\n\nWhen the error occurs inside a MathWorks built-in function, the bug is almost\nalways in the **user's code that called it**. Walk up the stack to user code.\n\n### 4. Question the Diagnosis\n\nThe user's description of the problem may not match the actual problem. Before\nfixing what they say is broken, verify it yourself:\n\n- **Test the claimed failure directly** — If the user says `ismember` or `strcmp`\n  doesn't work, run it yourself with their actual data. Often the operation works\n  fine and the real issue is the logic around it.\n- **Check data before blaming code** — When operations on data \"don't work,\"\n  inspect the data: types (`class`), actual values (sample a few), whitespace\n  (`strtrim`), hidden characters (`double(str)`), and dimensions (`size`).\n- **Verify what the code does vs what the user describes** — Read the code and\n  confirm which variables and columns are actually being used. The user may\n  describe their intent but the code may do something different.\n- **Consider whether the approach itself is wrong** — Sometimes the code has no\n  bug per se, but the approach is unnecessarily complex or fragile. Suggest\n  idiomatic MATLAB alternatives: table joins instead of manual loops, vectorized\n  operations instead of element-wise comparisons, built-in functions instead of\n  hand-rolled logic.\n\n\n## Common Errors — What to Check First\n\n| Error Pattern | Diagnostic Steps |\n|---------------|-----------------|\n| `Undefined function or variable 'X'` | `which X`, `exist('X','file')`, `exist('X','var')`, check `path`, use `detect_matlab_toolboxes` to verify toolbox is installed |\n| `Index exceeds array dimensions` \u002F `Index exceeds the number of array elements` | `size(arr)` and inspect the index expression — often off-by-one or empty array |\n| `Not enough input arguments` | Check how the function is called at the call site, `nargin` inside the function, compare with function signature |\n| `Too many input arguments` | Same as above — caller passing extra args, or calling a script as if it were a function |\n| `Matrix dimensions must agree` \u002F `Dimension mismatch` | `size(A)`, `size(B)` for both operands — often one is row and the other column |\n| `Subscript indices must either be real positive integers or logicals` | Check index variable: `class(idx)`, `min(idx)`, look for 0 or negative values, NaN, or floating-point indices |\n| `Dot indexing is not supported for variables of this type` | `class(var)` — usually accessing a struct field on a non-struct (cell, array, table) |\n| `Unable to perform assignment` | Check `class` and `size` of both sides of the assignment |\n| `Out of memory` | `whos` to find large variables, check for accidental array growth in loops |\n| `Maximum recursion limit` | Check for missing base case or infinite mutual recursion — `dbstack` at error point |\n| NaN propagation \u002F wrong branch taken | In desktop mode, use `dbstop if naninf` to catch where NaN is first created. In no-desktop mode, use `dbstop in file at line if tracer(suspect)` to probe values without pausing. NaN comparisons (`>`, `\u003C`, `==`) are always `false`, so `if` takes the wrong branch silently. Trace upstream: check for `0\u002F0`, `Inf-Inf`, or NaN in input data. Use `any(isnan(var))` to test. |\n\n## Gotchas\n\n- **Pausing breakpoints hang in no-desktop mode.** When `desktop('-inuse')`\n  returns `false`, `dbstop if error`, `dbstop if naninf`, `dbstop if warning`,\n  and unconditional line breakpoints cause MCP eval to hang indefinitely. Always\n  check desktop mode first. In no-desktop mode, use tracer conditional\n  breakpoints or try-catch wrappers instead (see no-desktop strategies above).\n- **`dbstep` does not work reliably via MCP.** Each `evaluate_matlab_code` call\n  is a separate command, so step state may not persist between calls. Use\n  breakpoints (`dbstop in file at line`) to pause at specific locations instead\n  of trying to step through code. For tracing execution flow, insert temporary\n  `fprintf()` statements or use try-catch blocks.\n- **Do not use `type` or `dbtype` to read source code.** Use the `Read` tool\n  instead — it's faster and doesn't consume MATLAB session output bandwidth.\n  Only use `which` to locate files you haven't found yet.\n- **Always `dbclear all` when done debugging.** Leftover breakpoints from a\n  previous session will cause unexpected pauses in later runs.\n- **`dbup`\u002F`dbdown` scope is per-call.** Each `evaluate_matlab_code` invocation\n  resets to the current frame. Chain `dbup` with variable inspection in the\n  same `evaluate_matlab_code` call:\n  ```matlab\n  dbup; whos; myVar(1:min(5,end),:)\n  ```\n  A separate `evaluate_matlab_code` call after `dbup` will be back in the\n  original frame.\n- **Never run `restoredefaultpath`.** It removes the MCP server's own packages\n  from the MATLAB path, breaking the eval channel (`mcpEval` not found). If this\n  happens, the only recovery is to restart MATLAB entirely.\n- **No toolboxes required.** This skill uses only base MATLAB debugging commands.\n\n## Key Principles\n\n- **Use the tools** — You have a live MATLAB session. Run commands, inspect\n  state, test hypotheses. Don't debug from code reading alone.\n- **Be selective** — Request only what's relevant. Don't dump all variables or\n  read every file in the stack.\n- **Check size before fetching data** — Always know the dimensions before\n  displaying a variable. Never blindly `disp` an unknown variable.\n- **Focus on user code** — Errors surfacing in built-in functions are almost\n  always caused by bad inputs from user code.\n- **Read before fixing** — Always read the actual source code before suggesting\n  changes. Never guess what code looks like.\n- **Verify fixes** — When practical, run the corrected code in MATLAB to confirm.\n\n----\n\nCopyright 2026 The MathWorks, Inc.\n\n----\n","# Investigating and Debugging MATLAB Code with MCP Tools\n\nYou have access to a live MATLAB session via MCP tools. Use them to actively\ninvestigate code — whether debugging errors, understanding behavior, or answering\nquestions about how MATLAB code works. Don't just guess from code alone.\n\n## When to Use\n\n- User encounters a MATLAB error message or unexpected result\n- User wants to set breakpoints or inspect variable state\n- Tracing why a function produces wrong output\n- NaN\u002FInf values appearing unexpectedly\n- A MATLAB MCP tool returns an error or exception — including runtime errors, syntax errors, undefined function\u002Fvariable errors, or failed test results\n- User asks \"why is my MATLAB code not working\", \"help me debug\", or shares a MATLAB stack trace\n\n## When NOT to Use\n\n- Code quality review without a runtime problem — use `matlab-reviewing-code` instead\n- Performance profiling — use performance optimization workflows\n- Writing tests for correctness — use `matlab-testing` instead\n- Understanding MATLAB APIs or language features without a specific bug\n\n## Static Analysis vs Runtime Debugging\n\nNot every issue needs the live MATLAB session. Choose the right approach:\n\n- **Static analysis is enough** when: syntax errors, unused variables, obvious\n  logic mistakes, or issues visible from reading the source code alone. Use the\n  `Read` tool and `check_matlab_code`.\n- **Runtime debugging is needed** when:\n  - The error depends on actual data values, types, or dimensions\n  - The output is wrong but the code looks correct\n  - The user says \"it doesn't work\" but the code looks fine — check actual data\n  - You need to know what variables contain at a specific point in execution\n\nWhen in doubt, start with static analysis. Escalate to runtime debugging when\nyou can't determine the root cause from source alone.\n\n## Auto-Trigger on MATLAB Errors\n\nWhen a MATLAB MCP tool returns an error (runtime error, syntax error, undefined\nfunction\u002Fvariable, dimension mismatch, failed assertion, etc.), **do not silently\nmove on or guess at a fix**. Instead:\n\n1. **Recognize the error** — Look for patterns like `Error using ...`,\n   `Undefined function or variable`, `Index exceeds ...`, `Error in ...`,\n   MATLAB stack traces, or failed test results in MCP tool output.\n2. **Ask the user for permission** — Before launching into investigation, offer:\n   > \"I noticed a MATLAB error: `\u003Cbrief error summary>`. I can use the\n   > matlab-debugging skill to dig into this — inspect variables, trace the\n   > call stack, and identify the root cause. Want me to investigate?\"\n3. **Proceed only after confirmation** — Once the user agrees, follow the\n   investigation workflow below.\n\nThis applies whether the error came from the user running code, or from you\nrunning code on the user's behalf (e.g., verifying a fix, running tests).\n\n## Available Tools\n\n| Tool | Use For |\n|------|---------|\n| `mcp__matlab__run_matlab_file` | **Run .m scripts** — prefer this for executing user scripts and verifying fixes |\n| `mcp__matlab__evaluate_matlab_code` | Quick diagnostics: inspect variables, evaluate expressions, test small snippets |\n| `mcp__matlab__check_matlab_code` | Static analysis of .m files (warnings, unused vars, potential issues) |\n| `mcp__matlab__run_matlab_test_file` | Run a MATLAB test file |\n| `mcp__matlab__detect_matlab_toolboxes` | List installed toolboxes — use when \"Undefined function\" may be a missing toolbox |\n\n**Prefer `run_matlab_file` over `evaluate_matlab_code` for running scripts.** Only\nuse `evaluate_matlab_code` for short diagnostic commands (checking a variable,\ntesting an expression, etc.) — not for re-running entire scripts inline.\n\n## Workflow\n\n### 1. Understand the Goal\n\nDetermine what the user needs:\n- **Debugging** — runtime error, wrong output, unexpected behavior\n- **Understanding** — how does this code work, what does this function do\n- **Investigating** — why does this variable have this value, where does this data come from\n- **Exploring** — what functions are available, how is this codebase structured\n\n### 2. Gather Information via MATLAB\n\nUse `mcp__matlab__evaluate_matlab_code` to run diagnostic commands.\n\n**Read source code:** Use the `Read` tool for .m files on disk — not MATLAB's\n`type` or `dbtype`. Only use MATLAB's `which` to locate files you haven't\nfound yet, and `which -all` to check for shadowing.\n\n**Preview large data:** Use `varName(1:min(5,end),:)` or `head(T)` to preview\nslices instead of dumping entire variables.\n\n**Runtime debugging — check desktop mode first:**\n\nBefore using breakpoints, check if MATLAB has a desktop:\n```matlab\ndesktop('-inuse')  % true = desktop mode, false = no-desktop\n```\n\n**Desktop mode (`desktop('-inuse')` returns `true`):**\n\nUse the full breakpoint workflow:\n\n1. **Set a breakpoint before running:**\n   ```matlab\n   dbstop if error          % Pause on any error\n   dbstop if caught error   % Pause on error inside try-catch (silent failures)\n   dbstop if warning        % Pause when a warning is issued\n   dbstop if naninf         % Pause on NaN or Inf\n   dbstop in file at line   % Pause at a specific line\n   ```\n2. **Run the code** via `run_matlab_file` — MATLAB pauses at the breakpoint.\n3. **Inspect the call stack:**\n   ```matlab\n   dbstack                  % See full call stack with file names and line numbers\n   ```\n4. **`whos` to see what's in scope** — check variable names, sizes, and types\n   before inspecting any values. For large arrays\u002Ftables, preview a slice\n   (`varName(1:5,:)`, `head(T)`) instead of displaying the whole thing.\n5. **Navigate frames and inspect variables in each scope:**\n   ```matlab\n   dbup                     % Move up one frame (toward caller)\n   dbdown                   % Move back down (toward callee)\n   ```\n   After `dbup`\u002F`dbdown`, variable inspection commands operate in that\n   frame's local scope — use this to check inputs\u002Foutputs at each level.\n6. **Resume or exit:**\n   ```matlab\n   dbcont                   % Continue execution to next breakpoint or end\n   dbquit                   % Exit debug mode entirely\n   dbclear all              % Remove all breakpoints when done\n   ```\n\n**Note:** Interactive stepping (`dbstep`) is unreliable via MCP — each\n`evaluate_matlab_code` call is a separate command, so step state may not\npersist.\n\n**No-desktop mode (`desktop('-inuse')` returns `false`):**\n\n**Do NOT use `dbstop if error`, `dbstop if naninf`, `dbstop if warning`, or\nany breakpoint that pauses execution.** In no-desktop mode, pausing breakpoints\ncause the MCP eval to hang indefinitely.\n\nUse these strategies instead:\n\n1. **try-catch wrappers** — Wrap suspect code to capture the error and\n   inspect state after failure:\n   ```matlab\n   try\n       result = suspectFunction(data);\n   catch ME\n       fprintf('Error: %s\\n', ME.message);\n       fprintf('In: %s line %d\\n', ME.stack(1).name, ME.stack(1).line);\n       whos  % Show variables in scope at failure\n   end\n   ```\n\n2. **Tracer conditional breakpoints** — Use `dbstop` with a condition\n   that always returns `false` so MATLAB never actually pauses, but prints\n   the value as a side effect. Define a tracer function:\n   ```matlab\n   function out = tracer(val)\n       disp(val);\n       out = false;\n   end\n   ```\n   Then set a conditional breakpoint that calls it:\n   ```matlab\n   dbstop in myScript at 42 if tracer(myVar)\n   ```\n   When line 42 executes, MATLAB evaluates `tracer(myVar)`, which prints\n   the value and returns `false` — execution continues without pausing.\n   This probes variables at specific lines without modifying the source file.\n   Remove tracer breakpoints when done: `dbclear all`\n\n3. **Run then inspect** — For scripts, run via `run_matlab_file`, then use\n   `evaluate_matlab_code` to inspect workspace variables after execution.\n   The base workspace persists across MCP calls within a session.\n\n### 3. Investigate Iteratively\n\nThis is the core of debugging — use your judgment:\n\n- **Read the relevant source code** to understand intent\n- **Inspect variables** that appear on or near the failing line\n- **Evaluate sub-expressions** to isolate which part fails\n- **Test hypotheses** by running small snippets in MATLAB\n- **Be selective** — don't dump the entire workspace. Only inspect what is relevant\n  to the problem. If there are 7 variables in scope but only 2 are used on the\n  failing line, inspect those 2.\n\nWhen the error occurs inside a MathWorks built-in function, the bug is almost\nalways in the **user's code that called it**. Walk up the stack to user code.\n\n### 4. Question the Diagnosis\n\nThe user's description of the problem may not match the actual problem. Before\nfixing what they say is broken, verify it yourself:\n\n- **Test the claimed failure directly** — If the user says `ismember` or `strcmp`\n  doesn't work, run it yourself with their actual data. Often the operation works\n  fine and the real issue is the logic around it.\n- **Check data before blaming code** — When operations on data \"don't work,\"\n  inspect the data: types (`class`), actual values (sample a few), whitespace\n  (`strtrim`), hidden characters (`double(str)`), and dimensions (`size`).\n- **Verify what the code does vs what the user describes** — Read the code and\n  confirm which variables and columns are actually being used. The user may\n  describe their intent but the code may do something different.\n- **Consider whether the approach itself is wrong** — Sometimes the code has no\n  bug per se, but the approach is unnecessarily complex or fragile. Suggest\n  idiomatic MATLAB alternatives: table joins instead of manual loops, vectorized\n  operations instead of element-wise comparisons, built-in functions instead of\n  hand-rolled logic.\n\n\n## Common Errors — What to Check First\n\n| Error Pattern | Diagnostic Steps |\n|---------------|-----------------|\n| `Undefined function or variable 'X'` | `which X`, `exist('X','file')`, `exist('X','var')`, check `path`, use `detect_matlab_toolboxes` to verify toolbox is installed |\n| `Index exceeds array dimensions` \u002F `Index exceeds the number of array elements` | `size(arr)` and inspect the index expression — often off-by-one or empty array |\n| `Not enough input arguments` | Check how the function is called at the call site, `nargin` inside the function, compare with function signature |\n| `Too many input arguments` | Same as above — caller passing extra args, or calling a script as if it were a function |\n| `Matrix dimensions must agree` \u002F `Dimension mismatch` | `size(A)`, `size(B)` for both operands — often one is row and the other column |\n| `Subscript indices must either be real positive integers or logicals` | Check index variable: `class(idx)`, `min(idx)`, look for 0 or negative values, NaN, or floating-point indices |\n| `Dot indexing is not supported for variables of this type` | `class(var)` — usually accessing a struct field on a non-struct (cell, array, table) |\n| `Unable to perform assignment` | Check `class` and `size` of both sides of the assignment |\n| `Out of memory` | `whos` to find large variables, check for accidental array growth in loops |\n| `Maximum recursion limit` | Check for missing base case or infinite mutual recursion — `dbstack` at error point |\n| NaN propagation \u002F wrong branch taken | In desktop mode, use `dbstop if naninf` to catch where NaN is first created. In no-desktop mode, use `dbstop in file at line if tracer(suspect)` to probe values without pausing. NaN comparisons (`>`, `\u003C`, `==`) are always `false`, so `if` takes the wrong branch silently. Trace upstream: check for `0\u002F0`, `Inf-Inf`, or NaN in input data. Use `any(isnan(var))` to test. |\n\n## Gotchas\n\n- **Pausing breakpoints hang in no-desktop mode.** When `desktop('-inuse')`\n  returns `false`, `dbstop if error`, `dbstop if naninf`, `dbstop if warning`,\n  and unconditional line breakpoints cause MCP eval to hang indefinitely. Always\n  check desktop mode first. In no-desktop mode, use tracer conditional\n  breakpoints or try-catch wrappers instead (see no-desktop strategies above).\n- **`dbstep` does not work reliably via MCP.** Each `evaluate_matlab_code` call\n  is a separate command, so step state may not persist between calls. Use\n  breakpoints (`dbstop in file at line`) to pause at specific locations instead\n  of trying to step through code. For tracing execution flow, insert temporary\n  `fprintf()` statements or use try-catch blocks.\n- **Do not use `type` or `dbtype` to read source code.** Use the `Read` tool\n  instead — it's faster and doesn't consume MATLAB session output bandwidth.\n  Only use `which` to locate files you haven't found yet.\n- **Always `dbclear all` when done debugging.** Leftover breakpoints from a\n  previous session will cause unexpected pauses in later runs.\n- **`dbup`\u002F`dbdown` scope is per-call.** Each `evaluate_matlab_code` invocation\n  resets to the current frame. Chain `dbup` with variable inspection in the\n  same `evaluate_matlab_code` call:\n  ```matlab\n  dbup; whos; myVar(1:min(5,end),:)\n  ```\n  A separate `evaluate_matlab_code` call after `dbup` will be back in the\n  original frame.\n- **Never run `restoredefaultpath`.** It removes the MCP server's own packages\n  from the MATLAB path, breaking the eval channel (`mcpEval` not found). If this\n  happens, the only recovery is to restart MATLAB entirely.\n- **No toolboxes required.** This skill uses only base MATLAB debugging commands.\n\n## Key Principles\n\n- **Use the tools** — You have a live MATLAB session. Run commands, inspect\n  state, test hypotheses. Don't debug from code reading alone.\n- **Be selective** — Request only what's relevant. Don't dump all variables or\n  read every file in the stack.\n- **Check size before fetching data** — Always know the dimensions before\n  displaying a variable. Never blindly `disp` an unknown variable.\n- **Focus on user code** — Errors surfacing in built-in functions are almost\n  always caused by bad inputs from user code.\n- **Read before fixing** — Always read the actual source code before suggesting\n  changes. Never guess what code looks like.\n- **Verify fixes** — When practical, run the corrected code in MATLAB to confirm.\n\n----\n\nCopyright 2026 The MathWorks, Inc.\n\n----\n",{"name":5,"license":25,"metadata":26,"description":7},"MathWorks BSD-3-Clause",{"author":27,"version":28},"MathWorks","2.0","master","49e49abf2f670d429e0b7e2c0349739c3fdd5cbe","skills\u002Fmatlab-debugging",5,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium","https:\u002F\u002Fgithub.com\u002Fstanfish06","https:\u002F\u002Fwww.stanfish.dev\u002F","2026-11-14 21:31:37",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add stanfish06\u002Fskillquarium --skill matlab-debugging",{"tool":43,"command":44},"bunx","bunx skills add stanfish06\u002Fskillquarium --skill matlab-debugging",{"tool":46,"command":47},"pnpm","pnpm dlx skills add stanfish06\u002Fskillquarium --skill matlab-debugging","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-debugging\u002FSKILL.md",true,[51,56],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":16},"LICENSE.md","LICENSE","许可证",1482,{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"manifest.yaml","REFERENCE","参考文档",478,"https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fmatlab-debugging\u002Fmanifest.yaml",[63,71,80,87,94,101],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":20},"01M76ZJTRVA456GD7K8Y3EP82H","zarr-python","Stores and queries chunked N-D scientific arrays with Zarr-Python 3, including codecs, sharding, S3\u002FGCS storage, and NumPy\u002FDask\u002FXarray integration. Use for array layout, bounded I\u002FO, format migration, or scientific metadata preservation.","MIT","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fzarr-python\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":76,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":20},"01M76ZJQZ15Q1HKC5V85NHE325","yeet","Publish local changes to GitHub by confirming scope, committing intentionally, pushing the branch, and opening a draft PR through the GitHub app from this plugin, with `gh` used only as a fallback where connector coverage is insufficient.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":20},"01M76ZJ8ASZ4QYQ70Y6SBA4Z4S","xarray","N-dimensional labeled arrays and datasets in Python. Built on top of NumPy and Dask. It introduces labels in the form of dimensions, coordinates, and attributes on top of raw NumPy-like arrays, making data analysis in physical sciences more intuitive and less error-prone. Use for working with multi-dimensional scientific data, NetCDF\u002FGRIB\u002FZarr files, climate\u002Fweather\u002Foceanographic datasets, remote sensing, geospatial imaging, large out-of-memory datasets with Dask, and labeled array operations.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fxarray\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":20},"01M76ZHFBXD6VXPQ02VCEG202B","writing-mstest-tests","Use when asked to fix, rewrite, update, improve, modernize, show corrected code for, or explain existing MSTest tests or MSTest-specific configuration. Use for \"review\" when corrected code or edits are wanted, even for one pasted assertion or passing tests with bad failure output. Covers expected\u002Factual labels; generic Boolean, collection, string, numeric, null, identity, exception, hard-cast, and object[] checks; TestContext\u002Flifecycle; timeout\u002Fcancellation; OS\u002FCI conditions, retry, cleanup, parallelization, MSTest.Sdk project setup, and MSTESTxxxx. Honor the installed MSTest version. DO NOT USE to design new test cases (code-testing), perform report-only audits, create project files rather than explain MSTest setup, run tests, migrate frameworks, or handle non-MSTest\u002Fnon-.NET code.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwriting-mstest-tests\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":67,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":20},"01M76ZDFDF4N88RH6HSYGS7GP2","wgs-prs","End-to-end WGS to polygenic risk score pipeline. Takes paired-end FASTQ files (or a pre-existing VCF) through nf-core\u002Fsarek for variant calling, applies VCF QC (normalisation, hard filtering, Ti\u002FTv and Het\u002FHom checks), then computes polygenic risk scores via the PGS Catalog. Fills the FASTQ to VCF gap upstream of the gwas-prs skill.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwgs-prs\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":75,"licenseFileUrl":105,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":20},"01M76ZCC1SC68J42QK4MDC8RCG","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fstanfish06\u002Fskillquarium\u002Fblob\u002Fmaster\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[]]