Skip to main content

Overview

RunTools is used to build AI-powered applications across many domains. Here are common patterns and examples.

Code Review Bot

Automatically review PRs for bugs, security issues, and style.
// Create the agent runtime
const runtime = await rt.runtimes.create({
  slug: 'code-reviewer',
  systemPrompt: `You are an expert code reviewer. Review code for:
- Bugs and logic errors
- Security vulnerabilities  
- Performance issues
- Code style and best practices

Be constructive and specific. Suggest fixes.`,
  model: 'claude-opus-4-5',
  tools: ['bash', 'read_file', 'grep', 'glob'],
});

// Create deployment
const deployment = await rt.deployments.create({
  runtimeSlug: 'code-reviewer',
  templateSlug: 'nodejs-20',
  apiSlug: 'code-reviewer',
});

// Set up GitHub trigger
await rt.triggers.create({
  deployment: 'code-reviewer',
  source: 'github',
  events: ['pull_request.opened', 'pull_request.synchronize'],
  repo: 'myorg/myrepo',
  message: 'Review PR #{{payload.number}}: {{payload.pull_request.title}}',
});

AI Email Assistant

Process emails and draft responses.
const runtime = await rt.runtimes.create({
  slug: 'email-assistant',
  systemPrompt: `You help manage emails:
- Summarize important emails
- Draft professional responses
- Categorize and prioritize
- Extract action items`,
  model: 'claude-sonnet-4',
  tools: ['gmail', 'google_calendar'],
});

// Schedule daily check
await rt.schedules.create({
  deployment: 'email-assistant',
  cron: '0 9 * * *',  // 9 AM daily
  timezone: 'America/New_York',
  message: 'Check my inbox, summarize important emails, and draft responses for urgent ones.',
});

Customer Support Agent

Handle support tickets with context from your docs and database.
const runtime = await rt.runtimes.create({
  slug: 'support-agent',
  systemPrompt: `You are a helpful customer support agent for Acme Corp.
- Search our docs for answers
- Look up customer info when needed
- Escalate complex issues to humans
- Be friendly and professional`,
  model: 'gpt-4o',
  tools: ['tool_search', 'web_search'],  // Dynamic tool discovery
});

// Custom tool for customer lookup
await rt.myTools.create({
  slug: 'customer-lookup',
  name: 'Customer Lookup',
  parameters: {
    type: 'object',
    properties: {
      email: { type: 'string' },
      customerId: { type: 'string' },
    },
  },
  code: `
    export async function execute({ email, customerId }) {
      const res = await fetch(\`\${process.env.API_URL}/customers\`, {
        method: 'POST',
        headers: { 'Authorization': \`Bearer \${process.env.API_KEY}\` },
        body: JSON.stringify({ email, customerId }),
      });
      return await res.json();
    }
  `,
});

Data Pipeline Automation

Process and transform data on schedule.
const runtime = await rt.runtimes.create({
  slug: 'data-processor',
  systemPrompt: 'You process and transform data. Write Python code to clean, transform, and analyze data.',
  model: 'claude-sonnet-4',
  tools: ['bash', 'read_file', 'edit_file', 'postgres'],
});

const deployment = await rt.deployments.create({
  runtimeSlug: 'data-processor',
  templateSlug: 'python-ml',  // Has pandas, numpy, etc.
  apiSlug: 'data-processor',
  mounts: [
    { workspaceId: 'data-warehouse', path: '/data' },
  ],
});

// Schedule nightly processing
await rt.schedules.create({
  deployment: 'data-processor',
  cron: '0 2 * * *',  // 2 AM daily
  message: 'Process new data from /data/raw, clean it, and load into the warehouse.',
});

CI/CD Agent

Run tests, build artifacts, and deploy.
const runtime = await rt.runtimes.create({
  slug: 'ci-agent',
  systemPrompt: `You are a CI/CD assistant:
- Run tests and report results
- Build and package applications
- Deploy to staging/production
- Rollback on failures`,
  model: 'claude-sonnet-4',
  tools: ['bash', 'read_file', 'edit_file', 'github'],
});

// Trigger on push to main
await rt.triggers.create({
  deployment: 'ci-agent',
  source: 'github',
  events: ['push'],
  repo: 'myorg/myrepo',
  filter: { ref: 'refs/heads/main' },
  message: 'Run CI for commit {{payload.head_commit.id}}',
});

Document Generator

Generate reports, docs, or content.
const runtime = await rt.runtimes.create({
  slug: 'doc-generator',
  systemPrompt: 'You generate professional documents. Write clear, well-structured content.',
  model: 'claude-opus-4-5',
  tools: ['bash', 'read_file', 'edit_file', 'web_search'],
});

// Generate weekly report
await rt.schedules.create({
  deployment: 'doc-generator',
  cron: '0 8 * * 1',  // Monday 8 AM
  message: 'Generate weekly status report from the project files in /workspace.',
});

Interactive Development Environment

Embed sandboxes in your app for users to code.
import { RunToolsProvider, Terminal, CodeEditor, PreviewFrame } from '@runtools/react';

function UserIDE({ userId }: { userId: string }) {
  const [sandbox, setSandbox] = useState(null);

  useEffect(() => {
    // Create or resume user's sandbox
    const init = async () => {
      const sb = await rt.sandboxes.create({
        template: 'nodejs-20',
        mounts: [{ workspaceId: `user-${userId}`, path: '/workspace' }],
      });
      setSandbox(sb);
    };
    init();
  }, [userId]);

  if (!sandbox) return <div>Loading...</div>;

  return (
    <RunToolsProvider apiKey={process.env.NEXT_PUBLIC_RUNTOOLS_KEY}>
      <div className="ide-grid">
        <CodeEditor sandboxId={sandbox.id} path="/workspace/index.js" />
        <Terminal sandboxId={sandbox.id} />
        <PreviewFrame sandboxId={sandbox.id} port={3000} />
      </div>
    </RunToolsProvider>
  );
}

Multi-Agent Workflow

Agents that delegate to specialized agents.
// Orchestrator agent
const orchestrator = await rt.runtimes.create({
  slug: 'orchestrator',
  systemPrompt: `You coordinate tasks across specialized agents:
- code-agent: For coding tasks
- research-agent: For research
- writer-agent: For content

Delegate appropriately and synthesize results.`,
  model: 'claude-opus-4-5',
  tools: ['bash', 'read_file'],
});

// Specialized agents
await rt.runtimes.create({
  slug: 'code-agent',
  systemPrompt: 'You are an expert programmer. Write clean, tested code.',
  tools: ['bash', 'read_file', 'edit_file', 'github'],
});

await rt.runtimes.create({
  slug: 'research-agent', 
  systemPrompt: 'You research topics thoroughly using web search.',
  tools: ['web_search', 'read_file', 'edit_file'],
});

// Use AIP for context sharing between agents
const session = await hub.sessions.create({ name: 'Project Alpha' });

// Orchestrator delegates with shared context
const result = await hub.invoke({
  agent: 'orchestrator',
  session: session.id,
  prompt: 'Build a landing page for our new product. Research competitors first.',
});

Smart Home / IoT

Invoke agents from anywhere using AIP.
// AIP enables invocation from any device
// Phone, CLI, voice assistant, smart home, webhook...

// From voice assistant (Siri Shortcut, Alexa Skill)
POST https://api.runtools.ai/.well-known/aip/invoke
{
  "agent": "home-assistant",
  "session": "sess_home",
  "prompt": "Turn off all lights and set alarm for 7am"
}

// From smart button
POST https://api.runtools.ai/v1/triggers/abc123/invoke
{
  "event": "button_press",
  "device": "office_button"
}

Best Practices

Choose python-ml for data tasks, nodejs-20 for web apps, custom for specific needs.
Mount workspaces to persist code and data across sandbox sessions.
Let agents discover tools dynamically instead of hardcoding tool lists.
Share context between agents using AIP sessions and blocks.
Verify trigger configurations work before connecting to production events.