Skip to content
Back to skills

Module Authoring

ASecurity

"Author and debug custom Sonnet modules, lazy variables,

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 9, 2026
devopsapi

Works with

  • api

Security analysis

A100/100

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

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill module-authoring --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Module Authoring?

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

Security grade badge for Module Authoring
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-module-authoring/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-module-authoring)

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: module-authoring
description: "Author and debug custom Sonnet modules, lazy variables,
  composition wrappers, and module build contracts."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# Sonnet Module Authoring

Use this sub-skill for custom `snt.Module` classes, `@snt.once` lazy variable creation, variable and submodule inspection, name scopes, `snt.Sequential`, `snt.Deferred`, `snt.BatchApply`, and `snt.build` shape checks.

## Start here

1. Read [references/module-patterns.md](references/module-patterns.md) for concrete authoring patterns.
2. Read [references/api-reference.md](references/api-reference.md) for verified signatures and contracts.
3. Read [references/troubleshooting.md](references/troubleshooting.md) for construction, first-call, and composition failures.
4. Run [scripts/module_contract_smoke.py](scripts/module_contract_smoke.py) for a tiny executable lazy-variable and optional `BatchApply` check.

## Boundaries

- Built-in layers and `snt.nets`: [../layers-and-nets/SKILL.md](../layers-and-nets/SKILL.md).
- Optimizers and training loops: [../training-and-optimization/SKILL.md](../training-and-optimization/SKILL.md).
- Functional `init`/`apply` APIs: [../functional-transforms/SKILL.md](../functional-transforms/SKILL.md).
- Checkpoint/SavedModel/distribution: [../serialization-and-distribution/SKILL.md](../serialization-and-distribution/SKILL.md).

## Minimum module contract

- Subclass `snt.Module` and call `super().__init__(name=name)` in `__init__`.
- Put input-dependent variable creation in a side-effect-only `@snt.once` method that returns `None`.
- Call/build the module before inspecting `variables` or `trainable_variables`.
- Use explicit subclasses for branching or extra call arguments; use `Sequential` only for plain chains.
- Use `Deferred` when one module's constructor depends on another module after first call, and `BatchApply` for applying a 2-D module over extra leading dimensions.

Files in this skill

  • SKILL.md2 KB
  • references/api-reference.md2 KB
  • references/module-patterns.md1.4 KB
  • references/troubleshooting.md1.1 KB
  • scripts/module_contract_smoke.py1.7 KB

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…