dialyzer-analysis
Use when analyzing and fixing Dialyzer warnings and type discrepancies in Erlang/Elixir code.
What this skill does
# Dialyzer Analysis
Understanding and fixing Dialyzer warnings in Erlang and Elixir code.
## Type Specifications
### Basic Specs
```elixir
@spec add(integer(), integer()) :: integer()
def add(a, b), do: a + b
@spec get_user(pos_integer()) :: {:ok, User.t()} | {:error, atom()}
def get_user(id) do
# implementation
end
```
### Complex Types
```elixir
@type user :: %{
id: pos_integer(),
name: String.t(),
email: String.t(),
role: :admin | :user | :guest
}
@spec process_users([user()]) :: {:ok, [user()]} | {:error, String.t()}
```
### Generic Types
```elixir
@spec map_values(map(), (any() -> any())) :: map()
@spec filter_list([t], (t -> boolean())) :: [t] when t: any()
```
## Common Warnings
### Pattern Match Coverage
```elixir
# Warning: pattern match is not exhaustive
case value do
:ok -> :success
# Missing :error case
end
# Fixed
case value do
:ok -> :success
:error -> :failure
_ -> :unknown
end
```
### No Return
```elixir
# Warning: function has no local return
def always_raises do
raise "error"
end
# Fixed with spec
@spec always_raises :: no_return()
def always_raises do
raise "error"
end
```
### Unmatched Returns
```elixir
# Warning: unmatched return
def process do
{:error, "failed"} # Return value not used
:ok
end
# Fixed
def process do
case do_something() do
{:error, reason} -> handle_error(reason)
:ok -> :ok
end
end
```
### Unknown Functions
```elixir
# Warning: unknown function
SomeModule.undefined_function()
# Fixed: ensure function exists or handle dynamically
if Code.ensure_loaded?(SomeModule) and
function_exported?(SomeModule, :function_name, 1) do
SomeModule.function_name(arg)
end
```
## Type Analysis Patterns
### Union Types
```elixir
@type result :: :ok | {:ok, any()} | {:error, String.t()}
@spec handle_result(result()) :: any()
def handle_result(:ok), do: nil
def handle_result({:ok, value}), do: value
def handle_result({:error, msg}), do: Logger.error(msg)
```
### Opaque Types
```elixir
@opaque internal_state :: %{data: map(), timestamp: integer()}
@spec new() :: internal_state()
def new, do: %{data: %{}, timestamp: System.system_time()}
```
### Remote Types
```elixir
@spec process_conn(Plug.Conn.t()) :: Plug.Conn.t()
@spec format_date(Date.t()) :: String.t()
```
## Success Typing
Dialyzer uses success typing:
- Approximates what a function can succeed with
- Different from traditional type systems
- May miss some errors, but no false positives (in theory)
### Example
```elixir
# Dialyzer infers: integer() -> integer()
def double(x), do: x * 2
# More specific spec
@spec double(pos_integer()) :: pos_integer()
def double(x) when x > 0, do: x * 2
```
## Best Practices
1. **Start with Core Modules**: Add specs to public APIs first
2. **Use Strict Types**: Prefer specific types over `any()`
3. **Document Assumptions**: Use specs to document expected behavior
4. **Test Specs**: Ensure specs match actual behavior
5. **Iterative Fixing**: Fix warnings incrementally
## Debugging Tips
### Verbose Output
```bash
mix dialyzer --format dialyzer
```
### Explain Warnings
```bash
mix dialyzer --explain
```
### Check Specific Files
```bash
mix dialyzer lib/my_module.ex
```
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.