# Usage

Source: https://aunysillyme.dev/projects/decompose/docs/usage/

## Unit map example

From the root of this repository:

```
python3 skills/decompose/scripts/decompose.py --plan skills/decompose/examples/plan.json
```

The bundled map compares three CSV libraries on speed and license, then recommends one. Actual output, exit 0 (table trimmed to four rows):

```
PLAN valid

Advisor review: REQUIRED before picks (S1 read by 3 units)

| unit | parent | clause | type x speed | wave | group | shape | model | machine | runner-up |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| S1 (invalidator) | - | C1 | data x fast | 0 | W0 | single | - | - | - |
| S3.1 | S3 | C2 | research x fast | 0 | W0 | single | - | - | - |
| S2.1 | S2 | C1 | coding x standard | 1 | W1 | single | - | - | - |
| S4 | - | C3 | writing x standard | 2 | - | single | - | - | - |

Waves:
  W0: S1, S3.1, S3.2, S3.3
  W1: S2.1, S2.2, S2.3
  W2: S4
Critical path (minutes): S1 -> S2.3 -> S4, length 11
Serial estimate: 29 minutes. Both figures come from the units' own needs.minutes.
Clause coverage:
  C1 (compare on speed): S1, S2.1, S2.2, S2.3
  C2 (compare on license): S3.1, S3.2, S3.3
  C3 (recommend one): S4
```

The advisor gate fired because S1 is read by three units. The bundled `patch.json` is a sample review: it splits S4 into a draft and a citation check. Apply it with `--apply-patch skills/decompose/examples/patch.json`. Add `--json` for machine-readable output. The model, machine and runner-up columns stay empty until you pick them by the method in [references/picking.md](https://github.com/aunysillyme-dev/aunx-decompose/blob/v0.3.0/skills/decompose/references/picking.md).

Unit map exit codes: `0` valid, `2` every error listed, including unknown types or speeds, clause gaps, false or missing edges, cycles, substeps more than one level deep, and overlapping writes between units that could run at the same time. Dispatch and gate thresholds live under `plan_defaults` in the bundled `recipes.json`; override any of them in your own recipe store.

## Step plan example

From the root of this repository, create `CARD.md`:

```
---
kind: audit
ask: "Review the parser"
---
```

Run:

```
python3 skills/decompose/scripts/decompose.py CARD.md --waves
```

Actual output, exit 0:

```
[
  [
    {
      "id": "audit",
      "kind": "audit",
      "inputs": [
        "ask"
      ],
      "outputs": [
        "audit-result"
      ],
      "deps": [],
      "paths": [],
      "needs": {
        "cpu": 1,
        "ram_gb": 1,
        "gpu": false,
        "disk_gb": 1,
        "tools": []
      }
    }
  ]
]
```

Each outer array entry is a wave. Independent steps share a wave; every prerequisite finishes in an earlier wave. Resource and tool availability still limit execution. Bundled card recipes are `build`, `fix`, `research`, `read`, and `audit`. Set `ship: no` or `push: no` in a card to omit shipping.

For a custom plan, create a fresh temporary directory:

```
steps_dir=$(mktemp -d) || exit 1
steps_file="$steps_dir/steps.json"
```

Write the plan to that new `"$steps_file"` path using the schema in [SKILL.md](https://github.com/aunysillyme-dev/aunx-decompose/blob/v0.3.0/skills/decompose/SKILL.md). Never overwrite an existing file. Use the same path for each command:

```
python3 skills/decompose/scripts/decompose.py --validate "$steps_file" --waves
python3 skills/decompose/scripts/decompose.py --validate "$steps_file" --save-recipe my-plan
```

Step plan exit codes: `0` valid, `2` error, `3` no matching card recipe (a schema is printed so Claude can write the steps). Validation checks the required fields, known kinds, unique IDs, known dependencies, cycles, absolute write paths, and write-path overlap, including parent/child paths, symlink aliases, and existing paths that refer to the same file. Each part of a resolved path is normalized to Unicode NFC and case-folded, so paths differing only by Unicode normalization or letter case are conservatively rejected even when they do not yet exist or the filesystem treats them as distinct. Overlapping writes are rejected even between dependent steps. Combine those writes into one step. Empty `paths` declares no writes.

Recipes save to `$DECOMPOSE_RECIPES` or `~/.claude/decompose/recipes.json`, creating directories as needed. User recipes override bundled recipes by name; `tools_by_kind` and `scopes` merge by kind. Saved names must be new. Saved steps retain their literal inputs and paths. The helper never writes recipes inside the plugin directory, including case variants and directory aliases. Concurrent saves hold an exclusive lock beside the recipe store across reading, checking names, merging, and atomic replacement. On systems without `fcntl`, an exclusive lock file retries for up to 10 seconds, then reports an error. A stale lock file left by an interrupted save on those systems must be removed before saving again.

## What it runs and writes

- Claude runs one Python 3 script, `skills/decompose/scripts/decompose.py`, on the files you name. It uses only the standard library.
- It makes no network requests, sends no data anywhere, installs no packages, and starts no other programs. The plugin has no hooks and no MCP servers.
- It reads the steps, card, plan or patch file you pass and the bundled `recipes.json`.
- It never picks or calls a model or a machine. Picking is a written method for the agent.
- It writes only when you save a recipe: to `$DECOMPOSE_RECIPES` or `~/.claude/decompose/recipes.json`, plus a `.lock` file and a temporary file beside it. It never writes inside the plugin folder.
- Claude is told to keep its working `steps.json` in a new temporary directory, so it does not overwrite your files.
