---
name: makima-chain
description: Chain commands for makima multi-contract orchestration. Use when running chains of contracts defined in YAML, checking chain status, or managing contract dependencies.
---

# Makima Chain Commands

Chains are DAGs (directed acyclic graphs) of contracts that work together. Contracts can depend on each other and run in parallel when no dependencies exist.

Environment variables (`MAKIMA_API_URL`, `MAKIMA_API_KEY`) must be set.

## Running Chains

### Run chain from YAML
```bash
makima chain run <yaml_file>
```
Parses the chain definition, validates the DAG, and creates contracts.

Options:
- `--dry-run` - Validate and preview without creating

### Validate chain YAML
```bash
makima chain validate <yaml_file>
```
Checks syntax and validates DAG structure (no cycles).

### Preview chain
```bash
makima chain preview <yaml_file>
```
Shows execution order and contract details without creating.

## Chain Status

### Get chain status
```bash
makima chain status <chain_id>
```

### List all chains
```bash
makima chain list
```
Options:
- `--status <active|completed|archived>` - Filter by status
- `--limit <n>` - Limit results (default: 50)

### List contracts in chain
```bash
makima chain contracts <chain_id>
```

### Display ASCII DAG visualization
```bash
makima chain graph <chain_id>
```
Options:
- `--with-status` - Show contract status in visualization

## Chain Management

### Archive chain
```bash
makima chain archive <chain_id>
```
Marks chain as archived (does not delete contracts).

## Chain YAML Format

```yaml
name: my-chain
description: Optional description
repository_url: https://github.com/org/repo

contracts:
  - name: setup
    contract_type: implementation
    description: Initial setup work

  - name: feature-a
    contract_type: implementation
    depends_on: [setup]
    description: Implement feature A

  - name: feature-b
    contract_type: implementation
    depends_on: [setup]
    description: Implement feature B (parallel with A)

  - name: integration
    contract_type: review
    depends_on: [feature-a, feature-b]
    description: Integrate and test
```

## Output Format

All commands output JSON to stdout.

Example workflow:
```bash
# Validate before running
makima chain validate my-chain.yaml

# Preview execution
makima chain preview my-chain.yaml

# Run the chain
chain_id=$(makima chain run my-chain.yaml | jq -r '.chainId')

# Monitor progress
makima chain status "$chain_id"
makima chain graph "$chain_id" --with-status
```
