<purpose>
Switch the model profile used by GMD agents. Controls how the universal profile × complexity table (the 9-cell `COMPLEXITY_MODEL` in `bin/lib/core.cjs`) scales model selection for every spawn site. Users pick a row; workflows pick a column per Task spawn.
</purpose>

<required_reading>
Read all files referenced by the invoking prompt's execution_context before starting.

@C:/Users/Christopher/.claude/get-magic-done/references/model-profiles.md
@C:/Users/Christopher/.claude/get-magic-done/references/model-profile-resolution.md
</required_reading>

<process>

<step name="validate">
Validate argument:

```
if $ARGUMENTS.profile not in ["quality", "balanced", "budget"]:
  Error: Invalid profile "$ARGUMENTS.profile"
  Valid profiles: quality, balanced, budget
  EXIT
```
</step>

<step name="ensure_and_load_config">
Ensure config exists and load current state:

```bash
node "$HOME/.claude/get-magic-done/bin/gmd-tools.cjs" config-ensure-section
INIT=$(node "$HOME/.claude/get-magic-done/bin/gmd-tools.cjs" state load)
if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
```

This creates `.planning/config.json` with defaults if missing and loads current config.
</step>

<step name="update_config">
Update the `model_profile` field in `.planning/config.json`:

```bash
node "$HOME/.claude/get-magic-done/bin/gmd-tools.cjs" config-set model_profile "$ARGUMENTS.profile"
```

This writes the new profile to `.planning/config.json`. The next spawned agent reads this value via `resolveModelInternal` in `bin/lib/core.cjs`.
</step>

<step name="confirm">
Display a confirmation banner plus the active row of the 9-cell `COMPLEXITY_MODEL` table so the user can see exactly what the three complexity tiers will resolve to under the new profile.

Render the active row by loading `COMPLEXITY_MODEL` from `bin/lib/core.cjs` and printing the `simple` / `standard` / `complex` cells:

```bash
node -e "
const { COMPLEXITY_MODEL } = require('$HOME/.claude/get-magic-done/bin/lib/core.cjs');
const profile = '$ARGUMENTS.profile';
const row = COMPLEXITY_MODEL[profile];
console.log('');
console.log('| Complexity | Model |');
console.log('|------------|-------|');
console.log('| simple     | ' + row.simple + ' |');
console.log('| standard   | ' + row.standard + ' |');
console.log('| complex    | ' + row.complex + ' |');
console.log('');
console.log('(opus resolves to \"inherit\" at Task-spawn time — see');
console.log(' references/model-profile-resolution.md for the full flow.)');
"
```

Then print the final banner:

```
✓ Model profile set to: $ARGUMENTS.profile

GMD uses a universal profile × complexity table — the 9-cell COMPLEXITY_MODEL
in bin/lib/core.cjs. The active profile ($ARGUMENTS.profile) sets one row;
each workflow spawn site picks a column via --complexity.

[table rendered from the node one-liner above]

Behavioral promises for this profile:
  - quality:  never drops to haiku (simple tasks still get sonnet)
  - balanced: full haiku → sonnet → opus range
  - budget:   never reaches opus (complex tasks cap at sonnet)

Next spawned agents will use the new profile.
```

Substitute the matching promise bullet for the selected profile. The full 9-cell matrix lives in `references/model-profiles.md`.
</step>

</process>

<success_criteria>
- [ ] Argument validated against {quality, balanced, budget}
- [ ] Config file ensured
- [ ] `model_profile` field updated in `.planning/config.json`
- [ ] Confirmation displayed with the active row of `COMPLEXITY_MODEL` (simple/standard/complex cells) loaded from `bin/lib/core.cjs`
- [ ] Behavioral promise for the selected profile surfaced to the user
</success_criteria>
