AgentsCLI Tools

sw-agent-init

View as MarkdownOpen in Claude

The sw-agent-init command creates new SignalWire agent projects with a pre-configured directory structure, agent class, environment configuration, test scaffolding, and optional virtual environment. It supports local, AWS Lambda, Google Cloud Functions, and Azure Functions deployment targets.

sw-agent-init [project_name] [options]

Running without a project name enters interactive mode with guided prompts.

Options

name
string

Project name. If omitted, sw-agent-init runs in interactive mode and prompts for all configuration values.

--type
stringDefaults to basic

Agent type. Valid values:

  • "basic" — Minimal agent with a single example tool, test scaffolding, and .env config
  • "full" — All features: debug webhooks, post-prompt summary, web UI, basic auth, tests
--platform, -p
stringDefaults to local

Target deployment platform. Valid values:

  • "local" — Standard FastAPI/uvicorn server (default)
  • "aws" — AWS Lambda with handler and SAM template
  • "gcp" — Google Cloud Function with main.py entry point
  • "azure" — Azure Function with function_app.py and host.json
--region, -r
string

Cloud region for serverless platforms. Defaults vary by platform:

  • AWS: us-east-1
  • GCP: us-central1
  • Azure: eastus
--no-venv
flag

Skip virtual environment creation. By default, a .venv directory is created and dependencies are installed. Only applies to local platform.

--dir
string

Parent directory for the project. The project is created as a subdirectory of this path.

Interactive Mode

When run without arguments, sw-agent-init prompts for:

  1. Project name
  2. Project directory
  3. Agent type (basic or full)
  4. Feature selection (toggle individual features)
  5. SignalWire credentials
  6. Virtual environment creation
sw-agent-init

Features available in interactive mode:

FeatureDescription
Debug webhooksReal-time call data printed to console
Post-prompt summaryCall summary handling after conversations
Web UIStatic file serving with status page
Example SWAIG toolSample get_info tool implementation
Test scaffoldingpytest-based test suite
Basic authenticationHTTP basic auth for SWML endpoints

Generated Project Structure

Local Platform

myagent/
agents/
__init__.py
main_agent.py # Main agent implementation
skills/
__init__.py # Reusable skills module
tests/
__init__.py
test_agent.py # Test suite using swaig-test
web/ # Static files (full type only)
index.html
app.py # Entry point
.env # Environment configuration
.env.example # Example configuration
.gitignore
requirements.txt
README.md

Serverless Platforms

PlatformEntry PointAdditional Files
AWS Lambdahandler.pydeploy.sh
GCP Cloud Functionsmain.pydeploy.sh
Azure Functionsfunction_app/__init__.pyhost.json, local.settings.json, deploy.sh

Environment Detection

The generated project auto-detects SignalWire credentials from environment variables:

VariableDescription
SIGNALWIRE_SPACE_NAMEYour SignalWire space
SIGNALWIRE_PROJECT_IDProject identifier
SIGNALWIRE_API_TOKENAPI token

If these are set when running sw-agent-init, they are written into the generated .env file.

Only the CLI reads SIGNALWIRE_SPACE_NAME. RestClient and RelayClient read SIGNALWIRE_SPACE, the full hostname your-space.signalwire.com, so add it to the generated .env if the agent uses either client.

Examples

Basic Local Agent

sw-agent-init support-bot
cd support-bot
source .venv/bin/activate
python app.py
sw-agent-init customer-service --type full
cd customer-service
source .venv/bin/activate
python app.py

AWS Lambda Project

sw-agent-init my-lambda-agent -p aws -r us-west-2
cd my-lambda-agent
# Deploy with SAM CLI
sam build && sam deploy --guided

Google Cloud Function

sw-agent-init my-gcf-agent -p gcp -r us-central1
cd my-gcf-agent
gcloud functions deploy my-gcf-agent --runtime python311 --trigger-http

Azure Function

sw-agent-init my-azure-agent -p azure -r eastus
cd my-azure-agent
func azure functionapp publish <app-name>

Skip Virtual Environment

sw-agent-init myagent --no-venv
cd myagent
pip install -r requirements.txt
python app.py

Testing the Generated Agent

cd myagent
source .venv/bin/activate
# Run the test suite
pytest tests/ -v
# Or use swaig-test directly
swaig-test agents/main_agent.py --dump-swml
swaig-test agents/main_agent.py --list-tools
swaig-test agents/main_agent.py --exec get_info --topic "SignalWire"