package-namespace-migration

Prevent Mathematica package namespace shadowing during BeginPackage-based function migration.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents hard-to-debug breakages caused by Mathematica context-resolution and BeginPackage behavior when moving public functions from one package context to another, specifically avoiding unintended symbol shadowing.

Core Features & Use Cases

  • Explains the shadowing root cause: how BeginPackage without the right dependency context path can temporarily remove the original package from $ContextPath and cause usage-only symbols to override real implementations.
  • Provides phase-based safe migration patterns: Phase Q-2a (namespace reservation), Phase Q-2b (full transfer), and Phase C (wrapper/alias during deprecation).
  • Includes concrete failure-mode lessons: covers real failure patterns (self-recursion, usage-only shadowing, and why Off[General::shdw] makes diagnosis harder).
  • Use case: migrate claudecode-related functions into a new Mathematica package context (e.g., splitting claude code management into ClaudePackageManager), while keeping LLMGraphDAGCreate and related infrastructure working.

Quick Start

Ask an AI assistant to review your planned BeginPackage/Remove/migration sequence against the package-namespace-migration skill’s Phase A/B/C patterns and to flag any cases where you would declare usage for an existing public symbol or risk context-path shadowing.

Frequently Asked Questions about package-namespace-migration

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

FAQPage Schema
Why does namespace shadowing happen when moving Mathematica package functions between contexts?

Namespace shadowing happens when BeginPackage removes the original package from $ContextPath, allowing usage-only symbols to override real implementations. This Skill prevents this by enforcing phase-appropriate usage declaration rules and namespace-qualified definitions during context migration.

How do I safely migrate functions to a new Mathematica package context without breaking existing public APIs?

You can safely migrate functions by applying phased migration patterns: namespace reservation, full transfer, and wrapper/alias sequencing during deprecation. This Skill validates your BeginPackage and Remove sequences to ensure context-path behavior remains stable across package boundaries.

What is the best way to prevent self-recursion when refactoring Mathematica package namespaces?

The best way to prevent self-recursion is to apply correct Remove and alias sequencing rules during context migration. This Skill flags failure patterns like usage-only shadowing and DAG handler breakage, enforcing namespace-qualified definitions to avoid unintended recursion.

Can I use deprecation wrappers while keeping LLMGraphDAGCreate and related infrastructure working during package migration?

Yes, you can use deprecation wrappers while keeping infrastructure working by applying Phase C migration patterns. This Skill ensures context-path stability and safe alias sequencing so existing public APIs remain functional across reorganized package boundaries.

Does turning off General::shdw warnings make Mathematica namespace migration safer?

No, turning off General::shdw warnings makes diagnosis harder by hiding shadowing root causes. This Skill identifies why suppressing shadowing warnings obscures context-resolution failures and instead enforces proper usage declaration rules to prevent shadowing proactively.

When should I not use standard BeginPackage refactoring for moving Mathematica package functions?

You should not use standard BeginPackage refactoring without phase-appropriate usage declarations when migrating existing public symbols. This Skill flags cases where declaring usage for an existing symbol risks context-path shadowing, preventing hard-to-debug breakages during package reorganization.