Mastermind new agent

From monoes/monomind · View interactive version

Mastermind new agent is an AI agent skill from the GitHub repository monoes/monomind. Mastermind new-agent — hire an agent into an org: runtime, model, role, reports_to, responsibilities, skills and budget, written as a validated Org Runtime role.

How to use this skill

Skill file

Mastermind New Agent

This skill is invoked directly via /mastermind-new-agent.

It writes one role in the Org Runtime shape (RoleSchema in packages/@monomind/cli/src/orgrt/types.ts) — the same shape mastermind-createorg produces — and runs monomind org validate on the result. There is no adapter object, heartbeat or per-role system prompt in the org config: the runtime reads runtime, adapter_config.model, responsibilities, skills and skill_pool.


Inputs


Runtimes and their latest models

Leave adapter_config.model out unless the user asked for an exact model: an unpinned role runs the newest model of its runtime's default family, resolved when the org runs (latest-models.ts), so it is never older than the newest, while a pin goes stale (org validate warns about an older pin). The table is what an unpinned role resolves to today (resolveModel() in orgrt/session-prompt.ts is the source of truth; if it disagrees with this table, it wins). Claude Fable and GPT Astra models are never assigned or routed; the role is rejected if one is named:

| runtime | Latest model |

|-----------|--------------|

| claude (default — omit the field) | claude-sonnet-5-5 |

| codex | gpt-5.6-terra |

| antigravity | gemini-3.8-flash-high |

| kimicode | kimi-code/k3 |

| opencode | glm-5.2 |

| vercel | gpt-5.5 |


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 — Load Org

orgFile=".monomind/orgs/${org_name}.json"
[ ! -f "$orgFile" ] && { echo "ERROR: Org '${org_name}' not found."; exit 1; }

Step 1.5 — Find Skills (create / preview)

Skills are org-library skills, not slash commands: names like mastermind:tasks are not valid here and fail org validate. When skills / skill_pool were not given, search the library with the role's title and responsibilities and choose from the hits:

npx monomind org skills search "${title} ${responsibilities}" --limit 8 --format json \
  | jq -r '.skills[] | "\(.name)\t\(.description)"'
npx monomind org skills show <name>   # read one before choosing it

Pin 1–3 that define the role in skills; put the ones it needs only for some tasks in skill_pool. Leave both empty when nothing fits cleanly — responsibilities alone is a complete role.


Step 2 — Execute Action

list-runtimes

echo "ORG RUNTIME RUNTIMES (latest model)"
echo "────────────────────────────────────────────────────────"
cat <<'RUNTIMES'
  claude        claude-sonnet-5-5        (default; also claude-opus-5-5, claude-haiku-5-5)
  codex         gpt-5.6-terra
  antigravity   gemini-3.8-flash-high
  kimicode      kimi-code/k3
  opencode      glm-5.2
  vercel        gpt-5.5                  (pair with provider.vendor)
RUNTIMES

list-roles

echo "CURRENT ROLES IN ORG: $org_name"
echo "────────────────────────────────────────────────────────"
printf "%-22s %-24s %-12s %-24s %s\n" "ID" "TITLE" "RUNTIME" "MODEL" "REPORTS TO"
echo "────────────────────────────────────────────────────────"
jq -r '(.roles // [])[] |
  [.id, (.title // "-"), (.runtime // "claude"), (.adapter_config.model // "(unset)"), (.reports_to // "(root)")] | @tsv' \
  "$orgFile" | while IFS=$'\t' read -r id title rt model parent; do
  printf "%-22s %-24s %-12s %-24s %s\n" "$id" "$title" "$rt" "$model" "$parent"
done

preview / create — shared setup

[ -z "$title" ] && { echo "ERROR: --title required."; exit 1; }
[ -z "$reports_to" ] && { echo "ERROR: --reports-to required (the org already has its root role)."; exit 1; }

runtimeVal="${runtime:-claude}"
modelId="${model}"   # empty = unpinned: the runtime resolves the newest default when the org runs
case "$runtimeVal" in
  claude|codex|antigravity|kimicode|opencode|vercel) ;;
  *) echo "ERROR: unknown runtime '$runtimeVal' (see --action list-runtimes)."; exit 1 ;;
esac

[ -z "$agent_id" ] && agent_id=$(echo "$title" | tr '[:upper:]' '[:lower:]' | tr -cs 'a-z0-9' '-' | sed 's/^-//;s/-$//')

