julia-scratch/SKILL.md
Use Scratch.jl for package-specific mutable data containers (caches, compiled objects, host-specific data). Use this skill when storing or managing scratch spaces in Julia packages.
npx skillsauth add krastanov/juliallmagentskills julia-scratchInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use Scratch.jl to create and manage mutable, package-specific data directories for caches, compiled objects, and machine-specific data.
Scratch spaces are not user-facing -- don't use them for files users access via file browsers. For user-facing output, write to a user-specified path instead.
Always initialize scratch paths in __init__() for relocatability:
module MyPackage
using Scratch
download_cache = ""
function __init__()
global download_cache = @get_scratch!("downloaded_files")
end
function download_dataset(url)
fname = joinpath(download_cache, basename(url))
if !isfile(fname)
download(url, fname)
end
return fname
end
end # module
The @get_scratch! macro automatically detects the calling module's UUID. The verbose
equivalent uses get_scratch!:
function __init__()
global download_cache = get_scratch!(@__MODULE__, "downloaded_files")
end
Check contents after get_scratch! to handle users who called clear_scratchspaces!():
function get_dataset_dir()
dataset_dir = @get_scratch!("dataset")
if isempty(readdir(dataset_dir))
perform_expensive_dataset_generation(dataset_dir)
end
return dataset_dir
end
Incorporate package version into the key to isolate data across versions:
module VersionSpecificExample
using Pkg.TOML, Scratch
function get_version()
return VersionNumber(TOML.parsefile(joinpath(dirname(@__DIR__), "Project.toml"))["version"])
end
const pkg_version = get_version()
const version_specific_scratch = Ref{String}()
function __init__()
scratch_name = "data_for_version-$(pkg_version.major).$(pkg_version.minor)"
global version_specific_scratch[] = @get_scratch!(scratch_name)
end
end # module
Pkg.gc() removes scratch spaces for uninstalled packages (Julia 1.6+).clear_scratchspaces!(pkg).clear_scratchspaces!().delete_scratch!(key; pkg_uuid).When data is mature and ready to share, export it as an immutable Artifact:
using Pkg, Scratch, Pkg.Artifacts
function export_scratch(scratch_name::String)
scratch_dir = @get_scratch!(scratch_name)
hash = create_artifact() do artifact_dir
rm(artifact_dir)
cp(scratch_dir, artifact_dir)
end
mktempdir() do upload_dir
tarball_path = joinpath(upload_dir, "$(scratch_name).tar.gz")
tarball_hash = archive_artifact(hash, tarball_path)
tarball_url = upload_tarball(tarball_path) # user-defined upload function
bind_artifact!(
joinpath(@__DIR__, "Artifacts.toml"),
scratch_name,
hash;
download_info=[(tarball_url, tarball_hash)],
force=true,
)
end
end
Set JULIA_SCRATCH_TRACK_ACCESS=0 to disable logging to logs/scratch_usage.toml.
julia-package-dev - Package development workflowsjulia-package-dev - Package bootstrapping (add Scratch.jl as a dependency)julia-toml - TOML parsing (used for version-specific scratch keys)testing
Run and write Julia tests with Test.jl, TestItemRunner.jl, and ParallelTestRunner.jl. Use when organizing test suites, choosing a test runner, or filtering package tests.
tools
Create and develop Julia packages in local environments, including package bootstrapping, multi-package workspaces, package extensions, and Pkg apps. Use when starting a package or managing package environments, dependencies, structure, and related development workflows.
development
Analyze Julia code with JET.jl for type errors, undefined references, and optimization failures. Use this skill when setting up or running JET analysis on Julia packages.
development
Fix trailing whitespace and ensure files end with newlines. Use this skill when preparing code for commit or when whitespace issues are detected.