Wolfram Language Engineer
Purpose
Use this skill to deliver production-quality Wolfram Language work across three common modes:
- Build: create new functions, packages, notebooks, or paclet-ready components.
- Refactor: improve readability, modularity, API design, and maintainability.
- Audit: review correctness, robustness, performance, and developer ergonomics.
Trigger cues
Activate this skill when the request includes:
- Wolfram Language / Mathematica /
.wl / .wls / .nb / paclet development.
- Symbolic transformation rules, pattern matching, UpValues/DownValues, or evaluation-order issues.
- Numeric and mixed symbolic-numeric tasks (NDSolve, optimization, linear algebra, fitting, etc.).
- Requests to debug scoping, assumptions, precision, recursion, memoization, or nontermination.
Response modes
Before implementation, infer or ask for one of these modes:
- Fast fix: minimal safe patch and short explanation.
- Production: polished API, options, validation, tests, and docs.
- Audit-first: issue report first, then prioritized remediation.
Default to Production unless the user explicitly asks for quick iteration.
Core workflow
1) Clarify intent and constraints
Capture:
- expected inputs/outputs and invariants;
- symbolic vs numeric guarantees;
- scale/performance targets;
- notebook-only vs package/paclet destination.
If uncertain, make explicit assumptions and proceed.
2) Choose representation boundaries
Define where each stage happens:
- parsing/normalization;
- symbolic transformation;
- numeric realization;
- formatting/export.
Do not mix stages casually; this prevents evaluation leaks and rewrite blowups.
3) Implement with WL-safe patterns
Prefer:
- clear contexts and public/private split for packages;
OptionsPattern[] with typed option validation;
- explicit failure contracts (
Failure[...], messages, $Failed mapping policy);
- local scoping (
Module, Block, With) chosen intentionally;
- bounded and terminating rewrite systems.
Avoid brittle global state and accidental value capture.
4) Validate and test
Always include:
- nominal examples;
- edge cases (empty, missing, malformed, large, symbolic/numeric mixed);
- at least one failure-path test;
- deterministic behavior checks where order/evaluation matters.
Prefer VerificationTest/TestReport for package code.
5) Audit and harden
Run an explicit pass for:
- performance hotspots;
- precision and exact-arithmetic explosions;
- memoization growth/lifetime;
- UpValue collisions and context pollution;
- notebook hidden state dependencies.
Debugging stance (WL-specific)
When debugging, inspect in this order:
- Evaluation semantics:
Hold* attributes, delayed vs immediate rules, unintended evaluation.
- Pattern specificity: overly broad patterns, missing conditions, precedence pitfalls.
- Rule termination: oscillating rewrites, unbounded
ReplaceRepeated.
- Scope/state: symbol leakage, stale definitions, notebook execution order.
- Numeric stability: precision tracking, machine vs arbitrary precision mismatch.
Useful probes include Trace, TraceScan, FullForm, Definition, DownValues, UpValues, and lightweight timing/memory checks.
Robustness patterns
Input and option validation
- Validate shape/type early; fail loudly with actionable messages.
- Normalize equivalent forms (e.g., scalar/list/association variants) once at boundaries.
- Keep internal forms stable to reduce branch complexity.
Failure signaling
- Use structured
Failure payloads for machine-readable diagnostics.
- Include remediation hints in messages.
- Keep success/failure return conventions consistent across the API.
Rewrite discipline
- Prefer finite, staged transformations over monolithic global rewrite passes.
- Add guards (
Condition/PatternTest) to prevent overmatching.
- Use explicit max-iteration bounds where repeated rewriting is necessary.
Numeric discipline
- Introduce numerics intentionally (
N, SetPrecision) at clear points.
- Avoid exact arithmetic in high-degree / high-dimension operations unless required.
- Use assumptions and domains to constrain simplification.
Refactor & audit playbook
For existing code, produce:
- Findings table: issue, severity, evidence, impact.
- Refactor plan: ordered patches with risk level.
- Implementation: smallest safe sequence of changes.
- Verification: before/after tests and behavior notes.
High-value refactors:
- split public API from kernel internals;
- replace implicit globals with explicit parameters/options;
- extract repeated rule fragments into named transforms;
- convert notebook-only logic into package functions.
Package and paclet progression
When asked to “flesh out” solutions:
- Start with standalone function prototypes.
- Move to package layout with usage messages and tests.
- Add examples and migration notes.
- Optionally package as a paclet once API stabilizes.
Output expectations
Unless user requests otherwise, return:
- concise rationale;
- complete WL code block(s);
- tests/examples;
- known limitations and next improvements.
For audits, include prioritized recommendations (P0/P1/P2).
Reference files
Load only as needed:
references/wl-build-and-refactor.md for implementation and architecture patterns.
references/wl-debugging-and-audit.md for diagnostic checklists and failure modes.
references/wl-performance-and-testing.md for optimization and validation strategy.
1---2name: wolfram-language-engineer3description: Use this skill when users ask to design, implement, debug, refactor, optimize, document, or audit Wolfram Language (Mathematica) code, notebooks, packages, or paclets. Covers symbolic programming patterns, evaluation semantics, numeric workflows, testing, and code-quality review.4---56# Wolfram Language Engineer78## Purpose9Use this skill to deliver production-quality Wolfram Language work across three common modes:101. **Build**: create new functions, packages, notebooks, or paclet-ready components.112. **Refactor**: improve readability, modularity, API design, and maintainability.123. **Audit**: review correctness, robustness, performance, and developer ergonomics.1314## Trigger cues15Activate this skill when the request includes:16- Wolfram Language / Mathematica / `.wl` / `.wls` / `.nb` / paclet development.17- Symbolic transformation rules, pattern matching, UpValues/DownValues, or evaluation-order issues.18- Numeric and mixed symbolic-numeric tasks (NDSolve, optimization, linear algebra, fitting, etc.).19- Requests to debug scoping, assumptions, precision, recursion, memoization, or nontermination.2021## Response modes22Before implementation, infer or ask for one of these modes:23- **Fast fix**: minimal safe patch and short explanation.24- **Production**: polished API, options, validation, tests, and docs.25- **Audit-first**: issue report first, then prioritized remediation.2627Default to **Production** unless the user explicitly asks for quick iteration.2829## Core workflow3031### 1) Clarify intent and constraints32Capture:33- expected inputs/outputs and invariants;34- symbolic vs numeric guarantees;35- scale/performance targets;36- notebook-only vs package/paclet destination.3738If uncertain, make explicit assumptions and proceed.3940### 2) Choose representation boundaries41Define where each stage happens:42- parsing/normalization;43- symbolic transformation;44- numeric realization;45- formatting/export.4647Do not mix stages casually; this prevents evaluation leaks and rewrite blowups.4849### 3) Implement with WL-safe patterns50Prefer:51- clear contexts and public/private split for packages;52- `OptionsPattern[]` with typed option validation;53- explicit failure contracts (`Failure[...]`, messages, `$Failed` mapping policy);54- local scoping (`Module`, `Block`, `With`) chosen intentionally;55- bounded and terminating rewrite systems.5657Avoid brittle global state and accidental value capture.5859### 4) Validate and test60Always include:61- nominal examples;62- edge cases (empty, missing, malformed, large, symbolic/numeric mixed);63- at least one failure-path test;64- deterministic behavior checks where order/evaluation matters.6566Prefer `VerificationTest`/`TestReport` for package code.6768### 5) Audit and harden69Run an explicit pass for:70- performance hotspots;71- precision and exact-arithmetic explosions;72- memoization growth/lifetime;73- UpValue collisions and context pollution;74- notebook hidden state dependencies.7576## Debugging stance (WL-specific)77When debugging, inspect in this order:781. **Evaluation semantics**: `Hold*` attributes, delayed vs immediate rules, unintended evaluation.792. **Pattern specificity**: overly broad patterns, missing conditions, precedence pitfalls.803. **Rule termination**: oscillating rewrites, unbounded `ReplaceRepeated`.814. **Scope/state**: symbol leakage, stale definitions, notebook execution order.825. **Numeric stability**: precision tracking, machine vs arbitrary precision mismatch.8384Useful probes include `Trace`, `TraceScan`, `FullForm`, `Definition`, `DownValues`, `UpValues`, and lightweight timing/memory checks.8586## Robustness patterns8788### Input and option validation89- Validate shape/type early; fail loudly with actionable messages.90- Normalize equivalent forms (e.g., scalar/list/association variants) once at boundaries.91- Keep internal forms stable to reduce branch complexity.9293### Failure signaling94- Use structured `Failure` payloads for machine-readable diagnostics.95- Include remediation hints in messages.96- Keep success/failure return conventions consistent across the API.9798### Rewrite discipline99- Prefer finite, staged transformations over monolithic global rewrite passes.100- Add guards (`Condition`/`PatternTest`) to prevent overmatching.101- Use explicit max-iteration bounds where repeated rewriting is necessary.102103### Numeric discipline104- Introduce numerics intentionally (`N`, `SetPrecision`) at clear points.105- Avoid exact arithmetic in high-degree / high-dimension operations unless required.106- Use assumptions and domains to constrain simplification.107108## Refactor & audit playbook109For existing code, produce:1101. **Findings table**: issue, severity, evidence, impact.1112. **Refactor plan**: ordered patches with risk level.1123. **Implementation**: smallest safe sequence of changes.1134. **Verification**: before/after tests and behavior notes.114115High-value refactors:116- split public API from kernel internals;117- replace implicit globals with explicit parameters/options;118- extract repeated rule fragments into named transforms;119- convert notebook-only logic into package functions.120121## Package and paclet progression122When asked to “flesh out” solutions:1231. Start with standalone function prototypes.1242. Move to package layout with usage messages and tests.1253. Add examples and migration notes.1264. Optionally package as a paclet once API stabilizes.127128## Output expectations129Unless user requests otherwise, return:130- concise rationale;131- complete WL code block(s);132- tests/examples;133- known limitations and next improvements.134135For audits, include prioritized recommendations (P0/P1/P2).136137## Reference files138Load only as needed:139- `references/wl-build-and-refactor.md` for implementation and architecture patterns.140- `references/wl-debugging-and-audit.md` for diagnostic checklists and failure modes.141- `references/wl-performance-and-testing.md` for optimization and validation strategy.