notebook-path-policy

Resolve Mathematica output file paths with NotebookDirectory or $packageDirectory fallback.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents broken or unsafe file output behavior by standardizing how Mathematica chooses an output directory when users provide only a filename or a relative path.

Core Features & Use Cases

  • NotebookDirectory-first resolution: Selects NotebookDirectory[InputNotebook[]] when it exists and is a valid directory, otherwise falls back to $packageDirectory.
  • Bare filename and relative path handling: Treats “bare filename” output requests as intended to be placed in the resolved output directory.
  • Explicit absolute path priority: Uses an explicitly provided absolute path as the highest-priority destination to respect user intent.
  • Use Case: When generating result files during a Claude-assisted coding session, ensure outputs consistently land in the notebook’s folder (or the package folder) instead of unpredictable locations.

Quick Start

Use notebook-path-policy to decide whether the output file should be written to NotebookDirectory[InputNotebook[]] or $packageDirectory when the user specifies only a bare filename.

Frequently Asked Questions about notebook-path-policy

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

FAQPage Schema
How do I save Mathematica output files to the notebook directory automatically?▼

Mathematica output files save automatically to the notebook directory by resolving bare filenames through NotebookDirectory[InputNotebook[]] first, applying a fallback policy to $packageDirectory if the notebook directory is invalid or missing.

Why does Mathematica write output files to the wrong directory when I specify a bare filename?▼

Mathematica writes output files to the wrong directory when bare filenames lack a standardized resolution policy. Enforcing a NotebookDirectory-or-$packageDirectory fallback policy directs bare filename outputs to the correct deterministic location instead of unpredictable paths.

Can I use an absolute path to override the NotebookDirectory fallback policy for Mathematica outputs?▼

Explicit absolute paths receive the highest priority and override the NotebookDirectory fallback policy entirely. Providing an absolute path respects user intent by using that exact destination instead of resolving a directory based on the notebook or package location.

What is the best way to ensure deterministic file output routing in Mathematica notebooks?▼

Deterministic file output routing in Mathematica notebooks is achieved by enforcing a fallback policy that selects NotebookDirectory for bare filenames, prioritizes absolute paths, and constructs output paths using OS-independent joining to prevent broken filesystem behavior.

Does Mathematica relative path handling support OS-independent directory joining?▼

Relative path handling in this workflow constructs output paths using OS-independent joining to ensure safe filesystem behavior across platforms. It treats relative outputs as intended for the resolved destination directory selected by the fallback policy.

When should I use $packageDirectory instead of NotebookDirectory for Mathematica output routing?▼

Use $packageDirectory for output routing when NotebookDirectory[InputNotebook[]] does not exist or is not a valid directory. The fallback policy automatically selects $packageDirectory to ensure outputs still land in a safe, predictable package folder location.