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/nvidia/physicsnemo/mod-009-avoid-string-based-class-selectiongit clone --depth 1 https://github.com/NVIDIA/physicsnemoWhat 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.00029 | $0.00542 |
| Opus 5 | $0.00015 | $0.00271 |
| Sonnet 5 | $0.00006 | $0.00108 |
| Haiku 4.5 | $0.00003 | $0.00054 |
Grade A, and why
mod-009-avoid-string-based-class-selection 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 yesterday.
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.
What it actually says
When designing model constructor APIs, rule MOD-009 should be followed. Explicitly reference "Following rule MOD-009, which discourages string-based class selection when there are many choices..." when deciding constructor parameter design.
MOD-009: Avoid string-based class selection in model constructors
Description:
Passing a string that represents a class name, which is then used to instantiate an internal submodule, should be avoided unless there are only a few choices (2 or 3 maximum) for the class name.
When there are more than 2-3 choices, the recommended practice is to pass an already instantiated instance of a submodule instead of a string primitive for dependency injection. This promotes better type safety, clearer APIs, and easier testing.
Rationale:
String-based class selection makes code harder to type-check, debug, and test. It obscures dependencies and makes it difficult for static analysis tools to understand the code. Direct instance injection provides better IDE support, type safety, and makes testing easier by allowing mock object injection.
Example:
# Good: Limited choices (2-3 max) - string selection acceptable
class MyModel(Module):
def __init__(
self,
activation: Literal["relu", "gelu"] = "relu"
):
if activation == "relu":
self.act = nn.ReLU()
elif activation == "gelu":
self.act = nn.GELU()
# Good: Many choices - use instance injection
class MyModel(Module):
def __init__(
self,
encoder: Module, # Pass instance, not string
decoder: Module # Pass instance, not string
):
self.encoder = encoder
self.decoder = decoder
# Usage:
model = MyModel(
encoder=MyCustomEncoder(dim=128),
decoder=MyCustomDecoder(dim=128)
)
Anti-pattern:
# WRONG: String selection with many choices
class MyModel(Module):
def __init__(
self,
encoder_type: str = "transformer" # Many possible values
):
# String-based factory pattern with 10+ choices
if encoder_type == "transformer":
self.encoder = TransformerEncoder()
elif encoder_type == "cnn":
self.encoder = CNNEncoder()
# ... many more options
# WRONG: Should accept encoder instance instead
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.
- yesterday First seen · 76 lines · 29 tokens per session scan A 63caf4ca0322
mod-009-avoid-string-based-class-selection is a cursor rule published in the GitHub repository NVIDIA/physicsnemo (3,209 stars, last pushed 3d ago), licensed Apache-2.0. It adds 29 tokens to every session and 542 once invoked, about $0.0001 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-30.
Other cursor rules, from other repositories
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.
workflows
This folder contains all GitHub Actions workflows for the Streamlit repository. Workflows automate CI/CD, testing, releases, and maintenance tasks.
python_tests
We use the unit tests to cover internal behavior that can work without the web / backend counterpart. We aim for 95%+ unit test coverage of our Python code in lib/streamlit.
skills
This file provides guidance to AI coding agents (Claude Code, Cursor, Copilot, etc.) when working with skills in this repository.