Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/altaidevorg/rules-for-ai/nnx_modulegit clone --depth 1 https://github.com/altaidevorg/rules-for-aiWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.03606 | $0.03606 |
| Opus 5 | $0.01803 | $0.01803 |
| Sonnet 5 | $0.00721 | $0.00721 |
| Haiku 4.5 | $0.00361 | $0.00361 |
Grade A, and why
nnx_module scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 280 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Chapter 1: nnx.Module
Welcome to the Flax NNX tutorial! This first chapter introduces the cornerstone of building neural networks with NNX: nnx.Module.
Motivation: Pythonic Neural Networks in JAX
JAX provides powerful tools for accelerated numerical computing, particularly automatic differentiation and compilation (XLA). However, its functional nature can sometimes make defining and managing the state (parameters, batch statistics, etc.) of complex neural networks cumbersome.
Traditional Flax (Linen) addressed this with a functional API built around nn.Module, which required special methods (setup, compact) and external state management.
Flax NNX introduces nnx.Module to offer a more intuitive, object-oriented approach. The core idea is simple: define your network layers and models as standard Python classes. State is held directly as instance attributes, initialization happens in __init__, and forward computation is defined in regular methods (like __call__). This leverages familiar Python principles, simplifying debugging, inspection, and overall development workflow, while still integrating seamlessly with JAX's functional transformations through helper APIs.
Central Use Case: Defining a Simple Linear Layer
Let's see how nnx.Module works by defining a basic linear transformation layer.
import jax
import jax.numpy as jnp
from flax import nnx
from flax.nnx.nn import initializers # For parameter initialization
# Define needed RNGs for initialization
rngs = nnx.Rngs(0)
class SimpleLinear(nnx.Module):
def __init__(self, in_features: int, out_features: int, *, rngs: nnx.Rngs):
# Define state (parameters) directly as attributes
# We use nnx.Param, a type of nnx.Variable, to mark learnable parameters
self.kernel = nnx.Param(
initializers.lecun_normal()(rngs.params(), (in_features, out_features))
)
self.bias = nnx.Param(initializers.zeros_init()(rngs.params(), (out_features,)))
def __call__(self, x: jax.Array) -> jax.Array:
# Access state attributes directly in forward computation
y = jnp.dot(x, self.kernel.value) + self.bias.value
return y
# Instantiate the layer like a regular Python class
layer = SimpleLinear(in_features=3, out_features=4, rngs=rngs)
# Create dummy input data
x = jnp.ones((1, 3))
# Call the layer instance directly
y = layer(x)
print(f"Output shape: {y.shape}")
# Output: Output shape: (1, 4)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 280 lines · 3,606 tokens per session scan A 45bc74268992
nnx_module is a cursor rule published in the GitHub repository altaidevorg/rules-for-ai (2 stars, last pushed 1y ago), licensed MIT. It adds 3,606 tokens to every session, about $0.0180 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.