> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runflow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Agent

> Create new AI agents from templates with rf create

The `rf create` command provides an interactive way to create new agents from pre-built templates. It handles everything: creating the agent on the server, initializing the repository, cloning locally, and installing dependencies.

## Basic Usage

```bash theme={null}
# Interactive mode (recommended)
rf create
```

This will guide you through:

1. Entering the agent name
2. Choosing a template
3. Creating the agent on the server
4. Cloning the repository locally
5. Installing dependencies

## Non-Interactive Mode

Perfect for scripts, CI/CD pipelines, and AI tools (Cursor, Copilot):

```bash theme={null}
# Minimal command
rf create --name my-agent --template starter

# With auto-install (skip dependency prompt)
rf create --name my-agent --template rag-agent --yes

# Short form
rf create -n my-agent -t starter -y
```

## Options

| Option            | Alias | Description                                 | Example              |
| ----------------- | ----- | ------------------------------------------- | -------------------- |
| `--name <name>`   | `-n`  | Agent name (non-interactive)                | `--name support-bot` |
| `--template <id>` | `-t`  | Template ID or name (non-interactive)       | `--template starter` |
| `--yes`           | `-y`  | Auto-install dependencies without prompting | `--yes`              |

## Available Templates

### starter

**Minimal setup, perfect for beginners**

A simple agent with basic configuration. Best for:

* Learning RunFlow basics
* Quick prototyping
* Custom implementations from scratch

```bash theme={null}
rf create --name my-first-agent --template starter --yes
```

### rag-agent

**Agent with knowledge base integration**

Pre-configured with RAG (Retrieval Augmented Generation) capabilities. Best for:

* Customer support bots
* Documentation assistants
* Knowledge-based Q\&A systems

```bash theme={null}
rf create --name support-bot --template rag-agent --yes
```

### webhook-handler

**Process webhooks and integrations**

Specialized template for handling external webhooks. Best for:

* Integration workflows
* Event-driven automation
* Third-party service connections

```bash theme={null}
rf create --name webhook-processor --template webhook-handler --yes
```

## What Gets Created?

When you run `rf create`, the following happens:

1. **Server-side Agent Creation**
   * Agent is created in your RunFlow account
   * Git repository is initialized
   * Template files are added

2. **Local Repository Clone**
   * Repository is cloned to `./agent-name/`
   * All template files are downloaded

3. **Project Configuration**
   * `.runflow/rf.json` is created with agent metadata
   * Contains: `agentId`, `agentName`, `tenantId`

4. **Dependencies Installation** (if confirmed)
   * `npm install` is run automatically
   * Or skipped if `--yes` flag is used

## Complete Workflow Example

```bash theme={null}
# 1. Create agent from template
rf create
# → Enter name: "support-bot"
# → Select template: "rag-agent"
# → Install dependencies: Yes

# 2. Navigate to agent folder
cd support-bot/

# 3. Review the structure
ls -la
# .runflow/rf.json    - Project configuration
# src/               - Agent source code
# package.json       - Dependencies
# README.md          - Template documentation

# 4. Set up knowledge base
rf kb create support-docs
rf kb upload support-docs ./docs/faq.pdf

# 5. Test locally
rf test

# 6. Make your changes
# ... edit src/index.ts ...

# 7. Deploy to production
rf agents deploy
```

## Using with AI Tools

The non-interactive mode is designed for seamless integration with AI coding assistants:

```bash theme={null}
# Cursor / Copilot can execute this directly
rf create --name customer-support --template rag-agent --yes
```

**Why it's AI-friendly:**

* No user interaction required
* All parameters via flags
* Automatic dependency installation with `--yes`
* Predictable output
* Exit codes for success/failure

## Automation & Scripts

Use in bash scripts or CI/CD pipelines:

```bash theme={null}
#!/bin/bash

# Create multiple agents programmatically
agents=("support-bot" "sales-assistant" "feedback-analyzer")

for agent in "${agents[@]}"; do
  rf create --name "$agent" --template rag-agent --yes
  cd "$agent"
  rf kb create "$agent-knowledge"
  cd ..
done
```

## Project Structure

After creation, your agent folder will contain:

```
my-agent/
├── .runflow/
│   └── rf.json          # Agent configuration
├── src/
│   └── index.ts         # Main agent code
├── package.json         # Dependencies
├── tsconfig.json        # TypeScript config
└── README.md           # Template documentation
```

### .runflow/rf.json

This file contains essential metadata:

```json theme={null}
{
  "agentId": "agent_uuid",
  "agentName": "my-agent",
  "tenantId": "tenant_123"
}
```

<Warning>
  Don't delete `.runflow/rf.json` - it's required for `rf test` and `rf agents deploy` to work!
</Warning>

## Common Options Combination

```bash theme={null}
# Quick setup for development
rf create -n dev-agent -t starter -y

# Production RAG agent
rf create -n prod-support -t rag-agent -y

# Webhook handler without dependencies (install later)
rf create -n webhook-handler -t webhook-handler
# → Skip dependency installation when prompted
```

## Troubleshooting

### Template Not Found

```bash theme={null}
rf create --name test --template invalid-template
# Error: Template 'invalid-template' not found
```

**Solution:** Use one of the available templates: `starter`, `rag-agent`, `webhook-handler`

### Agent Name Already Exists

```bash theme={null}
rf create --name existing-agent --template starter
# Error: Agent 'existing-agent' already exists
```

**Solution:** Choose a different name or delete the existing agent first with `rf agents delete`

### Dependencies Installation Failed

If dependency installation fails:

```bash theme={null}
# Navigate to agent folder
cd my-agent/

# Manually install dependencies
npm install

# Or use yarn/pnpm
yarn install
pnpm install
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Test Locally" icon="flask" href="/cli/test">
    Test your newly created agent
  </Card>

  <Card title="Knowledge Base" icon="database" href="/cli/kb">
    Add knowledge base for RAG
  </Card>

  <Card title="Prompts" icon="file-lines" href="/cli/prompts">
    Manage prompt templates
  </Card>

  <Card title="Deploy" icon="rocket" href="/cli/agents">
    Deploy to production
  </Card>
</CardGroup>
