From lang-julia
Expert guidance for Julia package development following SciML standards, Distributions.jl patterns, and Julia ecosystem best practices
npx claudepluginhub seabbs/skills --plugin lang-juliaThis skill uses the workspace's default tool permissions.
Use this skill when working with Julia packages to ensure proper development workflows, testing patterns, documentation standards, and performance best practices.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Use this skill when working with Julia packages to ensure proper development workflows, testing patterns, documentation standards, and performance best practices.
# Start Julia with project environment
julia --project=.
# Activate project in REPL
using Pkg
Pkg.activate(".")
# Install dependencies
Pkg.instantiate()
# Update dependencies (PREFERRED over direct Project.toml editing)
Pkg.update()
# Add new dependency
Pkg.add("PackageName")
# Add development dependency
Pkg.add("PackageName"; io=devnull) # Then manually move to extras/test deps
# Check package status
Pkg.status()
IMPORTANT: Always use Pkg.update() to update packages.
Never edit Project.toml directly for version updates.
# Run all tests (from project root)
julia --project=. -e 'using Pkg; Pkg.test()'
# Run tests with test environment
julia --project=test test/runtests.jl
# Run tests skipping quality checks (if supported)
julia --project=test test/runtests.jl skip_quality
Test Organization:
TestItemRunner with @testitem syntax for modular testingtest/component/, test/package/test/package/ for quality (Aqua, DocTest, formatting)@testitem "description" begin ... end for individual test itemsExample test structure:
using TestItemRunner
@testitem "Basic functionality" begin
using MyPackage
@test my_function(1) == 2
end
@testitem "Edge cases" begin
using MyPackage
@test_throws ArgumentError my_function(-1)
end
# Build documentation locally
julia --project=docs docs/make.jl
# Build docs skipping notebooks (faster)
julia --project=docs docs/make.jl --skip-notebooks
# or via environment variable
SKIP_NOTEBOOKS=true julia --project=docs docs/make.jl
# Start Pluto server for interactive notebooks
# (check project-specific task or command)
Documentation Structure:
docs/pages.jl or docs/make.jl# Run pre-commit hooks
pre-commit run --all-files
# JuliaFormatter (typically configured in .JuliaFormatter.toml)
# Usually handled by pre-commit hooks
Quality Checks:
Follow SciML (Scientific Machine Learning) coding standards:
Type Stability:
# Good - type stable
function compute(x::Float64)
result = 0.0 # Type is known
for i in 1:10
result += x * i
end
return result
end
# Avoid - type unstable
function compute_bad(x)
result = 0 # Type might change
for i in 1:10
result = result + x * i # Type may vary
end
return result
end
Use @doc with either raw strings or regular strings:
# For simple docstrings without LaTeX or templates
@doc "
Brief description of the function.
# Arguments
- `x`: Description of x
- `y`: Description of y
# Returns
- Description of return value
# Examples
```jldoctest
julia> my_function(1, 2)
3
" function my_function(x, y) return x + y end
@doc raw" Computes the mathematical function:
f(x) = \int_0^x t^2 dt
Use raw strings when including LaTeX to preserve backslashes. " function math_function(x) # implementation end
### DocStringExtensions Templates
**IMPORTANT**: Template expansion rules:
- Use `@doc "` (regular string) for templates (allows expansion)
- Use `@doc """` with escaped backslashes when combining templates with LaTeX
- **NEVER** use `@doc raw"` with templates (prevents expansion)
```julia
using DocStringExtensions
# Good - template will expand
@doc "
$(TYPEDSIGNATURES)
Brief description.
# Fields
$(TYPEDFIELDS)
"
struct MyType
"Field description"
field::Int
end
# Good - template + LaTeX with escaped backslashes
@doc """
\$(TYPEDSIGNATURES)
Computes: ``f(x) = \\int_0^x t^2 dt``
Note the escaped backslashes in LaTeX: \\int, not \int
"""
function combined_function(x)
# implementation
end
# Avoid - raw string prevents template expansion
@doc raw"
$(TYPEDSIGNATURES) # This will NOT expand!
"
@example blocksCross-referencing:
@doc "
Compute the cumulative distribution function.
See also: [`logcdf`](@ref)
"
function cdf(d::MyDist, x::Real)
# implementation
end
@doc "
Compute the log cumulative distribution function.
See also: [`cdf`](@ref)
"
function logcdf(d::MyDist, x::Real)
# implementation
end
Typical Julia package structure:
MyPackage.jl/
├── src/
│ ├── MyPackage.jl # Main module file with exports
│ ├── component1.jl # Component implementations
│ ├── component2.jl
│ ├── docstrings.jl # DocStringExtensions templates
│ └── utils/
├── test/
│ ├── runtests.jl # Main test file
│ ├── component1/ # Tests by component
│ ├── component2/
│ └── package/ # Quality tests (Aqua, formatting)
├── docs/
│ ├── make.jl # Documentation build script
│ ├── src/ # Documentation source
│ └── pages.jl # Page structure (optional)
├── Project.toml # Package dependencies
└── README.md
# Check type stability with @code_warntype
@code_warntype my_function(args...)
# Look for red (Any) types - indicates type instability
# Ensure efficient precompilation
# Use PrecompileTools.jl for complex packages
using PrecompileTools
@compile_workload begin
# Representative workload for precompilation
my_function(example_args...)
end
! suffix convention)@simd, @inbounds when safeStaticArrays.jl for small fixed-size arrays@time, @benchmark (BenchmarkTools.jl)When implementing distributions:
pdf, logpdf, cdf, logcdf, quantile, randminimum, maximum, insupportmean, var, std (if analytically tractable)pdf!, logpdf!, cdf!Ensure compatibility with automatic differentiation:
Avoid non-differentiable operations in AD-sensitive code.
Activate this skill when:
This skill provides Julia-specific development patterns. Project-specific architecture and domain knowledge should remain in project CLAUDE.md files.