Skip to content
nerva docs v0.2.1

nerva generate

Generate a new component, its test file, and register it in nerva.yaml.

Usage

Terminal window
nerva generate <type> <name>
nerva g <type> <name>

g is an alias for generate.

Component types

TypeDescription
agentAn autonomous agent that handles tasks
toolA capability the agent can invoke
middlewareA pipeline stage that transforms requests or responses
routerIntent classifier that routes messages to handlers

What it creates

For each component, the generator:

  1. Creates the component file from a language-specific template
  2. Creates a test file in the tests/ directory
  3. Registers the component in nerva.yaml with its name and path

Python layout

Terminal window
nerva g agent weather-lookup

Creates:

agents/weather-lookup.py # Component file
tests/test_weather-lookup.py # Test file

TypeScript layout

Terminal window
nerva g agent weather-lookup

Creates:

src/agents/weather-lookup.ts # Component file
tests/weather-lookup.test.ts # Test file

Directory mapping

TypePython directoryTypeScript directory
agentagents/src/agents/
tooltools/src/tools/
middlewaremiddleware/src/middleware/
routerrouters/src/routers/

Template variables

Templates receive these variables:

VariableExampleDescription
nameweather-lookupComponent name as provided (kebab-case)
class_nameWeatherLookupPascalCase version of the name
typeagentThe component type
descriptionA agent named weather-lookupDefault 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.py

Custom 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

Terminal window
# Generate an agent
nerva generate agent order-processor
# Generate a tool (short alias)
nerva g tool web-scraper
# Generate middleware
nerva g middleware rate-limiter
# Generate a router
nerva g router intent-classifier