Diagnose
Diagnose Muse Code as an installed product. Use this skill only when the user
explicitly invokes doctor or clearly asks to debug/troubleshoot Muse Code
itself from binary/runtime evidence. Assume the user has the binary, not the
source tree. Help them understand how the app works, collect the smallest safe
evidence set, identify the likely failing layer, and give the next safe action.
Scope
- Use this skill ONLY when the user explicitly invokes
doctor, asks to use
the doctor skill, or clearly asks to debug/troubleshoot broken Muse Code
product behavior: app, CLI, TUI, desktop, crash, provider/model, settings,
auth, trust, skills, plugins, MCP, session, resume, export, trace, approvals,
sandbox, update, or unexpected output.
- Use this skill when the user asks how Muse Code itself works, where Muse Code
stores state, what a Muse Code log/session/trace means, or how to collect a
Muse Code support bundle.
- Use this skill when the user asks what happened earlier in the current
Muse Code session or explicitly selects an earlier Muse Code session for
evidence. This does not include ordinary repository history or an unspecified
third-party agent session.
- Do NOT use this skill for ordinary repository engineering: code
implementation, third-party project bugs, benchmark/eval tasks, build or test
failures, command hangs, toolchain issues, CI failures, or local debugging
inside a non-Muse Code codebase. Handle those with the normal engineering
workflow unless the evidence points to Muse Code itself.
- Treat the user as a product user first, not as a repository engineer.
- For pure settings questions or explicitly requested settings edits with no
product failure to investigate, use the
manage-settings skill instead;
Diagnose reads settings only as evidence for a failure it is investigating.
- Do not create issues, branches, commits, PRs, install/enable/disable skills or
plugins, change settings/auth/trust, upload logs, run live-provider/network
checks, or edit code unless the user explicitly asks.
- Do not print secrets, raw prompts, raw model payloads, auth tokens, API keys,
cookies, bearer headers, or full session logs. Prefer redacted exports,
key/value presence checks, and concise summaries.
- If a surface has no standalone app log, say so and use session logs, crash
reports, trace inspection, or export evidence instead of inventing a path.
Mental Model
Explain the relevant product path before asking for logs:
- The binary reads settings/auth/trust from the user's config directory and
writes sessions, crashes, model catalog cache, and memory under the data
directory.
- A Muse Code session is the main handle for resume, trace inspection, export,
and support. Prefer a session id or session log path over screenshots of
terminal output.
- Provider/auth failures are often config, environment, model catalog, network,
or credential problems. Separate those before blaming the model.
- Skills/plugins/MCP are loaded product capabilities. Diagnose discovery,
activation, trust, validation, and runtime errors separately.
- A trace/export explains what the binary saw and did. It is evidence, not a
transcript to paste raw.
Triage Questions
- Name the failing surface and exact symptom.
- Record the command, cwd, session id/path if provided, whether the user wants
to inspect or continue that session, approximate time, provider/model if
relevant, and whether the issue reproduces.
- Ask for one missing handle only when it blocks a safe local check. Prefer:
exact command, session id/path, time window, and whether they can reproduce.
- If the user only wants an explanation, explain first and avoid running checks.
Product Evidence Map
Collect the smallest read-only set that explains the issue. Adapt the map to the
symptom; do not run every row by default.
The config/data roots below are Muse Code's entire local state surface. A
config, log, or session file outside them is not Muse Code state —
never present one as the product's active configuration, logs, or session
evidence.
Variables such as CODEX_HOME matter only for explicitly requested
import/compat evidence and stay attributed to the product that owns them.
- Build/provenance:
muse --version; also note command -v muse when
multiple copies may exist.
- Config/data roots:
$XDG_CONFIG_HOME/muse or $HOME/.config/muse;
$XDG_DATA_HOME/muse or $HOME/.local/share/muse.
- Local files:
settings.json, auth.json, and trust.json; read settings
when relevant, but report auth/trust presence and provider names only.
- Data dirs:
sessions, memory, model-catalog, and crashes under the
data dir. For crashes, summarize report metadata and file path, not session
content.
- Session evidence: prefer
muse export --redacted --out <file> for the
latest workspace session, or muse export --session <id-or-session.jsonl> --redacted --out <file> when the user provides a handle.
- Continuation handles: if the user provides a Muse Code session id and wants
to continue that session, point them to
muse resume <session-id> or
muse resume --last for interactive continuation. Use
muse exec --session-id <session-id> "<follow-up>" only on explicit
request for headless continuation. Add --allow-workspace-switch to the
muse exec --session-id command only after confirming the session
belongs to another workspace; interactive muse resume does not take
this flag. If an exit, fork, or handoff message printed
muse resume <session-id>, treat that command as the canonical handle.
- Trace evidence: use
muse trace inspect --session-log <session.jsonl> --render-mode compact; add --run-id <uuid> or --all-runs for multi-run
logs; use --format json only when structured analysis is needed.
- User support bundle: use
/feedback when available; otherwise prefer a
redacted export, trace inspection, crash metadata, and concise reproduction
steps.
- Skills/plugins/MCP: use
muse skills list --enabled-only --json and safe
muse plugins ... --help or validation commands when the symptom points
there.
- Environment: check relevant non-secret variables by presence/value only, such
as
MUSE_MODEL, base-url variables with credentials redacted, XDG dirs,
CODEX_HOME for import/compat issues, and telemetry variables by presence
only.
Use Current Session Evidence First
For a question about what happened earlier in the current Muse Code session,
use the sibling scripts/session-evidence.py helper before export or full trace
inspection. After read_skill gives the physical Diagnose package path, run:
python3 <doctor-skill-dir>/scripts/session-evidence.py --session-log <current-session.jsonl> --workspace "$PWD"
The runtime session-identity context already contains the exact current log
path. Do not ask the user for a path already present there, do not guess a
latest session, and do not search the session store first. A host may instead
provide MUSE_CURRENT_SESSION_LOG, in which case the helper can run without a
selector.
For an explicitly selected earlier Muse Code session, use the exact path or id:
python3 <doctor-skill-dir>/scripts/session-evidence.py --session-log <explicit-session.jsonl> --workspace "$PWD"
python3 <doctor-skill-dir>/scripts/session-evidence.py --session-id <explicit-session-id> --workspace "$PWD"
Both explicit earlier-session forms are current-workspace scoped and fail
closed on unknown workspace metadata, a mismatch, or ambiguity. Use --kind,
--path, --tool, --run-id, or sequence bounds to narrow follow-up evidence.
Projected events retain their source stream, and the default bound reserves
evidence for both the main session and child sessions so a busy child cannot
erase the parent timeline. Always compare durable actions with assistant claims,
especially across compaction and child activity. Use a
redacted export or compact trace only when this bounded projection is
insufficient. Never paste the raw session log into model context.
Diagnose Live Session Ownership Safely
Use this path when resume says a session is already open or the original
terminal no longer accepts input:
- Select the exact session first and run
scripts/session-evidence.py as
above. Bound the output and compare its latest durable activity timestamps;
do not start with a store-wide process or file search.
- Treat
.session.lock as an inode-backed kernel lease, not a marker file:
file existence is not lock ownership, and flock protects an open inode.
Unlinking a contended pathname can let another process create and lock a new
inode while the original writer still owns the old inode.
- Probe the exact lock read-only with a non-blocking exclusive
flock. Open it
without truncation, report only acquirable, contended, missing, or the
read error, then close it immediately. Never resume the session as a probe.
- Read the lock body's PID only as a hint. A tool sandbox or PID namespace may
not see the host process;
ps/kill -0 absence inside it cannot prove that
the host owner died. Request a host-shell check when that distinction matters.
- Check the bounded session evidence for prior file mutation involving
.session.lock, especially rm, unlink, replacement, truncation, or
recreation. If the path is missing while old activity advances, stop resume
attempts and preserve evidence.
Never remove, replace, truncate, or recreate .session.lock as diagnosis or
repair. Never signal the owner from Diagnose. Use only the supported interactive
resume picker takeover after the user explicitly chooses it; it remains
idle-only and the normal writer lease still decides who may write.
Classify the result before recommending an action:
| Evidence |
Classification |
Safe next action |
| Lease is acquirable |
No current kernel owner; a leftover pathname is harmless |
Retry normal resume; do not clean the file for tidiness |
| contended lease with advancing session activity |
Live owner and active runtime; terminal attachment may be the failed layer |
Preserve the owner; inspect terminal/PTY evidence or exit it normally |
| Contended lease with bounded activity idle |
Live kernel owner, runtime/terminal health unknown |
Use explicit idle takeover from the conflict picker, or collect host-visible stack/trace evidence |
| Contended lease but owner-control is unavailable |
Live old/incompatible/unreachable owner |
Keep fail-closed behavior; exit the old owner normally or collect host evidence |
| Lock path was unlinked or replaced while old activity continues |
Unsafe prior mutation with possible dual writers |
Stop further resume attempts, preserve both inode/session timelines, and escalate; do not recreate the lock |
A contended lease proves a live kernel owner, not that its TUI, terminal,
provider, or runtime is healthy. Pin the failing layer from activity plus
host-visible evidence before proposing a product fix.
Narrowing Loop
Work from evidence:
- State the most likely layer in one or two concrete sentences.
- Say why the next check will confirm or reject that hypothesis, then run that
one safe local check.
- Update the hypothesis from the result and continue only while the next check
is still relevant and safe.
- If a live provider, live network, destructive command, or upload is required,
state why and get explicit user approval first.
- If customization or local state is suspected, compare against an isolated
temporary XDG config/data profile only after explaining that it will not read
or mutate the user's real settings.
Common Diagnosis Paths
- Startup/auth: binary path -> version -> config load -> auth provider present
-> model/catalog selection -> first network boundary.
- Provider/model: selected provider/model -> base URL with credentials redacted
-> auth presence -> model catalog cache -> trace request/error summary.
- Session/resume: session id/path -> workspace match -> session log exists ->
resume/export/trace command -> whether the user wants inspection or
continuation.
- Skills/plugins/MCP: list/discovery -> activation/trust -> validation output ->
runtime trace or startup diagnostic.
- Desktop/TUI: packaged app/binary version -> session id -> UI-visible symptom
-> crash/report metadata -> trace/export evidence. Say when source-only tests
cannot prove a packaged-app issue.
Fix Boundary
- Settings-only fix: propose the exact change and apply it only after explicit
user request; preserve unknown settings fields and verify with a read-back or
focused command.
- Workspace code fix: switch to the RED-before-GREEN engineering loop only when
the user explicitly asks to fix code in the current repo. Reproduce first,
edit surgically, rerun the same check, and report incomplete if it still
fails.
- Product bug report: if the evidence points to Muse Code itself and no local fix
is safe, give a concise support bundle with symptom, version, config/data
paths, session/crash paths, redacted export/trace evidence, likely cause, and
next action.
Completion Report
Include:
- Symptom and affected surface.
- Product mental model relevant to this failure.
- Evidence collected, paths inspected, commands and outcomes.
- Redactions applied.
- Most likely cause and confidence.
- Fix made, proposed, or not made.
- Remaining uncertainty and the next safest check.
1---2name: doctor3description: Diagnose Muse Code product/runtime issues from installed binary evidence. Use ONLY when the user explicitly invokes the doctor skill, asks to debug/troubleshoot Muse Code itself, asks what happened earlier in the current Muse Code session, or explicitly selects an earlier Muse Code session. Do NOT use for ordinary repository code failures or history, benchmark tasks, implementation debugging, build/test hangs, or third-party project issues.4---56# Diagnose78Diagnose Muse Code as an installed product. Use this skill only when the user9explicitly invokes `doctor` or clearly asks to debug/troubleshoot Muse Code10itself from binary/runtime evidence. Assume the user has the binary, not the11source tree. Help them understand how the app works, collect the smallest safe12evidence set, identify the likely failing layer, and give the next safe action.1314## Scope1516- Use this skill ONLY when the user explicitly invokes `doctor`, asks to use17 the doctor skill, or clearly asks to debug/troubleshoot broken Muse Code18 product behavior: app, CLI, TUI, desktop, crash, provider/model, settings,19 auth, trust, skills, plugins, MCP, session, resume, export, trace, approvals,20 sandbox, update, or unexpected output.21- Use this skill when the user asks how Muse Code itself works, where Muse Code22 stores state, what a Muse Code log/session/trace means, or how to collect a23 Muse Code support bundle.24- Use this skill when the user asks what happened earlier in the current25 Muse Code session or explicitly selects an earlier Muse Code session for26 evidence. This does not include ordinary repository history or an unspecified27 third-party agent session.28- Do NOT use this skill for ordinary repository engineering: code29 implementation, third-party project bugs, benchmark/eval tasks, build or test30 failures, command hangs, toolchain issues, CI failures, or local debugging31 inside a non-Muse Code codebase. Handle those with the normal engineering32 workflow unless the evidence points to Muse Code itself.33- Treat the user as a product user first, not as a repository engineer.34- For pure settings questions or explicitly requested settings edits with no35 product failure to investigate, use the `manage-settings` skill instead;36 Diagnose reads settings only as evidence for a failure it is investigating.37- Do not create issues, branches, commits, PRs, install/enable/disable skills or38 plugins, change settings/auth/trust, upload logs, run live-provider/network39 checks, or edit code unless the user explicitly asks.40- Do not print secrets, raw prompts, raw model payloads, auth tokens, API keys,41 cookies, bearer headers, or full session logs. Prefer redacted exports,42 key/value presence checks, and concise summaries.43- If a surface has no standalone app log, say so and use session logs, crash44 reports, trace inspection, or export evidence instead of inventing a path.4546## Mental Model4748Explain the relevant product path before asking for logs:4950- The binary reads settings/auth/trust from the user's config directory and51 writes sessions, crashes, model catalog cache, and memory under the data52 directory.53- A Muse Code session is the main handle for resume, trace inspection, export,54 and support. Prefer a session id or session log path over screenshots of55 terminal output.56- Provider/auth failures are often config, environment, model catalog, network,57 or credential problems. Separate those before blaming the model.58- Skills/plugins/MCP are loaded product capabilities. Diagnose discovery,59 activation, trust, validation, and runtime errors separately.60- A trace/export explains what the binary saw and did. It is evidence, not a61 transcript to paste raw.6263## Triage Questions64651. Name the failing surface and exact symptom.662. Record the command, cwd, session id/path if provided, whether the user wants67 to inspect or continue that session, approximate time, provider/model if68 relevant, and whether the issue reproduces.693. Ask for one missing handle only when it blocks a safe local check. Prefer:70 exact command, session id/path, time window, and whether they can reproduce.714. If the user only wants an explanation, explain first and avoid running checks.7273## Product Evidence Map7475Collect the smallest read-only set that explains the issue. Adapt the map to the76symptom; do not run every row by default.7778The config/data roots below are Muse Code's entire local state surface. A79config, log, or session file outside them is not Muse Code state —80never present one as the product's active configuration, logs, or session81evidence.82Variables such as `CODEX_HOME` matter only for explicitly requested83import/compat evidence and stay attributed to the product that owns them.84851. Build/provenance: `muse --version`; also note `command -v muse` when86 multiple copies may exist.872. Config/data roots: `$XDG_CONFIG_HOME/muse` or `$HOME/.config/muse`;88 `$XDG_DATA_HOME/muse` or `$HOME/.local/share/muse`.893. Local files: `settings.json`, `auth.json`, and `trust.json`; read settings90 when relevant, but report auth/trust presence and provider names only.914. Data dirs: `sessions`, `memory`, `model-catalog`, and `crashes` under the92 data dir. For crashes, summarize report metadata and file path, not session93 content.945. Session evidence: prefer `muse export --redacted --out <file>` for the95 latest workspace session, or `muse export --session <id-or-session.jsonl>96 --redacted --out <file>` when the user provides a handle.976. Continuation handles: if the user provides a Muse Code session id and wants98 to continue that session, point them to `muse resume <session-id>` or99 `muse resume --last` for interactive continuation. Use100 `muse exec --session-id <session-id> "<follow-up>"` only on explicit101 request for headless continuation. Add `--allow-workspace-switch` to the102 `muse exec --session-id` command only after confirming the session103 belongs to another workspace; interactive `muse resume` does not take104 this flag. If an exit, fork, or handoff message printed105 `muse resume <session-id>`, treat that command as the canonical handle.1067. Trace evidence: use `muse trace inspect --session-log <session.jsonl>107 --render-mode compact`; add `--run-id <uuid>` or `--all-runs` for multi-run108 logs; use `--format json` only when structured analysis is needed.1098. User support bundle: use `/feedback` when available; otherwise prefer a110 redacted export, trace inspection, crash metadata, and concise reproduction111 steps.1129. Skills/plugins/MCP: use `muse skills list --enabled-only --json` and safe113 `muse plugins ... --help` or validation commands when the symptom points114 there.11510. Environment: check relevant non-secret variables by presence/value only, such116 as `MUSE_MODEL`, base-url variables with credentials redacted, XDG dirs,117 `CODEX_HOME` for import/compat issues, and telemetry variables by presence118 only.119120## Use Current Session Evidence First121122For a question about what happened earlier in the current Muse Code session,123use the sibling `scripts/session-evidence.py` helper before export or full trace124inspection. After `read_skill` gives the physical Diagnose package path, run:125126```bash127python3 <doctor-skill-dir>/scripts/session-evidence.py --session-log <current-session.jsonl> --workspace "$PWD"128```129130The runtime session-identity context already contains the exact current log131path. Do not ask the user for a path already present there, do not guess a132latest session, and do not search the session store first. A host may instead133provide `MUSE_CURRENT_SESSION_LOG`, in which case the helper can run without a134selector.135136For an explicitly selected earlier Muse Code session, use the exact path or id:137138```bash139python3 <doctor-skill-dir>/scripts/session-evidence.py --session-log <explicit-session.jsonl> --workspace "$PWD"140python3 <doctor-skill-dir>/scripts/session-evidence.py --session-id <explicit-session-id> --workspace "$PWD"141```142143Both explicit earlier-session forms are current-workspace scoped and fail144closed on unknown workspace metadata, a mismatch, or ambiguity. Use `--kind`,145`--path`, `--tool`, `--run-id`, or sequence bounds to narrow follow-up evidence.146Projected events retain their source stream, and the default bound reserves147evidence for both the main session and child sessions so a busy child cannot148erase the parent timeline. Always compare durable actions with assistant claims,149especially across compaction and child activity. Use a150redacted export or compact trace only when this bounded projection is151insufficient. Never paste the raw session log into model context.152153## Diagnose Live Session Ownership Safely154155Use this path when resume says a session is already open or the original156terminal no longer accepts input:1571581. Select the exact session first and run `scripts/session-evidence.py` as159 above. Bound the output and compare its latest durable activity timestamps;160 do not start with a store-wide process or file search.1612. Treat `.session.lock` as an inode-backed kernel lease, not a marker file:162 file existence is not lock ownership, and `flock` protects an open inode.163 Unlinking a contended pathname can let another process create and lock a new164 inode while the original writer still owns the old inode.1653. Probe the exact lock read-only with a non-blocking exclusive `flock`. Open it166 without truncation, report only `acquirable`, `contended`, `missing`, or the167 read error, then close it immediately. Never resume the session as a probe.1684. Read the lock body's PID only as a hint. A tool sandbox or PID namespace may169 not see the host process; `ps`/`kill -0` absence inside it cannot prove that170 the host owner died. Request a host-shell check when that distinction matters.1715. Check the bounded session evidence for prior file mutation involving172 `.session.lock`, especially `rm`, unlink, replacement, truncation, or173 recreation. If the path is missing while old activity advances, stop resume174 attempts and preserve evidence.175176Never remove, replace, truncate, or recreate `.session.lock` as diagnosis or177repair. Never signal the owner from Diagnose. Use only the supported interactive178resume picker takeover after the user explicitly chooses it; it remains179idle-only and the normal writer lease still decides who may write.180181Classify the result before recommending an action:182183| Evidence | Classification | Safe next action |184| --- | --- | --- |185| Lease is acquirable | No current kernel owner; a leftover pathname is harmless | Retry normal resume; do not clean the file for tidiness |186| contended lease with advancing session activity | Live owner and active runtime; terminal attachment may be the failed layer | Preserve the owner; inspect terminal/PTY evidence or exit it normally |187| Contended lease with bounded activity idle | Live kernel owner, runtime/terminal health unknown | Use explicit idle takeover from the conflict picker, or collect host-visible stack/trace evidence |188| Contended lease but owner-control is unavailable | Live old/incompatible/unreachable owner | Keep fail-closed behavior; exit the old owner normally or collect host evidence |189| Lock path was unlinked or replaced while old activity continues | Unsafe prior mutation with possible dual writers | Stop further resume attempts, preserve both inode/session timelines, and escalate; do not recreate the lock |190191A contended lease proves a live kernel owner, not that its TUI, terminal,192provider, or runtime is healthy. Pin the failing layer from activity plus193host-visible evidence before proposing a product fix.194195## Narrowing Loop196197Work from evidence:1981991. State the most likely layer in one or two concrete sentences.2002. Say why the next check will confirm or reject that hypothesis, then run that201 one safe local check.2023. Update the hypothesis from the result and continue only while the next check203 is still relevant and safe.2044. If a live provider, live network, destructive command, or upload is required,205 state why and get explicit user approval first.2065. If customization or local state is suspected, compare against an isolated207 temporary XDG config/data profile only after explaining that it will not read208 or mutate the user's real settings.209210## Common Diagnosis Paths211212- Startup/auth: binary path -> version -> config load -> auth provider present213 -> model/catalog selection -> first network boundary.214- Provider/model: selected provider/model -> base URL with credentials redacted215 -> auth presence -> model catalog cache -> trace request/error summary.216- Session/resume: session id/path -> workspace match -> session log exists ->217 resume/export/trace command -> whether the user wants inspection or218 continuation.219- Skills/plugins/MCP: list/discovery -> activation/trust -> validation output ->220 runtime trace or startup diagnostic.221- Desktop/TUI: packaged app/binary version -> session id -> UI-visible symptom222 -> crash/report metadata -> trace/export evidence. Say when source-only tests223 cannot prove a packaged-app issue.224225## Fix Boundary226227- Settings-only fix: propose the exact change and apply it only after explicit228 user request; preserve unknown settings fields and verify with a read-back or229 focused command.230- Workspace code fix: switch to the RED-before-GREEN engineering loop only when231 the user explicitly asks to fix code in the current repo. Reproduce first,232 edit surgically, rerun the same check, and report incomplete if it still233 fails.234- Product bug report: if the evidence points to Muse Code itself and no local fix235 is safe, give a concise support bundle with symptom, version, config/data236 paths, session/crash paths, redacted export/trace evidence, likely cause, and237 next action.238239## Completion Report240241Include:242243- Symptom and affected surface.244- Product mental model relevant to this failure.245- Evidence collected, paths inspected, commands and outcomes.246- Redactions applied.247- Most likely cause and confidence.248- Fix made, proposed, or not made.249- Remaining uncertainty and the next safest check.