Templates You Can Copy and Modify
Session 4.6 · ~5 min read
Starting From Zero vs Starting From a Template
Writing code from scratch requires knowing the language, the libraries, and the conventions. Modifying a working template requires knowing what you want to change. The difference is enormous. Templates let you produce working tools on day one, even if you have never written a line of Python.
This session provides four template scripts. Each one is a building block of the production pipeline you will assemble throughout this course. Copy them. Run them. Modify the variables. Break them. Fix them with your AI assistant. That process, repeated, is how you learn to operate the pipeline.
Templates are not training wheels. Professional developers use templates, boilerplate code, and starter kits constantly. The skill is not writing everything from memory. The skill is knowing which template to use and how to adapt it.
Template 1: Single API Call
The simplest building block. It sends one prompt to one AI model and saves the response. Every pipeline starts here.
| Component | What It Does | What You Modify |
|---|---|---|
| API client setup | Connects to the AI service using your API key | API key location, model name |
| System prompt | Sets the AI's role and constraints | The entire system prompt text |
| User prompt | The specific task or question | The task description |
| Parameters | Temperature, max tokens, model selection | Values based on content type |
| Output handling | Saves the response to a file | Output filename and format |
The structure of the script follows a predictable flow: load configuration, build the request, send it, save the result. When you read a template for the first time, trace this flow. Ignore the syntax. Follow the logic.
Read API key"] --> B["Define system prompt
Define user prompt"] B --> C["Set parameters
temperature, max_tokens, model"] C --> D["Send API request"] D --> E{"Response received?"} E -->|Yes| F["Save to output file"] E -->|No| G["Print error message"] style A fill:#222221,stroke:#c8a882,color:#ede9e3 style B fill:#222221,stroke:#6b8f71,color:#ede9e3 style C fill:#222221,stroke:#8a8478,color:#ede9e3 style D fill:#222221,stroke:#c47a5a,color:#ede9e3 style F fill:#222221,stroke:#6b8f71,color:#ede9e3
Template 2: Batch Processor
The batch processor reads a list of tasks from a CSV file and runs the single API call template for each row. If the CSV has 20 rows, the script produces 20 outputs. The same system prompt applies to every row, but the user prompt changes based on the row's data.
This is where scale begins. Instead of running a script once and copying in a new prompt, you define all your tasks in a spreadsheet and let the script work through them. Human involvement drops from "per piece" to "per batch."
Template 3: Output Formatter
Raw AI output is plain text. Your publishing pipeline needs HTML, markdown with specific headers, or JSON. The output formatter takes a raw generation and reshapes it. It might add metadata headers, convert markdown to HTML, strip unwanted formatting, or split a long output into sections.
This template is simple but important. It decouples generation from formatting. You can change how content is formatted without changing how it is generated, and vice versa.
Template 4: Quality Checker
The quality checker scans an output file for known problems: AI artifact phrases ("it's important to note"), excessive hedge words, missing sections, word count violations, and formatting errors. It produces a report listing every issue found.
This is not a replacement for human review. It is a pre-filter that catches the obvious problems before a human spends time reading. If the quality checker flags 15 issues, the piece probably needs regeneration, not editing.
| Template | Input | Output | When to Use |
|---|---|---|---|
| Single API Call | One prompt | One generation | Testing prompts, single-piece production |
| Batch Processor | CSV of tasks | Multiple generations | Producing content at scale |
| Output Formatter | Raw generation | Formatted output | Preparing content for publishing |
| Quality Checker | Any text file | Issue report | Pre-screening before human review |
How to Modify a Template
The modification process is always the same. Open the template in VS Code. Read the comments (every template should be heavily commented). Find the variable you want to change. Change it. Run the script. If it breaks, paste the error into your AI assistant.
Start with the smallest possible change. If the template generates a blog post, change it to generate a product description by modifying only the system prompt and user prompt. Keep everything else identical. Verify it works. Then change the next variable. One change at a time is slower than changing everything at once, but it is debuggable. Changing everything at once is not.
Further Reading
- Prompt Engineering Guide, OpenAI API documentation
- Prompt Engineering with Claude, Anthropic documentation
- Tavily Python SDK, GitHub repository
Assignment
Ask your AI coding assistant to create the Single API Call template as described above. Modify the system prompt to generate something relevant to your work. Change the temperature to 0.3. Run it. Read the code comments. Change the temperature to 0.8 and run it again. Compare the outputs. You are now iterating on code.