How to Build an AI SOP Generator
Generate standard operating procedures from process descriptions using AI.
Jay Banlasan
The AI Systems Guy
Writing SOPs takes forever, so nobody does it. Processes live in people's heads until that person leaves and the knowledge walks out the door. I built an ai sop generator that turns rough process descriptions into formatted, numbered standard operating procedures in minutes.
Describe what you do. The AI structures it into something anyone can follow.
What You Need Before Starting
- Python 3.8+
- An AI API key (Claude)
- Process descriptions (voice notes, rough outlines, or interviews)
- A template format for consistency
Step 1: Define the SOP Template Structure
SOP_TEMPLATE = {
"sections": [
"Purpose",
"Scope",
"Responsibilities",
"Prerequisites",
"Procedure",
"Exceptions",
"Related Documents",
"Revision History"
],
"format": "markdown",
"numbering": "1.1, 1.2, 2.1",
"max_step_length": "2 sentences per step"
}
Step 2: Build the Generator
import anthropic
from datetime import datetime
client = anthropic.Anthropic()
def generate_sop(process_description, department, author):
prompt = f"""Convert this process description into a formal Standard Operating Procedure.
Process Description:
{process_description}
Requirements:
- Number every step (1.1, 1.2, etc.)
- Each step must be one clear action
- Include who is responsible for each step
- Note any decision points or branches
- Add warnings for steps where mistakes are common
- Keep language simple and direct
Format the output as markdown with these sections:
## Purpose (1-2 sentences)
## Scope (who this applies to)
## Responsibilities (role: responsibility list)
## Prerequisites (what must be true before starting)
## Procedure (numbered steps with sub-steps)
## Exceptions (when to deviate from this process)
## Related Documents (leave as placeholders)
Department: {department}
Author: {author}
Date: {datetime.now().strftime('%Y-%m-%d')}"""
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=3000,
messages=[{"role": "user", "content": prompt}]
)
return message.content[0].text
Step 3: Add Version Control
import json
from pathlib import Path
def save_sop(sop_content, title, version=1):
slug = title.lower().replace(" ", "-")
sop_dir = Path("sops") / slug
sop_dir.mkdir(parents=True, exist_ok=True)
filename = f"v{version}-{datetime.now().strftime('%Y%m%d')}.md"
(sop_dir / filename).write_text(sop_content)
metadata = {
"title": title,
"current_version": version,
"created": datetime.now().isoformat(),
"versions": [{
"version": version,
"file": filename,
"date": datetime.now().isoformat(),
"changes": "Initial creation"
}]
}
(sop_dir / "metadata.json").write_text(json.dumps(metadata, indent=2))
return sop_dir / filename
Step 4: Generate SOPs from Voice Notes
If your team records how they do things, transcribe and convert:
def sop_from_transcript(transcript, department):
cleanup_prompt = f"""This is a transcript of someone describing a process.
Extract the actual steps they describe. Ignore filler words, tangents, and
repetition. Return a clean process description.
Transcript:
{transcript[:3000]}"""
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1500,
messages=[{"role": "user", "content": cleanup_prompt}]
)
clean_description = message.content[0].text
return generate_sop(clean_description, department, "Auto-generated from recording")
Step 5: Validate and Review
def validate_sop(sop_content):
prompt = f"""Review this SOP for completeness and clarity.
Check for:
1. Are all steps actionable (starts with a verb)?
2. Are responsibilities clear for each step?
3. Are there any ambiguous instructions?
4. Are decision points clearly marked?
5. Is anything missing that someone new would need?
SOP:
{sop_content[:3000]}
Return a JSON list of issues found."""
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
return message.content[0].text
What to Build Next
Add a review workflow where the process owner approves the generated SOP before it goes live. Track which SOPs get accessed most and which ones generate the most questions, so you know which processes still need clarification.
Related Reading
- Building Your First Automation: A Complete Guide - automation fundamentals
- Input, Process, Output: The Universal AI Framework - the pattern behind every system
- The Compounding Advantage Nobody Talks About - how documented processes compound
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment