Quick Start: Your First Automation Script

Build your first AI-powered automation script in 15 minutes. Learn API authentication, command execution, and immediate verification.

What We're Building

Build a simple AI-powered text summarization script in 15 minutes. This script takes input text, calls the Claude API, and returns a summary. By the end of this quick start, you'll have a working automation you can use immediately.

What You'll Achieve:

  • First working AI automation script
  • Reusable command-line tool
  • Foundation for more complex automations

Prerequisites Check:

Ensure you have these ready before starting:

  • Anthropic API key (from T1.1 Prompt Engineering course)
  • Terminal access (Terminal on macOS/Linux, Git Bash on Windows)
  • Text editor (VS Code, nano, vim, or any editor)

Building Your First Script

Set Up Environment Variables

Create a secure location for your API key using environment variables.

Create a .env file in your project directory:

echo 'export ANTHROPIC_API_KEY="your-key-here"' > .env
source .env

Verify the key is loaded:

echo $ANTHROPIC_API_KEY

Expected output: Your API key should display (first few characters visible).

Create Script File

Create a new shell script file and make it executable.

touch summarize.sh
chmod +x summarize.sh

Verify file permissions:

ls -l summarize.sh

Should display: -rwxr-xr-x (executable permissions set).

Write Minimal Script

Open summarize.sh in your text editor and add this minimal implementation:

#!/bin/bash
curl -X POST https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "content-type: application/json" \
  -d "{\"model\":\"claude-3-5-sonnet-20241022\",\"max_tokens\":1024,\"messages\":[{\"role\":\"user\",\"content\":\"Summarize: $1\"}]}"

Save the file (Ctrl+S or Cmd+S).

Note: This is a concept demonstration. Production scripts require error handling, input validation, and response parsing covered in the Core Build chapter.

Test the Script

Run the script with sample text to verify it works.

./summarize.sh "Artificial intelligence is transforming how we interact with technology. From voice assistants to recommendation systems, AI is becoming increasingly integrated into daily life."

Expected output: JSON response from Claude API containing a summary of the input text.

Verify Success

Confirm your automation works correctly by checking these criteria:

Success Checklist:

  • Script executes without errors
  • Returns AI-generated summary in JSON format
  • Can be reused with different inputs
  • Completes in under 5 seconds

Test with different text:

./summarize.sh "Your own text to summarize here"

Should return a different summary based on new input.

What You Just Built

First Working Automation

Created a functional AI-powered script that accepts input and returns processed results

Reusable Command-Line Tool

Built a tool you can invoke anytime from your terminal with different inputs

Foundation for Advanced Scripts

Established the basic pattern for API authentication, request formatting, and execution

Understanding What Happened

Your script performed these operations:

  1. Environment Loading: Retrieved API key from environment variables
  2. API Authentication: Sent authenticated request to Claude API
  3. Request Formatting: Structured input as JSON message format
  4. Response Handling: Received and displayed AI-generated summary

This 15-minute exercise demonstrates the core workflow all automation scripts follow: authenticate, format request, execute, handle response.

Next Steps

Ready for More?

This quick start created one basic script. The Core Build chapter expands this foundation with four additional automation patterns:

  • Batch processing multiple files
  • Interactive conversation scripts
  • Error handling and logging
  • Response parsing and formatting

Continue to Core Build to transform this concept into production-ready automations.