Skip to main content
m decompose takes a complex task description and uses an LLM to:
  1. Extract the constraints the output must satisfy
  2. Identify the subtasks needed to complete the goal, with dependency ordering
  3. Generate a prompt template for each subtask
  4. Output a ready-to-run Python script that executes each subtask in order
Prerequisites: Mellea installed (uv add "mellea[cli]"), Ollama running locally (or an OpenAI-compatible endpoint).

Basic usage

Write your task description to a text file, then run:
Note: The output directory must already exist — the command will error if it does not. On first run with Ollama, the default model will be downloaded automatically (~15 GB for the full model). Use --model-id with a smaller model (e.g. granite4.1:3b) to avoid the large download.
This produces a subdirectory under ./output/ (one per task job):
  • ./output/m_decomp_result/m_decomp_result.json — the full decomposition: subtask list, constraints, dependency graph, and prompt templates
  • ./output/m_decomp_result/m_decomp_result.py — a runnable Python script that calls m.instruct() for each subtask in dependency order

Example

Given a task.txt:
Run:
Then execute the generated script:

Backend options

m decompose defaults to Ollama with granite4.1:3b. Pass --backend and --model-id to use a different inference engine:
To see all options:

Python API

Use the decompose pipeline directly from Python:
Each subtask in result["subtasks"] has:

When to use m decompose

m decompose is useful when:
  • A task prompt is too large or complex for a single LLM call
  • The work can be broken into sequential or parallel subtasks
  • You want a first-pass structure you can then edit by hand
  • You are exploring how to decompose a problem before writing code
For tasks that fit comfortably in a single prompt, use m.instruct() directly.
Full example: docs/examples/m_decompose/
See also: Tools and Agents | Refactor Prompts with CLI | CLI Reference