
inject-faults
Add, configure, and manage faults on Simulink, Simscape, and System Composer model signals for robustness analysis and safety validation. Use when injecting faults (stuck, noise, gain, offset) onto block inports/outports, enabling fault simulation, or analyzing fault effects. Covers sensor failures, signal corruptions, actuator faults, FMEA validation, and robustness testing. Requires Simulink Fault Analyzer.
- Installs
- 51
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/matlab/simulink-agentic-toolkit --skill inject-faults- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads inject-faults automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Fault Injection
Use evaluate_matlab_code with the Simulink.fault API to programmatically inject faults into Simulink models. Faults override signal values at block ports to simulate hardware failures, sensor faults, and actuator malfunctions.
When to Use
- Injecting sensor stuck-at faults, noise, or bias for safety analysis (Simulink, Simscape, System Composer)
- Validating FMEA failure modes through simulation
- Testing controller robustness against actuator or sensor failures
- Adding fault placeholders (without behavior) for FMEA traceability before defining fault logic
- Configuring fault trigger conditions (timed, conditional, always-on)
- Creating fault scenarios for automated testing
- Comparing nominal vs. faulted behavior
- Linking faults to FMEA failure mode cells
- Generating fault specification reports
- Exporting models with embedded fault behavior for teams without Simulink Fault Analyzer
- Registering custom fault behavior libraries
- Synchronizing (also called resync / sync / synchronize faults / update fault references) fault information from referenced models, subsystems, or linked libraries into a parent model
When NOT to Use
- Creating FMEA spreadsheets or safety analysis documents -> use
manage-safety-analysis - Building or editing model structure -> use
building-simulink-models - Running standard (non-faulted) simulations -> use
simulating-simulink-models - Writing pass/fail tests -> use
testing-simulink-models
Probe
hasFA = ~isempty(which('Simulink.fault.addFault'));
fprintf('Simulink Fault Analyzer available: %d\n', hasFA);
Key Concepts
- Fault: A modification applied to a block port (inport or outport) that overrides the signal value.
- Fault without Behavior: A placeholder that documents a failure point but cannot be simulated.
- Fault with Behavior: A fault with an associated behavior model that can be simulated (see
references/fault-behaviors.md). - Fault Model: The
.slxfile containing fault behavior subsystem(s). - Trigger: When the fault activates (Always On, Timed, Conditional, Manual).
- Fault Info File:
<ModelName>_faultInfo.xmlstores all fault metadata alongside the model.
Critical Constraints
- Faults attach to block PORTS, not blocks. You must get the port handle via
get_param(blockPath, 'PortHandles'). - NEVER directly edit
_faultInfo.xmlfiles. Always use MATLAB APIs to modify fault definitions. - Fault names must be valid MATLAB identifiers (no spaces, slashes, or special characters). Use camelCase or PascalCase.
- The fault behavior model name (first arg to
addBehavior) must also be a valid MATLAB identifier. - NEVER use
Simulink.fault.deleteAllorSimulink.fault.deleteFaultto toggle faults on/off for simulation. Deleting faults destroys fault objects, their behavior models (.slx files), and their traceability links permanently. UseSimulink.fault.injection(model, false)to disable ALL fault injection for a nominal run, andSimulink.fault.injection(model, true)to re-enable. UseSimulink.fault.enable(modelElement, false)to disable faults on specific elements. - Not supported: Faults inside Stateflow charts, fault models, or observer models.
Workflow
- Understand the model. Use
model_overviewandmodel_readto identify fragile signal paths -- single-point actuators, sensor feedback, computed quantities with wide fan-out. - Pre-flight check. Query compiled port properties to confirm signal compatibility. If the model is not already compiled, ask the user before compiling. See
references/preflight-and-adding-faults.md. - Get port handles. Faults attach to port handles, not block paths. Use
get_param(blk, 'PortHandles'). - Add fault. Call
Simulink.fault.addFault(portHandle, Name=..., Description=...). Seereferences/preflight-and-adding-faults.md. - Add behavior. Call
addBehavior(fault, modelName, FaultBehavior='mwfaultlib/...'). Seereferences/fault-behaviors.md. - Configure trigger. Set
fault.TriggerTypeand the corresponding properties (e.g.,StartTimefor Timed,Conditionalfor Conditional,TriggerActivefor Manual). Seereferences/triggers-and-conditionals.md. - Save. Call
Simulink.fault.save('ModelName'). - Simulate. Enable injection with
Simulink.fault.injection(mdl, true)thensim(...). Seereferences/simulation-workflows.md.
Guardrails
Always
- Use
model_readto identify target blocks before injecting faults - Check compiled port info before creating faults (see
references/preflight-and-adding-faults.md) - Add behavior BEFORE setting trigger properties
- Save with
Simulink.fault.save('ModelName')after any fault changes - Verify fault is active before running faulted simulation with
activate(fault) - Disable fault injection after analysis with
Simulink.fault.injection(mdl, false) - Verify test input signals are non-zero at fault injection points
- Check bus compatibility before choosing a
mwfaultlibbehavior
Never
- Use the
Simulink.fault.Fault()constructor -- useSimulink.fault.addFault()instead - Pass library block paths (e.g.,
mwfaultlib/Stuck-at-Ground) as the fault model name argument toaddBehavior-- use theFaultBehaviorname-value pair - Assume fault simulation is off -- verify before each nominal run
- Violate any item in the Critical Constraints section
Ask First
- Before modifying the design model for any reason (adding blocks, changing sample times, reconnecting signals)
- Before enabling faults on a model that may be shared (it modifies model behavior)
- Before deleting existing faults (the behavior model .slx is also deleted)
- Before enabling
fault.Persistent = true-- it makes the fault irreversible during simulation
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
Assertion failed in Simulink.fault.Fault() | Do not use the Fault() constructor directly | Use Simulink.fault.addFault(portHandle, Name=..., Description=...) instead |
Fault name must follow MATLAB variable naming conventions | Name contains spaces or special chars | Use camelCase/PascalCase with no spaces (e.g., SensorStuckAtZero) |
Invalid name for a fault model | Behavior model name has invalid characters | Use a simple MATLAB identifier (e.g., StuckAtZero, not Stuck-at-Zero) |
Unable to add fault... only to block input or output ports | Passed a block path/handle instead of port handle | Use ph = get_param(blockPath, 'PortHandles'); ph.Outport(1) |
Target signal is a continuous-time signal | Fault Analyzer cannot inject on continuous signals going to continuous blocks | See Continuous-Time Signal Decision Tree in references/advanced-operations.md |
Output dimensions do not match or Data type mismatch | Fault constant size/type ≠ target signal | See "Vector and Matrix Fault Values" in references/fault-behaviors.md |
| Bus signal fault fails with non-Ground behavior | Most mwfaultlib behaviors are scalar-only | Use Stuck-at-Ground for full bus, or use BusElement to target individual elements |
| Multiple faults on same port but only one fires | Only one fault per port is active at a time | Use activate(fault) to select, or use different StartTime values |
| Fault exists but simulation runs nominally | Fault injection not enabled or fault not active | Call Simulink.fault.injection('Model', true) and activate(f) |
Reference Files
| File | Contents |
|---|---|
references/preflight-and-adding-faults.md | Port inspection, compile checks, adding faults, port handle resolution, fault object properties/methods |
references/fault-behaviors.md | Built-in behaviors, custom behaviors, bus faults, vector/matrix faults, discovery, data inport source |
references/triggers-and-conditionals.md | Trigger types, conditional creation, conditional/symbol object properties |
references/simulation-workflows.md | Running simulations, nominal vs. faulted comparison, selective fault isolation |
references/advanced-operations.md | FMEA linking, reports, export, deletion, continuous-time workarounds, synchronizing faults from referenced models/subsystems/libraries |
references/test-case-integration.md | Adding fault sets to Simulink Test cases (R2024a+) |
Copyright 2026 The MathWorks, Inc.
FAQ
What does the inject-faults skill do?
Add, configure, and manage faults on Simulink, Simscape, and System Composer model signals for robustness analysis and safety validation. Use when injecting faults (stuck, noise, gain, offset) onto block inports/outports, enabling fault simulation, or analyzing fault effects. Covers sensor failures, signal corruptions, actuator faults, FMEA validation, and robustness testing. Requires Simulink Fault Analyzer.
How do I install inject-faults?
Run npx skills add https://github.com/matlab/simulink-agentic-toolkit --skill inject-faults in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/inject-faults/ (personal) or .claude/skills/inject-faults/ (project).
Which AI agents can use inject-faults?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is inject-faults safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains inject-faults?
It is published by matlab in matlab/simulink-agentic-toolkit. It has 51 recorded installs.
More from matlab/simulink-agentic-toolkit
building-simulink-models
matlab/simulink-agentic-toolkit
Builds and edits Simulink, System Composer, Stateflow, and Simscape models. Use when modifying model structure, parameters, ports, connections, or Stateflow chart internals.
simulating-simulink-models
matlab/simulink-agentic-toolkit
Configures Simulink simulations non-destructively using SimulationInput objects — parameter overrides without modifying the model, batch sweeps via parsim, custom input signals via Dataset, and simulation data retrieval via logsout. Use when running sim()/parsim() with setVariable, setBlockParameter, setExternalInput, or when performing parameter sweeps and multi-run analysis. Not needed for one-shot simulations without configuration.
testing-simulink-models
matlab/simulink-agentic-toolkit
Tests Simulink models using either ephemeral Gherkin-based tests (modeltest) for quick validation or persistent tests (Simulink Test API) authored from requirements or behavioral specs. Requires Simulink Test.
specifying-plant-models
matlab/simulink-agentic-toolkit
Specify plant models for closed-loop simulation: system specs, architecture, build plans, validation plans. Use when creating, updating, or reviewing plant model specifications, planning plant model architecture, or planning plant model validation.
specifying-mbd-algorithms
matlab/simulink-agentic-toolkit
Specify algorithms for Model-Based Design: system specs, architecture specs, implementation plans, test plans. Use when creating specifications for controllers, signal processing, diagnostics, estimators, or other algorithms authored in Simulink, Stateflow, System Composer, or MATLAB Function blocks.
generate-requirement-drafts
matlab/simulink-agentic-toolkit
Generates draft requirements from Simulink models. Use when drafting or updating requirement artifacts from a model. Prefers Requirements Toolbox (.slreqx) when available; falls back to structured YAML.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available