nerva generate
Generate a new component, its test file, and register it in nerva.yaml.
Usage
nerva generate <type> <name>nerva g <type> <name>g is an alias for generate.
Component types
| Type | Description |
|---|---|
agent | An autonomous agent that handles tasks |
tool | A capability the agent can invoke |
middleware | A pipeline stage that transforms requests or responses |
router | Intent classifier that routes messages to handlers |
What it creates
For each component, the generator:
- Creates the component file from a language-specific template
- Creates a test file in the
tests/directory - Registers the component in
nerva.yamlwith its name and path
Python layout
nerva g agent weather-lookupCreates:
agents/weather-lookup.py # Component filetests/test_weather-lookup.py # Test fileTypeScript layout
nerva g agent weather-lookupCreates:
src/agents/weather-lookup.ts # Component filetests/weather-lookup.test.ts # Test fileDirectory mapping
| Type | Python directory | TypeScript directory |
|---|---|---|
agent | agents/ | src/agents/ |
tool | tools/ | src/tools/ |
middleware | middleware/ | src/middleware/ |
router | routers/ | src/routers/ |
Template variables
Templates receive these variables:
| Variable | Example | Description |
|---|---|---|
name | weather-lookup | Component name as provided (kebab-case) |
class_name | WeatherLookup | PascalCase version of the name |
type | agent | The component type |
description | A agent named weather-lookup | Default description |
nerva.yaml registration
After generation, the component is appended to the appropriate list in nerva.yaml:
agents: - name: weather-lookup path: agents/weather-lookup.pyCustom templates via plugins
The built-in types (agent, tool, middleware, router) use bundled templates. To add custom component types, install a plugin that provides additional templates.
Examples
# Generate an agentnerva generate agent order-processor
# Generate a tool (short alias)nerva g tool web-scraper
# Generate middlewarenerva g middleware rate-limiter
# Generate a routernerva g router intent-classifier