/vibe:skill-jax-patternsfrom vibe
Guides on JAX functional programming patterns: grad, jit, vmap, pmap transforms, composition rules, parameter management, and PRNG key handling.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
JAX transforms pure functions. Every pattern below follows one rule: write a function that takes inputs and returns outputs, with no side effects. Then transform it.
grads = jax.grad(loss_fn)(params, x, y)
loss, grads = jax.value_and_grad(loss_fn)(params, x, y)
Use when: you need gradients for optimization.
Constraint: the function must return a scalar. For non-scalar outputs, use jax.jacobian.
fast_fn = jax.jit(f)
Use when: the function will be called more than once with same-shaped inputs.
Constraint: no Python control flow that depends on traced values. Use jax.lax.cond for conditionals, jax.lax.scan for loops.
batch_fn = jax.vmap(f, in_axes=(None, 0))
Use when: you wrote a function for one example and need it to work on batches.
in_axes specifies which argument axis to batch over. None means do not batch (broadcast).
parallel_fn = jax.pmap(f, axis_name='devices')
Use when: you have multiple GPUs/TPUs and want data parallelism.
Inside the function, jax.lax.pmean(x, 'devices') averages across devices.
Transforms compose. The order matters:
per_example_grads = jax.jit(jax.vmap(jax.grad(loss_fn), in_axes=(None, 0, 0)))
Reading right to left: take gradient of loss_fn, vectorize over examples, compile the result.
Valid compositions:
jit(grad(f)) -- compiled gradient computationjit(vmap(f)) -- compiled batched computationvmap(grad(f)) -- per-example gradientspmap(jit(f)) -- parallel compiled computationgrad(jit(f)) -- gradient of compiled function (same as jit(grad(f)))JAX parameters are pytrees (nested dicts of arrays):
params = {
'layer1': {'w': jnp.zeros((784, 256)), 'b': jnp.zeros(256)},
'layer2': {'w': jnp.zeros((256, 10)), 'b': jnp.zeros(10)},
}
Update all parameters at once:
params = jax.tree.map(lambda p, g: p - lr * g, params, grads)
Count parameters:
n_params = sum(p.size for p in jax.tree.leaves(params))
JAX requires explicit random keys:
key = jax.random.PRNGKey(0)
key, subkey = jax.random.split(key)
noise = jax.random.normal(subkey, shape)
For multiple random operations, split once:
keys = jax.random.split(key, n)
Never reuse a key. Always split before using.
Mutating arrays inside jit: JAX arrays are immutable. Use x.at[i].set(v) instead of x[i] = v.
Using Python print inside jit: print runs during tracing, not execution. Use jax.debug.print("{}", x).
Python if/for inside jit on traced values: Use jax.lax.cond, jax.lax.switch, jax.lax.scan, jax.lax.fori_loop.
Forgetting .block_until_ready(): JAX uses async dispatch. For benchmarking, call .block_until_ready() to wait for actual completion.
Reusing PRNG keys: Two operations with the same key produce the same "random" values. Always split.
Global state in jitted functions: Global variables are captured at trace time. Changes after tracing are invisible. Pass everything as arguments.
@jax.jit.jax.grad or jax.value_and_grad.jax.vmap.jax.pmap.jax.lax primitives.Use JAX when:
Use PyTorch when:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job