---
name: mastermind-stoporg
description: Mastermind stoporg — stop a running org. Wraps monomind org stop, which writes the stop file the org daemon polls; the daemon exits within about 2 seconds.
type: domain-skill
default_mode: auto
pick: low
---

# Mastermind Stop Org

This skill is invoked by `mastermind:stoporg` or directly via `/mastermind:stoporg`.

---

## Inputs

- `org_name`: name of the org to stop (matches `.monomind/orgs/<org_name>.json`)
- `session_id`: session ID generated by the command wrapper
- `caller`: command | master

---

## Step 0 — Brain Load (standalone only)

If `caller` is not "command", load brain context following mastermind-protocol/SKILL.md Brain Load Procedure with namespace: `ops`.

---

## Step 1 — Validate Org

```bash
orgFile=".monomind/orgs/${org_name}.json"
[ ! -f "$orgFile" ] && {
  echo "ERROR: Org '${org_name}' not found."
  echo "Available orgs: $(ls .monomind/orgs/*.json 2>/dev/null | grep -vE -- '-approvals|-state|-activity|-goals|-routines|-projects|-members|-issues|-workspaces|-worktrees|-environments|-plugins|-adapters|-bootstrap|-threads|-budgets|-project-workspaces|-approval-comments' | xargs -I{} basename {} .json | tr '\n' ' ')"
  exit 1
}
```

The org daemon polls `.monomind/orgs/<name>/stop` every 2s, which is exactly
what `monomind org stop` writes — use the CLI:

```bash
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
CTRL_URL=$(jq -r '.url // "http://localhost:4242"' "$REPO_ROOT/.monomind/control.json" 2>/dev/null || echo "http://localhost:4242")
npx -y monomind@latest org stop "${org_name}" \
  || { mkdir -p ".monomind/orgs/${org_name}"; date -u +%Y-%m-%dT%H:%M:%SZ > ".monomind/orgs/${org_name}/stop"; }
# Also POST to the control server in case a dashboard-started instance is running
curl -s -X POST -H "x-monomind-token: $(cat "${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}/.monomind/dashboard-token" 2>/dev/null || true)" "${CTRL_URL}/api/orgs/${org_name}/stop" >/dev/null 2>&1 || true
echo "Stop requested for org '${org_name}' (the daemon exits within 2s)."
```

---

## Step 2 — Return Output

```yaml
domain: ops
status: complete
decisions:
  - what: "Org <org_name> stopped"
    why: "stop file written; the org daemon exits within 2s"
    confidence: 1.0
    outcome: shipped
next_actions:
  - "To restart: /mastermind:runorg --org <org_name>"
  - "To check current state: /mastermind:orgstatus --org <org_name>"
```

---

## Step 3 — Brain Write (standalone only)

If `caller` is not "command", follow mastermind-protocol/SKILL.md Brain Write Procedure for domain `ops`.
