Skip to main content

Type your feature idea in plain English. Get a professional use case document back.

Python License PyPI

ucgen is a Python CLI that generates Cockburn-style use case documents from natural language using Ollama or hosted providers.

Install

pip install ucgen

Quick Start

Local (Ollama)

ollama pull qwen3:8b
ucgen generate "warehouse picker scans barcode before adding item to shipment"

Cloud (Anthropic)

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

Core Concepts

  • One idea -> one use case by default (ucgen generate).
  • --expand asks AI to discover multiple use cases first, then generates them sequentially.
  • Output is always grounded in a fixed 4-stage generation pipeline.

What ucgen Writes

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: structured UseCaseDocument output
  • .docx: optional Word output
  • report.html: optional HTML report

Word Document Generation

You can generate Word documents in two ways after markdown is written:

Native python-docx export

ucgen generate "register a new patient at reception" --docx

Claude Code terminal flow

ucgen generate "register a new patient at reception" --claude

This launches Claude Code to generate a .docx from the produced markdown.

Requirements:

npm install -g @anthropic-ai/claude-code

Both flags can be combined. --docx runs first, then --claude:

ucgen generate "register a new patient at reception" --docx --claude

Multi-Use-Case Discovery (--expand)

Use this when your idea describes a whole product/workflow, not just one use case:

ucgen generate "A CCTV desktop app monitor for a farm" --expand

Flow:

  1. AI proposes all relevant use cases in a table
  2. You confirm generation
  3. ucgen runs the full 4-stage pipeline for each discovered use case
  4. Final panel summarizes generated IDs/titles

Useful Flags

  • --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

Example Output Excerpt

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.

Configuration

Create local config:

ucgen init

Example .ucgenrc.toml:

[defaults]
provider = "ollama"
model = "qwen3:8b"
output_dir = "./use-cases"
template = "default"
temperature = 0.3
max_tokens = 4000

Command Reference

ucgen generate

Generate 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

ucgen batch

Generate multiple use cases from a .txt file (one idea per line) or .yaml list.

ucgen batch ideas.txt
ucgen batch ideas.yaml --report

ucgen run

Generate pending use cases from a ucgen.yaml project file.

ucgen run
ucgen run --id UC-001
ucgen run --tag booking

ucgen status

Show generation status for use cases in a ucgen.yaml project.

ucgen status

ucgen report

Build a portfolio HTML report from all generated JSON files.

ucgen report
ucgen report --output ./use-cases/report.html --open

ucgen validate

Validate generated markdown files against expected structure.

ucgen validate ./use-cases/standalone

ucgen init

Create a .ucgenrc.toml config in the current directory.

ucgen init

ucgen init-project

Scaffold a new ucgen.yaml project definition.

ucgen init-project "Farm CCTV"

ucgen log

Log a mistake/correction entry to ucgen memory.

ucgen log --quick "Used wrong provider default in CLI output"

ucgen gc

Archive or graduate memory entries based on recurrence/staleness rules.

ucgen gc
ucgen gc --dry-run

ucgen version

Print version and provider availability checks.

ucgen version

Troubleshooting

Ollama 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.

License

MIT — see LICENSE.

Metadata

Release files for ucgen 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ucgen 0.2.0
File Size Uploaded Provenance
ucgen-0.2.0.tar.gz 99.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ucgen 0.2.0
File Interpreter ABI Platform
ucgen-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 178.5 kB

Release files / ucgen-0.2.0.tar.gz

Download URL ucgen-0.2.0.tar.gz
Size 99.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e0e32c65202780d0d185a04d3e4781bb605754e080051b938398209bf8613592
BLAKE2b-256 checksum
How to use checksums
e013862f07ecdcb646fca7e460c6aafe5acfb0de081e94d491e8b8e28ff0cc53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / ucgen-0.2.0-py3-none-any.whl

Download URL ucgen-0.2.0-py3-none-any.whl
Size 79.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba777a18cecdebde783ab4af709a4a5e5fa5ad8b5f554659e996c8b449a9154e
BLAKE2b-256 checksum
How to use checksums
82a52d5aad2075ff1912f793d281a78e4578307d563406ea2e09f2e3e1386ebf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for ucgen 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page