Skip to main content
skill CX Codex

jax-best-practices — Claude Code skill: JAX rules

A skill that gives your agent JAX conventions: pure functions, jit, vmap, grad and profiling. Useful when the project actually runs on JAX.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Mindrally/skills --skill jax-best-practices -a claude-code
Open on GitHub

What jax-best-practices does

This skill makes the assistant a JAX specialist. It keeps functional style in view: immutability, pure functions with no side effects, JAX arrays instead of NumPy where that makes sense. Ask the agent to write or refactor JAX code and it works from these rules rather than generic NumPy habits.

Inside are instructions for three transformations. jax.jit for just-in-time compilation, jax.vmap for vectorising over a batch dimension, jax.grad for automatic differentiation. The common traps get their own notes: side effects inside jitted functions, static_argnums for compile-time constants, splitting random keys the right way. There is a performance section too, plus pytrees, custom vjp/jvp, sharding across devices and checkpointing to save memory.

It is a single instruction file, no scripts and no dependencies. Worth installing if your project is on JAX; on a PyTorch or plain NumPy codebase the advice about vmap and pytrees will just confuse the agent.

What it helps with

  • write a jitted function with no side effects
  • vectorise a loop over a batch with vmap
  • compute gradients and pair grad with jit
  • handle nested data as pytrees
  • cut Python overhead in a hot loop

Example prompts for the agent

  • rewrite this loop with jax.vmap and wrap it in jit
  • compute the gradient of this function, split the keys properly
  • my jitted function keeps failing — check it for side effects

How to install jax-best-practices

1Skills CLI (Vercel)

npx skills add Mindrally/skills --skill jax-best-practices -a claude-code

2Manually: put the files in place

~/.claude/skills/jax-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/jax-best-practices/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about jax-best-practices

How do I install jax-best-practices in Claude?

Run npx skills add Mindrally/skills --skill jax-best-practices -a claude-code. The skill file then sits at ~/.claude/skills/jax-best-practices/SKILL.md.

What does jax-best-practices do?

It sets the agent's rules for JAX code: pure functions, jit, vmap, grad, key handling and profiling.

Does it need extra dependencies?

The skill is one instruction file. The only thing it needs to be useful is JAX in your project.

Source text

SKILL.md · Apache-2.0
---
name: jax-best-practices
description: Expert in JAX for high-performance numerical computing and machine learning
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# JAX Best Practices

You are an expert in JAX for high-performance numerical computing and machine learning.

## Core Principles

- Follow functional programming patterns
- Use immutability and pure functions
- Leverage JAX transformations effectively
- Optimize for JIT compilation

## Key Transformations

### jax.jit
- Use for just-in-time compilation to optimize performance
- Avoid side effects in jitted functions
- Use static_argnums for compile-time constants

### jax.vmap
- Vectorize operations over batch dimensions
- Avoid explicit loops when possible
- Combine with jit for best performance

### jax.grad
- Compute gradients automatically
- Use for automatic differentiation
- Combine with jit for efficient gradient computation

## Best Practices

- Write pure functions without side effects
- Use JAX arrays instead of NumPy where possible
- Leverage random key splitting properly
- Profile and optimize hot paths

## Performance

- Minimize Python overhead in hot loops
- Use appropriate dtypes
- Batch operations when possible
- Profile with JAX profiler

## Common Patterns

- Use pytrees for nested data structures
- Implement custom vjp/jvp when needed
- Leverage sharding for multi-device
- Use checkpointing for memory efficiency

© Mindrally · Apache-2.0 · Mindrally/skills

Similar skills

Everything for AI and ML →

From the same set168

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor