Skip to main content

Custom Templates: Script Your AI Agent

Take complete control over the Cloud Coding API by scripting your AI agent’s exact behavior. Custom messages let you define precise conversation flows, control tool usage, and create powerful development workflows that adapt to your specific needs.
New to Cloud Coding API? Start with prebuilt templates for quick results, then return here when you need complete control over AI behavior.

Quick Start

Define your own custom workflow instead of using prebuilt templates:
Custom messages give you the same AI capabilities as prebuilt templates, but with complete control over the conversation flow and execution steps.

Why Use Custom Messages?

Message Structure

Every message supports these fields:
Critical Limitation: You cannot change workingDir and use continueConversation: true in the same request. When changing directories, you must start a fresh conversation (omit continueConversation or set it to false).

Progressive Examples

Level 1: Single Task

Start with simple, focused tasks:

Level 2: Multi-Step Workflow

Chain related tasks together:

Level 3: Tool-Controlled Workflow

Precisely control which tools are used at each step:

Level 4: Complex Task Planning

Break down complex tasks into manageable steps:

Level 5: Directory-Focused Development

Important: This example shows an incorrect pattern. You cannot change workingDir and use continueConversation: true. Each directory requires a separate API call.
Focus the agent on specific parts of your codebase using separate API calls:

Available Tools

Based on the actual system capabilities, you can specify these tools:

Real-World Workflow Patterns

Feature Development Workflow

Complete feature implementation from planning to deployment:

Security Audit Workflow

Comprehensive security review and fixes:

Code Migration Workflow

Large-scale TypeScript migration using directory-focused approach:

API Refactoring Workflow

Single-directory focused refactoring:

Database Schema Migration

Focused database work:

Advanced Features

Conversation Continuity

Use continueConversation: true to maintain context across messages:

Directory Scoping

Use workingDir to focus the agent on specific parts of your repository:
Note: The example below shows an incorrect pattern - you cannot change workingDir and use continueConversation: true together.

Working Directory Limitations

Critical Technical Constraint: The Cloud Coding API has an important limitation when using workingDir:
  • Cannot combine workingDir changes with continueConversation: true
  • Must use separate API calls for each different working directory
  • 🔧 Technical reason: The AI agent gets mounted to the specified directory and cannot maintain context across different mount points
This limitation is enforced at the system level and cannot be worked around.

Common Mistake

Correct Approach

Best Practices

1. Start Simple, Build Complexity

Then evolve to:

2. Use Descriptive Instructions

❌ Vague: "Fix the code" ✅ Specific: "Add error handling to all API endpoints, including proper HTTP status codes and user-friendly error messages"

3. Strategic Tool Selection

4. Leverage Working Directories

5. Task Planning

Python Integration

Common Patterns Summary

Critical Pattern Limitation: Multi-directory workflows must use separate API calls. You cannot change workingDir and use continueConversation: true in the same request. This is a system-level constraint, not a documentation suggestion.

Next Steps

Ready to build your first custom workflow? Start with:
  1. Simple single message - Get comfortable with the basic structure
  2. Add conversation flow - Try continueConversation: true
  3. Control tools - Specify exact tools for each step
  4. Directory focusing - Use workingDir for targeted development
  5. Complex workflows - Combine all features for powerful automation

Pro Tip

Custom messages give you the power to script any development workflow. Start simple and gradually build more sophisticated automation as you learn the patterns.