Management Commands

django-agents provides several Django management commands for working with agents.

list_agents

List all registered agents in the project.

Usage:

python manage.py list_agents [options]

Options:

  • --verbose: Show detailed information about each agent

  • --app APP: Filter agents by app name

  • --enabled-only: Show only enabled agents

  • --format {table,json,list}: Output format (default: table)

Examples:

# List all agents
python manage.py list_agents

# List agents from specific app
python manage.py list_agents --app myapp

# List with detailed information
python manage.py list_agents --verbose

# Output as JSON
python manage.py list_agents --format json

run_agent

Execute a specific agent manually from the command line.

Usage:

python manage.py run_agent AGENT_NAME [options]

Options:

  • --context JSON: JSON string containing execution context

  • --context-file FILE: Path to JSON file with execution context

  • --app APP: App name where agent is located

  • --async: Execute agent asynchronously (if supported)

  • --output {json,pretty,minimal}: Output format (default: pretty)

Examples:

# Run agent with context
python manage.py run_agent email_notification --context '{"recipient": "user@example.com"}'

# Run with context from file
python manage.py run_agent data_processor --context-file context.json

# Run asynchronously
python manage.py run_agent report_generator --async

create_agent

Create a new agent in an existing Django app.

Usage:

python manage.py create_agent AGENT_NAME APP_NAME [options]

Options:

  • --template {base,async,workflow,api,data}: Agent template type (default: base)

  • --no-tests: Skip test file generation

  • --description DESC: Agent description

  • --overwrite: Overwrite existing agent if it exists

Examples:

# Create basic agent
python manage.py create_agent EmailNotification myapp

# Create async agent
python manage.py create_agent ReportGenerator myapp --template async

# Create with description
python manage.py create_agent DataProcessor myapp --description "Processes CSV data"

# Create without tests
python manage.py create_agent QuickAgent myapp --no-tests

agent_stats

Display execution statistics for all registered agents.

Usage:

python manage.py agent_stats [options]

Options:

  • --agent AGENT: Show stats for specific agent only

  • --app APP: Filter agents by app name

  • --format {table,json,detailed}: Output format (default: table)

  • --sort-by {name,executions,last_run,app}: Sort agents by field (default: name)

Examples:

# Show all agent statistics
python manage.py agent_stats

# Show stats for specific agent
python manage.py agent_stats --agent email_notification

# Show detailed stats
python manage.py agent_stats --format detailed

# Sort by execution count
python manage.py agent_stats --sort-by executions

check_agents_health

Perform health checks on all registered agents.

Usage:

python manage.py check_agents_health [options]

Options:

  • --app APP: Check agents in specific app only

  • --verbose: Show detailed health check information

  • --test-execution: Test agent execution with empty context (may be slow)

Examples:

# Run health checks
python manage.py check_agents_health

# Check specific app
python manage.py check_agents_health --app myapp

# Verbose output with execution tests
python manage.py check_agents_health --verbose --test-execution

generate_context

Generate context files for AI coding assistants.

Usage:

python manage.py generate_context [options]

Options:

  • --output FILE: Output file name (default: agent-context.json)

  • --format {json,yaml}: Output format (default: json)

  • --include-stats: Include agent execution statistics

Examples:

# Generate context file
python manage.py generate_context

# Generate as YAML
python manage.py generate_context --format yaml --output agent-context.yaml

# Include statistics
python manage.py generate_context --include-stats

agent-audit

Run comprehensive project audit.

Usage:

python manage.py agent-audit [options]

Run audits on codebase, tests, settings, and deployment configuration.

startproject

Create a new Django project with django-agents pre-configured.

Usage:

python manage.py startproject PROJECT_NAME [directory]

Creates a new Django project with django-agents already set up.

startapp

Create a new Django app with agent scaffolding.

Usage:

python manage.py startapp APP_NAME [directory]

Creates a new Django app with agents.py file pre-configured.