package-hook-installation-patterns

Install safe Wolfram Language hooks with DownValues swapping and Abort-safe restoration.

3|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/transreal/claudecode --skill package-hook-installation-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: package-hook-installation-patterns
Source: https://github.com/transreal/claudecode/tree/main/Claude%20Directives/skills/package-hook-installation-patterns
Command: npx skills add https://github.com/transreal/claudecode --skill package-hook-installation-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents fragile and hard-to-debug integration failures when you hook into another package’s public Wolfram Language symbols while preserving the original behavior and options.

Core Features & Use Cases

  • Safe hook installation templates: Provides verified patterns for wrapping an exported symbol (e.g., ClaudeAttach / ClaudeAttachments) without breaking its Options/attributes or altering call semantics.
  • Correct DownValues swapping with recovery: Ensures idempotent enable/disable cycles by storing original DownValues, restoring them deterministically, and protecting state integrity during Abort.
  • Scheduled-task / worker visibility fallback strategy: Covers cases where Front End-dependent notebook context is invisible, by writing hook side-channel state to a memory registry and reading it via a two-step auto-detect flow.

Use Case: You want to install an additional ingest or auditing side effect whenever a host package’s public function is called, but you must avoid OptionValue::optnf, hook invisibility in scheduled tasks, and permanent hook corruption after Abort.

Quick Start

Use this skill to generate a safe enable/disable hook template for a target symbol by swapping its DownValues, passing through the original implementation, and adding Abort-safe restoration.

Frequently Asked Questions about package-hook-installation-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely hook into a public Wolfram symbol without breaking its Options?

To safely hook into a Wolfram symbol, use a persistent DownValues swap approach with opts___ passthrough. This pattern preserves the original implementation's Options and call semantics while injecting additional side effects.

Why does my Wolfram hook integration fail when called from scheduled tasks?

Scheduled tasks and worker contexts often hide Front End notebook state, making hooks invisible. A two-path fallback writing side-channel state to a memory registry ensures your hook remains visible and functional outside notebooks.

How do I make Wolfram hook enable and disable cycles idempotent?

You achieve idempotent enable/disable cycles by deterministically storing and restoring original DownValues. This prevents permanent hook corruption by ensuring the original state is always recoverable.

What's the best way to prevent hook corruption during an Abort in Wolfram Language?

To prevent hook corruption during Abort, use abort-safe restoration via CheckAbort. This ensures original DownValues are deterministically restored even if an evaluation is interrupted mid-execution.

Can I add auditing side effects to third-party Wolfram package functions?

Yes, you can wrap exported package symbols to add ingest or auditing side effects. By swapping DownValues and passing through the original implementation, you intercept calls without altering the host package's behavior.