if [ -n "$budget_tokens" ] && ! [[ "$budget_tokens" =~ ^[1-9][0-9]*$ ]]; then
  echo "ERROR: --budget-tokens must be a positive integer (omit it for the even share)."; exit 1
fi

preview

echo "PREVIEW — new role to be added to org '$org_name'"
echo "────────────────────────────────────────────────────────"
echo "  ID:               $agent_id"
echo "  Title:            $title"
echo "  Runtime / model:  $runtimeVal / ${modelId:-(newest default, resolved when the org runs)}"
echo "  Reports to:       $reports_to"
echo "  Responsibilities: ${responsibilities:-(none — add some: they are the role's briefing)}"
echo "  Skills:           ${skills:-(none)}"
echo "  Skill pool:       ${skill_pool:-(none)}"
echo "  Budget:           ${budget_tokens:-(even share of the org budget)}"
echo ""
echo "Run with --action create to add this role to the org."

create

duplicate=$(jq -r --arg id "$agent_id" '[(.roles // [])[] | select(.id == $id)] | length' "$orgFile")
[ "$duplicate" -gt 0 ] && { echo "ERROR: Role id '$agent_id' already exists in org '$org_name'. Use --agent-id to specify a unique id."; exit 1; }

parentExists=$(jq -r --arg pid "$reports_to" '[(.roles // [])[] | select(.id == $pid)] | length' "$orgFile")
[ "$parentExists" -eq 0 ] && { echo "ERROR: Parent role '$reports_to' not found in org '${org_name}'. Check ids with --action list-roles."; exit 1; }

list() { [ -n "$1" ] && echo "$1" | tr "$2" '\n' | sed 's/^ *//;s/ *$//' | jq -Rsc 'split("\n") | map(select(. != ""))' || echo '[]'; }

tmp="${orgFile}.tmp"
jq --arg id "$agent_id" \
   --arg title "$title" \
   --arg rt "$reports_to" \
   --arg runtime "$runtimeVal" \
   --arg model "$modelId" \
   --arg maxTok "${max_tokens:-}" \
   --arg budget "${budget_tokens:-}" \
   --argjson resp "$(list "$responsibilities" ';')" \
   --argjson skills "$(list "$skills" ',')" \
   --argjson pool "$(list "$skill_pool" ',')" \
  '.roles += [
    {id: $id, title: $title, type: "specialist", reports_to: $rt, responsibilities: $resp,
     adapter_config: ((if $model != "" then {model: $model} else {} end) + (if $maxTok != "" then {max_tokens: ($maxTok | tonumber)} else {} end))}
    + (if $runtime != "claude" then {runtime: $runtime} else {} end)
    + (if ($skills | length) > 0 then {skills: $skills} else {} end)
    + (if ($pool | length) > 0 then {skill_pool: $pool} else {} end)
    + (if $budget != "" then {budget_tokens: ($budget | tonumber)} else {} end)
  ]' \
  "$orgFile" > "$tmp" || { rm -f "$tmp"; echo "ERROR: could not build the role."; exit 1; }

# Validate BEFORE replacing the config: the same parse org run/serve use,
# plus unknown-skill checks. A refused role leaves the org file untouched.
cp "$orgFile" "${orgFile}.bak" && mv "$tmp" "$orgFile"
if ! npx -y monomind@latest org validate "$org_name"; then
  mv "${orgFile}.bak" "$orgFile"
  echo "ERROR: the new role did not validate (see above) — org config restored."; exit 1
fi
rm -f "${orgFile}.bak"

echo "Role created: $agent_id"
echo "  Title:    $title"
echo "  Runtime:  $runtimeVal / ${modelId:-(newest default)}"
echo "  Reports:  $reports_to"
echo "  Skills:   ${skills:-(none)}  pool: ${skill_pool:-(none)}"
echo ""
echo "Org '${org_name}' now has $(jq '.roles | length' "$orgFile") role(s)."
echo "View: /mastermind-agent-detail --org $org_name --agent-id $agent_id"
# #502: a new role takes effect only once the operator signs the org.
echo "Review, then sign the change yourself: monomind org sign ${org_name}"

Step 3 — Return Output

domain: ops
status: complete
action: <action>
org: <org_name>
agent_id: <agent_id>
runtime: <runtime>
model: <model>

Step 4 — Brain Write (standalone only)

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.