The plugin provides a skill that automatically activates when you're working with params-proto code.
Your First Proto Function CLI
Let's start with a simple train function---Just add @proto.cli and params-proto handles the rest.
Create train.py:
python
from params_proto import proto@proto.clidef train( lr: float = 0.001, # Learning rate batch_size: int = 32, # Training batch size epochs: int = 100, # Number of training epochs): """Train a neural network on CIFAR-10.""" print(f"Training: {epochs} epochs, lr={lr}, batch_size={batch_size}")if __name__ == "__main__": train()
That's it! No argparse boilerplate. Just type hints and inline comments.
Training: 100 epochs, lr=0.001, batch_size=32
Overview: Three Decorators
params-proto v3 provides three decorators in two categories:
Config Decorators (define parameter schemas)
Decorator
Scope
Use Case
@proto
Multiple instances
Library code, reusable components
@proto.prefix
Singleton (global)
Namespaced config groups (Model.lr, Training.epochs)
App Decorator (creates CLI entry point)
Decorator
Use Case
@proto.cli
Script entry points—wraps a function or class to parse CLI args
Typical pattern: Define configs with @proto/@proto.prefix, then create an entry point with @proto.cli.
Run it:
bash
$ python train.py --help
usage: train.py [-h] [--lr FLOAT] [--batch-size INT] [--epochs INT]Train a neural network on CIFAR-10.options: -h, --help show this help message and exit --lr FLOAT Learning rate (default: 0.001) --batch-size INT Training batch size (default: 32) --epochs INT Number of training epochs (default: 100)
bash
$ python train.py
Training for 100 epochs Learning rate: 0.001 Batch size: 32
bash
$ python train.py --lr 0.01 --batch-size 64
Training for 100 epochs Learning rate: 0.01 Batch size: 64
Python Namespaces as Config Singletons
As your config grows, classes provide better organization. Use @proto to turn a class into a configuration.
Create config.py:
python
from params_proto import proto@protoclass Params: """Training configuration.""" # Model settings model: str = "resnet50" # Model architecture pretrained: bool = True # Use pretrained weights # Training settings lr: float = 0.001 # Learning rate batch_size: int = 32 # Batch size epochs: int = 100 # Number of epochs # Data settings data_dir: str = "./data" # Data directory num_workers: int = 4 # Number of data loading workers# Access as class attributesprint(f"Training {Params.model} with lr={Params.lr}")# Or create an instanceconfig = Params()print(f"Batch size: {config.batch_size}")
Key difference: Classes use attributes (Params.lr), functions use parameters (train(lr=0.001)).
Composing Configurations from Multiple Locations
For larger projects, split configuration into logical groups using @proto.prefix. This creates namespaced parameters
like --model.name and --training.lr.
Create train_rl.py:
python
from params_proto import proto@proto.prefixclass Model: """Model configuration.""" name: str = "resnet50" # Architecture name pretrained: bool = True # Use pretrained weights dropout: float = 0.5 # Dropout rate@proto.prefixclass Data: """Data configuration.""" dataset: str = "cifar10" # Dataset name data_dir: str = "./data" # Data directory num_workers: int = 4 # Data loading workers@proto.prefixclass Training: """Training hyperparameters.""" lr: float = 0.001 # Learning rate batch_size: int = 32 # Batch size epochs: int = 100 # Number of epochs@proto.clidef main( seed: int = 42, # Random seed device: str = "cuda", # Device to use (cuda/cpu)): """Train a model on a dataset.""" print(f"Training {Model.name} on {Data.dataset}") print(f" LR: {Training.lr}, Batch size: {Training.batch_size}") print(f" Device: {device}, Seed: {seed}")if __name__ == "__main__": main()
Notice how parameters are organized into groups! Run it:
usage: train_rl.py [-h] [--seed INT] [--device STR] [OPTIONS]Train a model on a dataset.options: -h, --help show this help message and exit --seed INT Random seed (default: 42) --device STR Device to use (cuda/cpu) (default: cuda)Model options: Model configuration. --model.name STR Architecture name (default: resnet50) --model.pretrained Use pretrained weights (default: True) --model.dropout FLOAT Dropout rate (default: 0.5)Data options: Data configuration. --data.dataset STR Dataset name (default: cifar10) --data.data-dir STR Data directory (default: ./data) --data.num-workers INT Data loading workers (default: 4)Training options: Training hyperparameters. --training.lr FLOAT Learning rate (default: 0.001) --training.batch-size INT Batch size (default: 32) --training.epochs INT Number of epochs (default: 100)
Run it:
Training resnet50 on cifar10 LR: 0.001, Batch size: 32 Device: cuda, Seed: 42
With custom arguments:
Training vit on cifar10 LR: 0.0001, Batch size: 32 Device: cuda, Seed: 123
Prefixes create organization: Each @proto.prefix class becomes a group in the help text and uses dotted notation
on the CLI.
Summary: Three Patterns
You've learned three core patterns in 10 minutes:
Pattern
Decorator
Use Case
Access Pattern
Functions
@proto.cli
Simple CLIs, scripts
Function parameters
Classes
@proto
Organized configs
Class attributes
Prefixes
@proto.prefix
Multi-namespace configs
Namespaced (e.g., Model.name)
Quick Tips
Type hints are required: params-proto uses type hints for parsing and validation.