package-merge-pattern

Merge LLM-produced function updates into Mathematica .wl package files.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When using an LLM to update Wolfram Language (.wl) package source, naive replacement can overwrite unrelated code, drop or duplicate functions, or produce fragile results that are hard to validate and debug.

Core Features & Use Cases

  • Function-block extraction: Pulls function definitions from both the original code and the LLM response into comparable blocks for targeted merging.
  • Partial and full-file merge logic: Detects when a response likely contains a full file versus only changed parts, then applies the appropriate strategy.
  • New-function insertion with fallbacks: Inserts newly introduced functions into robust locations (including non-standard package structures) and verifies insertion actually occurred.
  • Prompt and response extraction discipline: Uses “return ONLY modified functions” prompting plus delimiter-then-codeblock fallback extraction to reduce truncation and noise.
  • stream-json progress parsing support: Supports incremental parsing of Claude Code progress events to enable reliable real-time UI/status updates.
  • Safety validation checklist: Applies post-merge checks (size/function ratios, structural preservation, and API error detection) to block unsafe overwrites.

Quick Start

Ask your AI to update the Wolfram package by returning only the modified function definitions, then merge them using the package-merge-pattern workflow and run the safety validation checks before accepting the result.

Frequently Asked Questions about package-merge-pattern

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

FAQPage Schema
How do I safely merge LLM generated code into existing Wolfram Language packages?

To merge LLM code into Wolfram Language packages safely, you extract function blocks from both the original source and the LLM response, then apply targeted merging logic to prevent overwriting unrelated code. This process ensures only modified functions are updated.

Why does my LLM code update overwrite unrelated functions in my .wl package?

Overwriting unrelated functions in a .wl package happens when naive replacement strategies are used instead of function-block extraction. By pulling definitions into comparable blocks and applying partial merge logic, only targeted functions are updated without dropping or duplicating existing code.

Can I merge partial code updates from an LLM into a full Mathematica package file?

Yes, you can merge partial code updates by detecting whether the LLM response contains a full file or only changed parts. The merge logic applies the appropriate strategy based on this detection, inserting new functions and verifying the insertion actually occurred.

What is the best way to validate LLM code changes before overwriting a .wl package?

The best way to validate LLM code changes is to apply a post-merge safety validation checklist that checks size and function ratios, verifies structural preservation, and detects API errors. This blocks unsafe overwrites before the merged result is accepted.

How do I parse stream-json progress events when updating Wolfram Language packages?

Parsing stream-json progress events for Wolfram Language package updates is supported through incremental parsing of Claude Code progress events. This enables reliable real-time UI and status updates during the LLM code merging workflow.

Does LLM code merging work with non-standard Mathematica package structures?

Yes, LLM code merging works with non-standard Mathematica package structures by using new-function insertion with fallbacks. It inserts newly introduced functions into robust locations and verifies that the insertion actually occurred within the package.