# Mosaic Stack Orchestration Templates

Templates for consistent orchestration setup within Mosaic Stack.

## Usage

### Variable Substitution

Templates use `${VARIABLE}` syntax. Substitute using `envsubst`:

```bash
# Set variables
export PROJECT="mosaic-stack"
export MILESTONE="M6-Security"
export CURRENT_DATETIME=$(date -Iseconds)

# Generate file from template (paths relative to repo root)
envsubst < docs/templates/orchestrator/tasks.md.template > docs/tasks.md
```

### Validation

Check for unsubstituted variables:

```bash
grep -rE '\$\{[A-Z_]+\}' docs/tasks.md && echo "WARN: Unsubstituted variables" || echo "OK"
```

## Standard Variables

| Variable              | Description          | Example                 |
| --------------------- | -------------------- | ----------------------- |
| `${PROJECT}`          | Project identifier   | `mosaic-stack`          |
| `${MILESTONE}`        | Milestone identifier | `M6-AgentOrchestration` |
| `${CURRENT_DATETIME}` | ISO datetime         | `2026-02-05T20:00:00Z`  |
| `${PHASE_NUMBER}`     | Phase number         | `1`                     |
| `${PHASE_ISSUE}`      | Gitea issue number   | `#337`                  |
| `${PHASE_BRANCH}`     | Feature branch       | `fix/security`          |
| `${TASK_PREFIX}`      | Task ID prefix       | `MS-SEC`                |

## Template Index

| Template                                            | Purpose                         |
| --------------------------------------------------- | ------------------------------- |
| `orchestrator/tasks.md.template`                    | Task tracking table with schema |
| `orchestrator/orchestrator-learnings.json.template` | Variance tracking               |
| `orchestrator/orchestrator-learnings.schema.md`     | JSON schema documentation       |
| `orchestrator/phase-issue-body.md.template`         | Gitea issue body                |
| `orchestrator/compaction-summary.md.template`       | 60% checkpoint format           |
| `reports/review-report-scaffold.sh`                 | Creates report directory        |
| `scratchpad.md.template`                            | Per-task working document       |

## Quick Start

```bash
# From mosaic-stack root
export PROJECT="mosaic-stack"
export MILESTONE="M7-NewFeature"
export CURRENT_DATETIME=$(date -Iseconds)
export TASK_PREFIX="MS-001"
export PHASE_ISSUE="#400"
export PHASE_BRANCH="fix/feature"

# Create tracking files
envsubst < docs/templates/orchestrator/tasks.md.template > docs/tasks.md
envsubst < docs/templates/orchestrator/orchestrator-learnings.json.template > docs/orchestrator-learnings.json

# Create review report structure
./docs/templates/reports/review-report-scaffold.sh codebase-review mosaic-stack
```

## Platform Integration

These templates are part of Mosaic Stack's orchestration system. The orchestrator guide at `docs/claude/orchestrator.md` references these templates.

**Self-contained:** All orchestration tooling ships with the platform. No external dependencies on `~/.claude/` or other repositories.
