fsharp-failure-paths
Make failures in F# code explicit instead of crashing or hiding them. Use when writing or reviewing F# that calls partial functions (List.head, Seq.find, Map.find, .Value), uses failwith, falls back with defaultArg or Option.defaultValue, catches exceptions, or combines several validations into one Result.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install fsharp-skills-fsharp-failure-pathsManual setup by platform
Claude Code
~/.claude/skills/fsharp-skills-fsharp-failure-paths/SKILL.md
Instructions
F# failure paths
The compiler accepts code that crashes on an empty list or hides a missing value.
Human reviewers find these defects, so the agent must find them first.
Review evidence ranks failure-path handling as a top category of human comments on agent F# code.
Model input boundaries with parse-dont-validate.
This skill covers what happens after a call can fail.
Rules
- Do not call a partial function on a value that the type lets be empty or absent.
Use the safe form and handle each case:List.tryHead,Seq.tryFind,Map.tryFind,Optionpattern match.
A pattern match such asfirst :: _is safe when the empty case also has a branch. - Use
failwithandinvalidArgonly for a broken invariant that the caller cannot cause or recover from.
When input, configuration, or a dependency can cause the failure, returnError. - Use
defaultArgandOption.defaultValueonly when the contract defines the default.
When the value is required, report the absence. A default for a removed setting hides the removal and keeps stale behavior. - Do not catch every exception and return empty data. A later step then reports the wrong cause, or reports success.
Catch the exceptions that you expect, and keep the cause in the error:with ex -> Error(RatesUnavailable ex). - When several checks validate independent inputs, return every error.
List.head errorsandResult.bindchains stop at the first error.
Usevalidationfrom FsToolkit.ErrorHandling, or collect theErrorcases into a list. - Check each guard helper with a true and a false condition. A reversed condition compiles and rejects valid input.
Read references/PATTERNS.md for each pattern with its unsafe form and its safe form.
Steps
- List every partial function,
failwith,defaultArg,Option.defaultValue,try ... with, and first-error-only path in the change.
Done when each item is on the list. - For each item, name the input that makes it fail: empty collection, missing key, missing setting, failed dependency, or a second invalid value.
- Change each item that the input can reach to return
Errorwith the cause. Keep eachfailwithonly for a broken invariant, and keep each default only when the contract defines it. - Run the code with each failing input from step 2. Confirm that each one returns an
Errorthat names its cause, and that valid input gives the same result as before.
Verify
Run the proof script from the skill root:
pwsh ./scripts/run.ps1
The script shows each unsafe form failing and each safe form reporting the failure.
It fails when an expected result does not occur.
Security
Reviews (0)
Related skills
Browse all →More from F# Skills
View source →More Build skills
Browse category →Frequently asked questions about fsharp-failure-paths
What does the fsharp-failure-paths skill do?
Make failures in F# code explicit instead of crashing or hiding them. Use when writing or reviewing F# that calls partial functions (List.head, Seq.find, Map.find, .Value), uses failwith, falls back with defaultArg or Option.defaultValue, catches exceptions, or combines several validations into one Result. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the fsharp-failure-paths skill?
Run `npx @skills-hub-ai/cli install fsharp-skills-fsharp-failure-paths` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/fsharp-skills-fsharp-failure-paths/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does fsharp-failure-paths work with?
fsharp-failure-paths runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the fsharp-failure-paths skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use fsharp-failure-paths after installing it?
In Claude Code, type `/fsharp-skills-fsharp-failure-paths` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the fsharp-failure-paths skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.