---
title: "Index"
---

# 03 — Automation

Now we shift from manually running prompts to building an automated pipeline. By the end of this section, you'll have a system that:

1. Reads a prompt from a file
2. Runs it through Ollama
3. Extracts any generated code
4. Runs the code and captures the results
5. Feeds errors back to improve the prompt

This is the "agentic loop" — an AI system that can improve itself.

## What We'll Build

| Tool                    | What It Does                                                                |
| ----------------------- | --------------------------------------------------------------------------- |
| **Prompt Runner**       | Bash script that runs a prompt through Ollama                               |
| **Self-Improving Loop** | Feeds errors back into the prompt for the next run                          |
| **File Combiner**       | Merges prompt, code, and test output into a single message for re-prompting |
| **Code Extractor**      | Pulls code blocks out of Ollama responses and saves them as runnable files  |

## The Architecture

```
prompt.txt ──► [Ollama] ──► ollama-output.md
                                  │
                          [Code Extractor]
                                  │
                    ┌─────────────┼─────────────┐
                    ▼             ▼             ▼
              reasoning.md   response.md     code/
                                               │
                                        [Test Runner]
                                               │
                                        test-output.md
                                               │
                          ┌────────────────────┘
                          ▼
                    [File Combiner]
                          │
                    error + prompt + test-output ──► [Ollama] ──► better code
```

This is the full loop. Let's build it piece by piece.

**Note:** In the original walkthrough, the author built this iteratively — the first version used a simple bash script, then the model evolved it into something more sophisticated. The files we reference below are the **final, working versions** of each tool.

**[06 — Prompt Runner →](/run-ai-locally/03-automation/06-prompt-runner/)**
