agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/ai-ml/ollama/SKILL.md

ollama

Skill15 starsChanged 45 days agoMITView on GitHub

Expert Ollama assistance covering local LLM execution, Modelfile customization, REST API integration, and model quantizations. Use when running open models (Llama, Mistral, DeepSeek) locally on CPU/GPU.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a custom Modelfile:

    line 118
  2. Very specific:

    Use format=Schema.model_json_schema() for reliable structured outputs without regex parsing.

    line 139
  3. Distinctive:

    Run heavy 70B models on systems with less than 64GB unified memory/RAM.

    line 147

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Ollama

Ollama bundles model weights, configurations, and runtime dependencies into a streamlined CLI and local server for running open-source LLMs locally with native tool-calling.

When to Use

  • Local LLM Execution: Running Llama 3, DeepSeek-R1, Mistral, and Qwen locally with a single CLI command.
  • Zero-Cloud Air-Gapped Deployments: Privacy-critical enterprise environments requiring 100% on-premise execution.
  • Custom Modelfile Configuration: Tailoring system prompts, temperature, context length, and stop sequences.
  • REST & OpenAI-Compatible API: Seamless drop-in replacement for OpenAI SDKs in local test and dev pipelines.

Quick Start

# Run open-weight models locally with zero setup
ollama run llama3.2:3b "Write a Python script to compute Fibonacci numbers."
# Query local Ollama instance via Python SDK
import ollama

response = ollama.chat(
    model="llama3.2:3b",
    messages=[{"role": "user", "content": "Explain zero-trust security."}]
)
print(response['message']['content'])

Core Concepts

Local Inference with the Python Ollama SDK

Querying local models with streaming and structured JSON output:

import ollama

# Basic chat completion
response = ollama.chat(
    model='llama3.1:8b',
    messages=[
        {'role': 'system', 'content': 'You are an expert DevOps engineer.'},
        {'role': 'user', 'content': 'Write a minimal production Dockerfile for a Go API.'}
    ],
    options={
        'temperature': 0.2,
        'num_ctx': 8192
    }
)

print(response['message']['content'])

Structured Output with Pydantic & JSON Schema

Enforcing typed JSON responses from local models:

from pydantic import BaseModel
import ollama

class ThreatAnalysis(BaseModel):
    threat_level: str
    vulnerabilities: list[str]
    mitigation: str

response = ollama.chat(
    model='llama3.1:8b',
    messages=[
        {'role': 'user', 'content': 'Analyze the security of an unauthenticated Redis instance exposed to 0.0.0.0.'}
    ],
    format=ThreatAnalysis.model_json_schema(),
    options={'temperature': 0.1}
)

analysis = ThreatAnalysis.model_validate_json(response['message']['content'])
print("Threat Level:", analysis.threat_level)
print("Mitigation:", analysis.mitigation)

Custom Modelfile Authoring

Creating tailored local model artifacts:

# Modelfile
FROM llama3.1:8b

PARAMETER temperature 0.3
PARAMETER num_ctx 16384
PARAMETER stop "<|eot_id|>"

SYSTEM '''
You are Antigravity Code Guardian. You analyze git diffs for security vulnerabilities,
performance regressions, and design pattern anti-patterns. Respond in concise markdown tables.
'''
# Build and register the custom model
ollama create code-guardian -f ./Modelfile
ollama run code-guardian "Review this diff..."

Common Patterns

Custom System Instructions and Temperature via Modelfile

Problem: Re-sending identical system prompts and temperature settings with every API request.

Solution: Create a custom Modelfile:

FROM llama3.2:3b

# Set model temperature
PARAMETER temperature 0.2

# Set system instruction
SYSTEM """
You are a senior DevOps engineer. Always provide answers as copy-pasteable bash or Terraform snippets.
"""

Build model: ollama create devops-assistant -f ./Modelfile

Best Practices

Do:

  • Set OLLAMA_NUM_PARALLEL and OLLAMA_MAX_LOADED_MODELS to handle concurrent local requests efficiently.
  • Use format=Schema.model_json_schema() for reliable structured outputs without regex parsing.
  • Offload models to Apple Silicon Metal or NVIDIA CUDA automatically with proper driver setups.
  • Utilize ollama pull and model tags to test quantized variants (:q4_K_M, :q8_0).

Don't:

  • Expose Ollama port (11434) to the public internet without an authenticating reverse proxy (Nginx, Caddy).
  • Assume default context is unlimited; explicitly set num_ctx: 16384 or higher in options if needed.
  • Run heavy 70B models on systems with less than 64GB unified memory/RAM.

Troubleshooting

ErrorCauseSolution
Error: could not connect to ollama appOllama daemon not running in background.Start daemon with ollama serve.
CUDA out of memory on local GPUModel size exceeds discrete GPU VRAM.Pull a smaller quantization (e.g. q4_0) or specify CPU layers in Modelfile.
pull model failed: unexpected EOFNetwork timeout during multi-gigabyte weight download.Re-run ollama pull <model> to resume download from checkpoint.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.