Skip to content
Back to skills

Extend Primitives

ASecurity

"Route custom primitive authoring, staged VJP/JVP closures,

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
documentationpythonapi

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill extend-primitives --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Extend Primitives?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Extend Primitives
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-extend-primitives/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-extend-primitives)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: extend-primitives
description: "Route custom primitive authoring, staged VJP/JVP closures,
  deprecated wrapper compatibility, and gradient checking."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# extend-primitives

Use this sub-skill when a user needs to make a new primitive differentiable or extend an existing primitive with custom reverse- or forward-mode rules.

## Route here for
- `primitive`-based authoring of custom primitives.
- staged `defvjp`, `defjvp`, `defvjp_argnums`, and `defjvp_argnums` closures.
- compatibility work for deprecated `.defvjp`, `.defgrad`, and `.defvjp_is_zero` wrappers.
- gradient checking with `check_grads` and `combo_check`.

## Route elsewhere for
- ordinary differentiation-operator questions, Jacobians, Hessians, and higher-level derivative semantics: [differentiation-core](../differentiation-core/SKILL.md)
- built-in NumPy/SciPy wrapper behavior, array protocol behavior, and wrapper limits: [numpy-scipy-primitives](../numpy-scipy-primitives/SKILL.md)

## Evidence anchors
`autograd/extend.py`, `autograd/core.py`, `autograd/test_util.py`, `docs/updateguide.md`, `docs/tutorial.md`, `examples/define_gradient.py`, `tests/test_wrappers.py`

## Bundled runtime files
- `references/api-reference.md`
- `references/workflows.md`
- `references/troubleshooting.md`
- `scripts/custom_primitive_smoke.py`

## Operating guidance
1. Start from `autograd.extend.primitive`.
2. Register a staged VJP/JVP rule immediately after the primitive is defined.
3. Use the staged maker to capture only the forward-pass values needed by the derivative.
4. Prefer `defvjp_argnums` / `defjvp_argnums` when one cached calculation should serve several argnums.
5. Use `None` only when a rule is intentionally zeroed; omit the argnum entirely when you want the missing-path `NotImplementedError`.
6. Validate tiny fixtures with `check_grads`; use `combo_check` when several positional or keyword combinations need coverage.
7. Keep deprecated wrapper APIs only for compatibility with existing code and test fixtures; new authoring should use the staged API.

## Quick smoke
Run `python scripts/custom_primitive_smoke.py` before handing off a draft.

## Cross-links
- `differentiation-core` for operator semantics and derivative wrappers.
- `numpy-scipy-primitives` for primitives that wrap ndarray or SciPy behavior.

Files in this skill

  • SKILL.md2.3 KB
  • references/api-reference.md2.8 KB
  • references/troubleshooting.md1.7 KB
  • references/workflows.md1.7 KB
  • scripts/custom_primitive_smoke.py956 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.