Second Opinion
Get an independent advisory memo or manage the consultant toggle.
Steps
Check for toggle command. If
$ARGUMENTSis one of the toggle sub-commands, handle it directly:enable→ writeconsultantMode: externalto.agents/.agents-mode.yamlwhile preservingdelegationMode,parallelMode,mcpMode,preferExternalWorker,preferExternalReviewer,externalProvider,externalPriorityProfile,reserveResolver,externalPriorityProfiles,externalOpinionCounts,externalCodexWorkdirMode,externalClaudeWorkdirMode,externalModelMode,externalCodexProfile, andexternalClaudeProfilewhen present. If the local file does not exist, inherit the effective known values from global~/.codex/.agents-mode.yaml(or global legacy~/.codex/.agents-mode) when available; otherwise initializedelegationMode: auto,parallelMode: auto,mcpMode: auto,preferExternalWorker: false,preferExternalReviewer: false,externalProvider: auto,externalPriorityProfile: balanced,reserveResolver: claude-sonnet, shippedexternalPriorityProfilesandexternalOpinionCounts,externalCodexWorkdirMode: neutral,externalClaudeWorkdirMode: neutral,externalModelMode: runtime-default,externalCodexProfile: default, andexternalClaudeProfile: opus-xhighunless the user explicitly asked for a different Claude profile. Shippedautostays on the Codex/Claude pair; Kimi requires explicit global Windows enrollment, and Grok remains unavailable in 1.x. Print "Consultant enabled (external-first)." and exit.internal→ writeconsultantMode: internalto.agents/.agents-mode.yamlwhile preservingdelegationMode,parallelMode,mcpMode,preferExternalWorker,preferExternalReviewer,externalProvider,externalPriorityProfile,reserveResolver,externalPriorityProfiles,externalOpinionCounts,externalCodexWorkdirMode,externalClaudeWorkdirMode,externalModelMode,externalCodexProfile, andexternalClaudeProfilewhen present. If the local file does not exist, inherit the effective known values from global~/.codex/.agents-mode.yaml(or global legacy~/.codex/.agents-mode) when available; otherwise initializedelegationMode: auto,parallelMode: auto,mcpMode: auto,preferExternalWorker: false,preferExternalReviewer: false,externalProvider: auto,externalPriorityProfile: balanced,reserveResolver: claude-sonnet, shippedexternalPriorityProfilesandexternalOpinionCounts,externalCodexWorkdirMode: neutral,externalClaudeWorkdirMode: neutral,externalModelMode: runtime-default,externalCodexProfile: default, andexternalClaudeProfile: opus-xhighunless the user explicitly asked for a different Claude profile. Shippedautostays on the Codex/Claude pair; Kimi requires explicit global Windows enrollment, and Grok remains unavailable in 1.x. Print "Consultant set to internal-only." and exit.disable→ writeconsultantMode: disabledto.agents/.agents-mode.yamlwhile preservingdelegationMode,parallelMode,mcpMode,preferExternalWorker,preferExternalReviewer,externalProvider,externalPriorityProfile,reserveResolver,externalPriorityProfiles,externalOpinionCounts,externalCodexWorkdirMode,externalClaudeWorkdirMode,externalModelMode,externalCodexProfile, andexternalClaudeProfilewhen present. If the local file does not exist, inherit the effective known values from global~/.codex/.agents-mode.yaml(or global legacy~/.codex/.agents-mode) when available; otherwise initializedelegationMode: auto,parallelMode: auto,mcpMode: auto,preferExternalWorker: false,preferExternalReviewer: false,externalProvider: auto,externalPriorityProfile: balanced,reserveResolver: claude-sonnet, shippedexternalPriorityProfilesandexternalOpinionCounts,externalCodexWorkdirMode: neutral,externalClaudeWorkdirMode: neutral,externalModelMode: runtime-default,externalCodexProfile: default, andexternalClaudeProfile: opus-xhighunless the user explicitly asked for a different Claude profile. Shippedautostays on the Codex/Claude pair; Kimi requires explicit global Windows enrollment, and Grok remains unavailable in 1.x. Print "Consultant disabled." and exit.status→ read and normalize.agents/.agents-mode.yamlfirst. If local.agents/.agents-mode.yamlis absent, continue with local legacy.agents/.agents-mode, global~/.codex/.agents-mode.yaml, then global legacy~/.codex/.agents-mode. If neither local nor global file exists: print "disabled (no file — run/second-opinion enableto activate)". Otherwise rewrite the effective file into the current canonical format in the same scope, then printconsultantMode,delegationMode,parallelMode,mcpMode,preferExternalWorker,preferExternalReviewer,externalProvider,externalPriorityProfile,reserveResolver,externalOpinionCounts,externalCodexWorkdirMode,externalClaudeWorkdirMode,externalModelMode,externalCodexProfile, andexternalClaudeProfilewhen it is present. Exit.- If
$ARGUMENTSis not a toggle command, proceed to step 1.
When reading, creating, or rewriting
.agents/.agents-mode.yaml, normalize it to the current canonical format: keep one key per line, restore inline YAML allowed-value comments, refresh the shipped profile/count blocks, preserve effective known values and unknown keys, and drop retired canonical keys. Legacy.agents/.agents-modeis compatibility input only and must not be recreated.Check toggle state. Read the effective Codex overlay first:
- Resolve in this order: local
.agents/.agents-mode.yaml, local legacy.agents/.agents-mode, global~/.codex/.agents-mode.yaml, then global legacy~/.codex/.agents-mode. - If neither local nor global file exists: print "disabled (no file — run
/second-opinion enableto activate)" and exit. - If a file exists, normalize it to the current canonical format in the same scope before evaluating any flags.
- If
consultantMode: disabled: print "Consultant is disabled. Run/second-opinion enablefirst." and exit. - If
consultantMode: external/consultantMode: internal: proceed. - Preserve
delegationMode,parallelMode,mcpMode,preferExternalWorker,preferExternalReviewer,externalProvider,externalPriorityProfile,reserveResolver,externalPriorityProfiles,externalOpinionCounts,externalCodexWorkdirMode,externalClaudeWorkdirMode,externalModelMode,externalCodexProfile, andexternalClaudeProfileon any write; do not clobber them back to defaults when changingconsultantMode.
- Resolve in this order: local
Get the question. Use
$ARGUMENTSas the question or topic. If empty, ask the user what they want a second opinion on.Invoke consultant. Use the consultant role:
- Pass the question along with relevant context (current file, recent changes, or accepted artifacts).
- The consultant follows its execution paths based on the current toggle mode.
Present the memo. Display the consultant's advisory memo:
- Recommended direction
- Alternatives considered
- Major tradeoffs
- Key risks
- Confidence level
- Continuation prompt — a ready-to-send second prompt that begins with a direct imperative to continue and names the next concrete action
Save. Follow the session persistence rule:
- If the current task has
work-items/active/<slug>/, persist only the memo there and return its concise result/provenance for the root ledger. - With no active work-item, a meaningful standalone memo MAY use one
.reports/YYYY-MM/report(consultant)-YYYY-MM-DD_HH-MM_topic.mdsummary.
- If the current task has
Rules
- Consultant is advisory-only — do not treat the memo as a blocking gate.
- Do not modify any project files (toggle file excluded).
- If the memo identifies a real blocker, recommend the proper specialist role to handle it.
.agents/.agents-mode.yamlis the project-local override surface for consultant mode. When it is absent, read-only status and routing fall back to the effective global Codex overlay at~/.codex/.agents-mode.yamluntil a local override is created.