|
| 1 | +--- |
| 2 | +description: "Diagnose CortexLink issues — asks about symptoms, runs targeted checks, and confirms before fixing anything" |
| 3 | +allowed-tools: Read, Bash |
| 4 | +--- |
| 5 | + |
| 6 | +⛔ **BEFORE ANYTHING ELSE — verify the environment:** |
| 7 | + |
| 8 | +```bash |
| 9 | +echo "${CLAUDE_PLUGIN_ROOT:-NOT_SET}" |
| 10 | +``` |
| 11 | + |
| 12 | +If the output is `NOT_SET`: |
| 13 | +> **STOP. Do not proceed.** |
| 14 | +> Tell the user: ⚠️ `CLAUDE_PLUGIN_ROOT` is not set. Run this command inside Claude Code or Copilot CLI with the CortexLink plugin loaded. |
| 15 | +
|
| 16 | +--- |
| 17 | + |
| 18 | +**Ask the user:** |
| 19 | + |
| 20 | +> What are you experiencing? Describe what's happening and I'll run the right checks. |
| 21 | +> |
| 22 | +> Examples: |
| 23 | +> - "The hook doesn't seem to fire / I don't see orchestration context injected" |
| 24 | +> - "Commands aren't showing up after install" |
| 25 | +> - "Agent delegation isn't working or auth is failing" |
| 26 | +> - "Setup seems incomplete or broken" |
| 27 | +> - "full checkup" — run everything |
| 28 | +
|
| 29 | +Wait for the user's response before continuing. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +Map their symptom(s) to the checks below and run only those — unless they said "full checkup", in which case run all five. |
| 34 | + |
| 35 | +| Symptom | Checks to run | |
| 36 | +|---------|--------------| |
| 37 | +| Hook not firing / no orchestration context | 1, 3 | |
| 38 | +| Commands missing / plugin not loading | 1, 2 | |
| 39 | +| Delegation failing / auth issues | 1, 4 | |
| 40 | +| Setup incomplete or broken | 1, 5 | |
| 41 | +| Full checkup | 1, 2, 3, 4, 5 | |
| 42 | + |
| 43 | +**Rule for every check:** report the finding first. If a fix is possible, tell the user exactly what you found and what you're about to do — then ask for confirmation before doing it. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Check 1 — Platform & Environment |
| 48 | + |
| 49 | +```bash |
| 50 | +echo "CLAUDE_PLUGIN_ROOT=${CLAUDE_PLUGIN_ROOT}" |
| 51 | +echo "COPILOT_CLI=${COPILOT_CLI:-not set}" |
| 52 | +``` |
| 53 | + |
| 54 | +- `CLAUDE_PLUGIN_ROOT` set, `COPILOT_CLI` not set → **Claude Code** |
| 55 | +- Both set → **Copilot CLI** |
| 56 | +- Report the detected platform. Note it for the summary. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Check 2 — Plugin File Integrity |
| 61 | + |
| 62 | +```bash |
| 63 | +for f in \ |
| 64 | + "$CLAUDE_PLUGIN_ROOT/hooks/hooks.json" \ |
| 65 | + "$CLAUDE_PLUGIN_ROOT/hooks/run-hook.cmd" \ |
| 66 | + "$CLAUDE_PLUGIN_ROOT/hooks/session-start" \ |
| 67 | + "$CLAUDE_PLUGIN_ROOT/skills/orchestration/SKILL.md" \ |
| 68 | + "$CLAUDE_PLUGIN_ROOT/skills/orchestration/references/agent-context.md" \ |
| 69 | + "$CLAUDE_PLUGIN_ROOT/skills/orchestration/references/delegation-template.md" \ |
| 70 | + "$CLAUDE_PLUGIN_ROOT/skills/orchestration/references/report-format.md" \ |
| 71 | + "$CLAUDE_PLUGIN_ROOT/skills/agents/copilot-cli/SKILL.md" \ |
| 72 | + "$CLAUDE_PLUGIN_ROOT/skills/agents/claude-cli/SKILL.md"; do |
| 73 | + [ -f "$f" ] && echo "OK: $f" || echo "MISSING: $f" |
| 74 | +done |
| 75 | +``` |
| 76 | + |
| 77 | +- ✅ All 9 files present |
| 78 | +- ❌ Any missing → tell the user which files are missing and suggest reinstalling: `/plugin install cortexlink@agent-plugins` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Check 3 — Hook Health |
| 83 | + |
| 84 | +**3a. Executable bit:** |
| 85 | + |
| 86 | +```bash |
| 87 | +ls -la "$CLAUDE_PLUGIN_ROOT/hooks/session-start" |
| 88 | +``` |
| 89 | + |
| 90 | +If `session-start` is not executable (no `x` in the permission bits): |
| 91 | +- Tell the user: "session-start is not executable — this will prevent the hook from firing." |
| 92 | +- Ask: "Should I fix the permissions now? (`chmod +x`)" |
| 93 | +- If yes: run `chmod +x "$CLAUDE_PLUGIN_ROOT/hooks/session-start"` and confirm ✅ Fixed |
| 94 | + |
| 95 | +**3b. jq dependency:** |
| 96 | + |
| 97 | +```bash |
| 98 | +jq --version 2>/dev/null || echo "NOT_FOUND" |
| 99 | +``` |
| 100 | + |
| 101 | +- ✅ jq installed (show version) |
| 102 | +- ❌ Not found → tell the user: the hook script requires `jq` to build its JSON output. Install with: |
| 103 | + - macOS: `brew install jq` |
| 104 | + - Linux: `sudo apt install jq` |
| 105 | + - Windows: `winget install jqlang.jq` |
| 106 | + |
| 107 | +**3c. Hook test run:** |
| 108 | + |
| 109 | +Tell the user: "Running the session-start hook to verify it produces valid output…" |
| 110 | + |
| 111 | +```bash |
| 112 | +"$CLAUDE_PLUGIN_ROOT/hooks/run-hook.cmd" session-start 2>&1 |
| 113 | +``` |
| 114 | + |
| 115 | +- ✅ Output is valid JSON containing `hookSpecificOutput` (Claude Code) or `additionalContext` (Copilot CLI) — show the first 200 characters of the context value as a preview |
| 116 | +- ❌ Output is invalid JSON, empty, or contains an error — show the raw output and tell the user this means the SessionStart hook is not injecting orchestration context into sessions |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Check 4 — CLI Agents |
| 121 | + |
| 122 | +**4a. Copilot CLI — installed?** |
| 123 | + |
| 124 | +```bash |
| 125 | +which copilot && copilot --version 2>/dev/null || echo "NOT_FOUND" |
| 126 | +``` |
| 127 | + |
| 128 | +If found, ask the user: "Copilot CLI is installed. Do you want me to run an authentication check? (This makes a live network call.)" |
| 129 | + |
| 130 | +If yes: |
| 131 | + |
| 132 | +```bash |
| 133 | +cd "$(git rev-parse --show-toplevel 2>/dev/null || echo "$HOME")" && \ |
| 134 | + copilot -p "ping" --no-ask-user --no-auto-update --no-color --allow-tool='read' --model=claude-haiku-4.5 2>/dev/null \ |
| 135 | + && echo "AUTH_OK" || echo "AUTH_FAIL" |
| 136 | +``` |
| 137 | + |
| 138 | +- ✅ Authenticated |
| 139 | +- ⚠️ Auth failed → run `copilot login` |
| 140 | +- ❌ Not installed → `brew install copilot-cli` (or see README) |
| 141 | + |
| 142 | +**4b. Claude CLI — installed?** |
| 143 | + |
| 144 | +```bash |
| 145 | +which claude && claude --version 2>/dev/null || echo "NOT_FOUND" |
| 146 | +``` |
| 147 | + |
| 148 | +If found, ask the user: "Claude CLI is installed. Do you want me to run an authentication check? (This makes a live network call.)" |
| 149 | + |
| 150 | +If yes: |
| 151 | + |
| 152 | +```bash |
| 153 | +claude -p "ping" --output-format text --allowedTools "Read" --max-turns 1 --no-session-persistence 2>/dev/null \ |
| 154 | + && echo "AUTH_OK" || echo "AUTH_FAIL" |
| 155 | +``` |
| 156 | + |
| 157 | +- ✅ Authenticated |
| 158 | +- ⚠️ Auth failed → run `claude auth login` |
| 159 | +- ❌ Not installed → `npm install -g @anthropic-ai/claude-code` |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## Check 5 — Setup State |
| 164 | + |
| 165 | +Read `~/.claude/CLAUDE.md`. Check for a `## CortexLink` section. |
| 166 | + |
| 167 | +- ✅ Present |
| 168 | +- ⚠️ Absent — not required if the hook is active (Claude Code), but can be added by running `/cortexlink:setup` |
| 169 | + |
| 170 | +Read `~/.copilot/copilot-instructions.md`. Check for a `## CortexLink` section. |
| 171 | + |
| 172 | +- ✅ Present |
| 173 | +- ❌ Absent — Copilot CLI needs this to have CortexLink context. Run `/cortexlink:setup` to add it. |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## Summary |
| 178 | + |
| 179 | +After all targeted checks complete, print this block filled in with results: |
| 180 | + |
| 181 | +``` |
| 182 | +Platform: [Claude Code / Copilot CLI / Unknown] |
| 183 | +
|
| 184 | +Hook |
| 185 | + [✅/❌] session-start script present |
| 186 | + [✅/❌/✅ Fixed] session-start executable |
| 187 | + [✅/❌] jq installed |
| 188 | + [✅/❌] hook test run valid |
| 189 | +
|
| 190 | +Plugin files |
| 191 | + [✅ All 9 present / ❌ Missing: list them] |
| 192 | +
|
| 193 | +Agents |
| 194 | + [✅/⚠️/❌] Copilot CLI [version / not installed / auth not checked] |
| 195 | + [✅/⚠️/❌] Claude CLI [version / not installed / auth not checked] |
| 196 | +
|
| 197 | +Setup |
| 198 | + [✅/⚠️] ~/.claude/CLAUDE.md |
| 199 | + [✅/❌] ~/.copilot/copilot-instructions.md |
| 200 | +
|
| 201 | +Status: [✅ Healthy / ⚠️ Needs attention] |
| 202 | +``` |
| 203 | + |
| 204 | +If status is healthy: |
| 205 | +> ✅ CortexLink is healthy. The SessionStart hook will inject orchestration context automatically on every new session. |
| 206 | +
|
| 207 | +If there are unresolved issues, list each one with its fix command. |
0 commit comments