Code Mode Tutorial banner
johnlindquist johnlindquist

Code Mode Tutorial

AI community

Description

Comprehensive tutorial and demos for teaching UTCP Code Mode - Transform AI agents from tool callers into code executors

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Code Mode Demos and Teaching Guide

This directory contains comprehensive demos for teaching UTCP Code Mode.

Setup

  1. Ensure you're in the demos directory: cd demos
  2. The .utcp_config.json configures available tools (OpenLibrary API)

Running Demos with Claude CLI

All demos should be run using Claude CLI in **print mode** with specific configurations:

# Basic template for running demos
claude --print \
  --dangerously-skip-permissions \
  --mcp-config '{"mcpServers":{"code-mode":{"command":"npx","args":["@utcp/code-mode-mcp"],"env":{"UTCP_CONFIG_FILE":"'"$(pwd)/.utcp_config.json"'"}}}}' \
  "Your prompt here"

Demo Files

Basic Demos (Remote APIs)

  1. demo-1-basic.sh - Basic code execution without tools
  2. demo-2-discovery.sh - Discovering available tools
  3. demo-3-simple-call.sh - Single tool call execution
  4. demo-4-error-handling.sh - Error handling patterns
  5. demo-5-multi-chain.sh - Chaining multiple tool calls
  6. demo-6-comparison.sh - Traditional vs Code Mode comparison

Advanced Demos (Local Tools)

  1. demo-7-local-tools.sh - Using local Bun/TypeScript tools
  2. demo-8-data-pipeline.sh - Building data pipelines
  3. demo-9-file-processing.sh - File analysis and reporting
  4. demo-10-hybrid-tools.sh - Mixing local and remote tools
  5. demo-11-local-tool-orchestration.sh - Orchestration patterns

Run All Demos

./run-all-demos.sh

Key Concepts to Teach

1. Print Mode vs Interactive Mode

  • --print flag: Non-interactive, outputs response and exits (perfect for testing)
  • Without --print: Interactive session (for conversations)

2. Permissions

  • --dangerously-skip-permissions: Required for automated testing in trusted environments
  • Without this flag: Claude will ask permission for each tool use

3. MCP Configuration

  • MCP servers are configured via JSON
  • UTCP_CONFIG_FILE environment variable points to tool configurations
  • Multiple MCP servers ca