Lesson

Run Gomplate Prompt Templating against gpt-oss:20b Locally with Ollama

Build one prompt, run it anywhere. Learn to create a unified workflow that sends templated prompts to Claude or a local model with Ollama for max flexibility.

Access
Included
Transcript
Needs source

AI workflows are often tied to specific APIs, making it hard to switch between powerful cloud models (like Claude) and free, private local models (like gpt-oss via Ollama). This lesson demonstrates a powerful and flexible command-line workflow that gives you the best of both worlds.

By combining gomplate for prompt templating with the power of shell pipes, you can direct the same prompt to different AI backends. This allows you to choose the right model for the job—whether you need the raw power of a cloud API or the privacy and cost-savings of a local model—all without changing your core workflow.

The Workflow

This lesson shows you how to:

  • Use gomplate to render a prompt from a template file.
  • Pipe the rendered prompt directly to a local model running with ollama run <model-name>.
  • Easily switch the pipeline to send the same prompt to the claude CLI instead.
  • Use flags like --hidethinking with Ollama for cleaner output.
  • Redirect the final AI-generated response into a markdown file for later use.

Key Benefits

  • Model Agnostic: Seamlessly switch between cloud and local models.
  • Cost-Effective: Use free, local models for development and experimentation.
  • Privacy: Keep sensitive prompts and data on your own machine with local models.
  • Automation: Easily integrate AI generation into your existing shell scripts and workflows.

Commands Used

Pipe a templated prompt to a local Ollama model and stream the output (including the "thinking" process).

gomplate -f prompt.txt | ollama run gpt-oss:20b

Pipe a templated prompt to Ollama, hide the thinking process, and redirect the final output to a file.

gomplate -f prompt.txt | ollama run --hidethinking gpt-oss:20b > next-steps.md

Remove the generated file.

rm next-steps.md

Pipe the same templated prompt to the Claude CLI and redirect the output to a file.

gomplate -f prompt.txt | claude -p > next-steps.md