Type your feature idea in plain English. Get a professional use case document back.
ucgen is a Python CLI that generates Cockburn-style use case documents from natural language using Ollama or hosted providers.
pip install ucgenollama pull qwen3:8b
ucgen generate "warehouse picker scans barcode before adding item to shipment"export ANTHROPIC_API_KEY=sk-ant-... # Windows: $env:ANTHROPIC_API_KEY=...
ucgen generate "warehouse picker scans barcode before adding item to shipment" --provider anthropic --model claude-sonnet-4-6- One idea -> one use case by default (
ucgen generate). --expandasks AI to discover multiple use cases first, then generates them sequentially.- Output is always grounded in a fixed 4-stage generation pipeline.
A successful run creates a standalone folder per use case:
use-cases/
standalone/
UC-2026-0049-warehouse-picker-scans-barcode/
UC-2026-0049-warehouse-picker-scans-barcode.md
UC-2026-0049-warehouse-picker-scans-barcode.json
report.html # optional: with --report
UC-2026-0049-... .docx # optional: with --docx / --claude
.md: human-readable use case document.json: structuredUseCaseDocumentoutput.docx: optional Word outputreport.html: optional HTML report
You can generate Word documents in two ways after markdown is written:
ucgen generate "register a new patient at reception" --docxucgen generate "register a new patient at reception" --claudeThis launches Claude Code to generate a .docx from the produced markdown.
Requirements:
npm install -g @anthropic-ai/claude-codeBoth flags can be combined. --docx runs first, then --claude:
ucgen generate "register a new patient at reception" --docx --claudeUse this when your idea describes a whole product/workflow, not just one use case:
ucgen generate "A CCTV desktop app monitor for a farm" --expandFlow:
- AI proposes all relevant use cases in a table
- You confirm generation
- ucgen runs the full 4-stage pipeline for each discovered use case
- Final panel summarizes generated IDs/titles
--report: write a single-use-case HTML report in the output folder--quiet: print only generated markdown path(s), ideal for CI/pipes--no-color: disable ANSI color output--provider,--model: override provider/model per run--stdin: read idea from stdin instead of CLI argument
Register New Patient (UC-2026-0049)
---
uc_id: UC-2026-0049
title: Register New Patient
actor: Receptionist
goal_level: user_goal
---
## Preconditions
- Patient identification documents are available
- Registration desk is staffed
## Normal Course
| Step | Actor | Action | System Response |
|------|-------|--------|-----------------|
| 1 | Receptionist | Capture demographics | Validate required fields |
| 2 | Receptionist | Submit registration | Create patient record and assign MRN |
## Success Guarantee
The patient has an active record and can be scheduled for care.Create local config:
ucgen initExample .ucgenrc.toml:
[defaults]
provider = "ollama"
model = "qwen3:8b"
output_dir = "./use-cases"
template = "default"
temperature = 0.3
max_tokens = 4000Generate one use case from a plain-English idea.
ucgen generate "<idea>"Common options:
--expand: discover and generate multiple use cases--report: generate single-use-case HTML report--docx: export native Word file via python-docx--claude: run Claude Code Word generation flow--quiet: output path(s) only--provider,--model: provider/model override--stdin: read idea from stdin--debug: persist debug artifacts on parse failures
Generate multiple use cases from a .txt file (one idea per line) or .yaml list.
ucgen batch ideas.txt
ucgen batch ideas.yaml --reportGenerate pending use cases from a ucgen.yaml project file.
ucgen run
ucgen run --id UC-001
ucgen run --tag bookingShow generation status for use cases in a ucgen.yaml project.
ucgen statusBuild a portfolio HTML report from all generated JSON files.
ucgen report
ucgen report --output ./use-cases/report.html --openValidate generated markdown files against expected structure.
ucgen validate ./use-cases/standaloneCreate a .ucgenrc.toml config in the current directory.
ucgen initScaffold a new ucgen.yaml project definition.
ucgen init-project "Farm CCTV"Log a mistake/correction entry to ucgen memory.
ucgen log --quick "Used wrong provider default in CLI output"Archive or graduate memory entries based on recurrence/staleness rules.
ucgen gc
ucgen gc --dry-runPrint version and provider availability checks.
ucgen versionOllama not reachable
Run ollama serve, then verify with ollama list.
Claude Code not found
Install with npm install -g @anthropic-ai/claude-code.
python-docx missing
Install with pip install python-docx.
Stage 2 retry message
Expected with some models (for example Mistral). Retry auto-corrects structure.
Slow generation
Try --provider groq for faster cloud inference.
MIT — see LICENSE.