원클릭으로
slack-diagnosis
Use when a Slack thread shows the bot behaving incorrectly and the root cause needs investigation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when a Slack thread shows the bot behaving incorrectly and the root cause needs investigation
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when a file or module is too large, responsibilities are tangled, or a cross-cutting redesign is needed
Use when literature notes exist and need citation verification, or before publishing any artifact that cites literature
Use at the end of a work session to embed learnings into conventions. Simplified for models with lower reasoning capacity.
Use at the end of a work session, or when accumulated findings need to be embedded into conventions, skills, or patterns
Use when the Slack bot needs to handle an operational action like launching an experiment, querying status, or processing approvals
Use when a plan, finding, or design needs adversarial review before committing to it
| name | slack-diagnosis |
| description | Use when a Slack thread shows the bot behaving incorrectly and the root cause needs investigation |
| complexity | medium |
| model-minimum | glm-5 |
| disable-model-invocation | false |
| allowed-tools | ["Read","Grep","Glob","Edit","Write","Bash(curl *)","Bash(jq *)","Bash(wc *)","Bash(cat *)","Bash(cd * && npx tsc --noEmit)"] |
| argument-hint | [problem description, thread URL, channel:timestamp, or 'recent'] |
Diagnose Slack bot issues by reading actual Slack messages, correlating with system logs, and implementing fixes.
The argument is context about what to investigate — a problem description, a thread URL, a channel:timestamp pair, or recent. Regardless of argument type, always start by fetching real Slack messages.
Before analyzing application logs, verify the process topology. This catches orphan processes, duplicate instances, and deployment issues that application logs alone cannot reveal.
pm2 list
Check for scheduler processes outside PM2:
ps aux | grep -E 'cli.js|scheduler' | grep -v grep
If multiple instances found:
ps -o pid,lstart,cmd -p <PID>Check for orphan log files:
ls -la /tmp/akari-*.log
If orphan log files exist or multiple scheduler processes are running:
/tmp/) instead of PM2 logs.Only proceed to Step 1 if the runtime environment is clean (single PM2-managed instance, no orphan logs).
The DM channel ID is D0AF4CX9U3U. The bot token is read inline from infra/scheduler/.env.
Always fetch recent DM history first to see the latest conversations:
curl -s "https://slack.com/api/conversations.history?channel=D0AF4CX9U3U&limit=20" \
-H "Authorization: Bearer $(grep '^SLACK_BOT_TOKEN=' infra/scheduler/.env | cut -d= -f2)" | jq '.messages[] | {ts, user, bot_id, text: (.text // "" | .[0:200]), thread_ts, reply_count}'
Then, for any message that has thread_ts (i.e., is part of a thread) and looks relevant to the reported issue, fetch the full thread:
curl -s "https://slack.com/api/conversations.replies?channel=D0AF4CX9U3U&ts=THREAD_TS&limit=100" \
-H "Authorization: Bearer $(grep '^SLACK_BOT_TOKEN=' infra/scheduler/.env | cut -d= -f2)" | jq '.messages[] | {ts, user, bot_id, text: (.text // "" | .[0:500])}'
If a specific channel:timestamp or thread URL was provided, fetch that thread too. But always start with recent history to get the full picture.
Identify the relevant thread(s): match the argument's problem description against the fetched messages. Look for threads where the described issue occurred.
For the same time window as the relevant thread(s):
Interaction log: Read .scheduler/metrics/interactions.jsonl — filter entries whose threadKey matches the thread's channel:timestamp. Fields to examine:
action, result, detail — what the bot did and whether it succeededturnsBeforeAction — how many user messages preceded this action (high = friction)userCorrected — whether the user had to rephraseintentFulfilled — auto-classified as fulfilled/partial/failed/abandonedintentType — status/approval/experiment/session/job/otherPM2 application log: Read the tail of ~/.pm2/logs/akari-out.log around the thread's time window. Look for [chat], [agent], [experiments], [slack], or [autofix] entries that correlate with the conversation.
Chat agent source: If the bot did something unexpected, cross-reference with:
infra/scheduler/src/chat.ts — action dispatch, confirmation flow, context gatheringinfra/scheduler/src/agent.ts — agent profiles (model, turns, duration), spawn logicinfra/scheduler/src/event-agents.ts — event-triggered agents (experiment completion → deep work escalation)infra/scheduler/src/slack.ts — Slack message delivery, experiment watcher callbacksFor each message exchange in the relevant thread(s), annotate:
For each issue found, classify:
| Category | Description | Example |
|---|---|---|
| Misunderstanding | Bot parsed the wrong intent | User said "restart the experiment" but bot showed status instead |
| Missing capability | User wanted something the bot can't do yet | "Show me the experiment logs" but no log-viewing action exists |
| Poor feedback | Bot did the right thing but communicated it badly | Launched experiment but didn't confirm which command was run |
| Error handling | System error was not surfaced or handled gracefully | API call failed silently, user got no response |
| Latency/UX | Response was too slow or required too many steps | User had to send 3 messages to accomplish one action |
| Incorrect behavior | Bot or system did the wrong thing entirely | Approved the wrong item, launched wrong experiment |
| Information gap | Bot lacked context it should have had | Didn't know experiment was already running |
| Escalation issue | Deep work escalation triggered incorrectly or task description was poor | Deep work spawned but couldn't complete due to missing context |
Also identify what worked well.
For each issue, propose a concrete fix. Classify by layer:
Prioritize by: impact x frequency.
## Slack Thread Diagnosis: <brief description>
Date: YYYY-MM-DD
Thread: <channel:timestamp or URL>
Messages analyzed: <count>
### Conversation summary
<2-3 sentences describing what the thread was about>
### What worked well
<bulleted list of positive observations>
### Issues found
#### Issue 1: <title>
Category: <from table above>
Layer: <L0/L2/L3/System>
Severity: high | medium | low
Evidence: <quote from thread or log>
Impact: <what went wrong for the user>
Fix: <concrete change — file, function, and what to change>
[repeat for each issue]
### System log correlation
<any interesting findings from interactions.jsonl or PM2 logs>
### Improvement roadmap
1. <highest priority fix — what and where>
2. ...
### Patterns
<any recurring patterns that suggest deeper issues>
MANDATORY: Write the diagnosis to a file before implementing any fixes.
File path: projects/<project>/diagnosis/diagnosis-<brief-slug>-YYYY-MM-DD.md
Create the diagnosis/ directory if it doesn't exist yet. Use the project most relevant to the issue being diagnosed (usually akari for infrastructure issues).
Diagnosis vs postmortem: Use diagnosis/ for operational investigations (unexpected behavior, thread analysis). If the investigation reveals a serious incident — resource waste, systemic failure, or flawed agent reasoning — escalate to a /postmortem record in projects/<project>/postmortem/ instead.
Example: projects/akari/diagnosis/diagnosis-slack-thread-model-comparison-focused-v2-2026-02-16.md
The diagnosis file must contain the complete output from Steps 1-5, formatted as markdown.
This ensures:
After saving the diagnosis, convert improvement roadmap items to tasks for items NOT fixed in this session:
[fleet-eligible] [skill: execute] for code fixes, [skill: record] for documentationDone when: derived from the fix descriptionWhy: referencing this diagnosis file path[requires-opus] investigation tasksThis ensures lower-priority improvements from slack diagnoses enter the task pipeline rather than being forgotten after the urgent fix is applied.
This step is mandatory for L0 code fixes. 33% of TDD violations originate from Slack diagnosis urgency — the "user is waiting" pressure bypasses test discipline. Writing the test first takes ~2 minutes and prevents regressions.
<module>.test.ts next to the source file being fixed.cd infra/scheduler && npm test to confirm the test fails (or target a specific file: cd infra/scheduler && npx vitest run <file>).Skip this step ONLY if the fix is purely non-behavioral: prompt text changes, log message wording, or configuration value changes with no testable code path.
| Excuse | Reality |
|---|---|
| "The user is waiting / this is urgent" | Urgency makes regression tests MORE important. The next occurrence won't have a user watching to verify. The test takes 2 minutes. |
| "I already verified it in the Slack thread" | Manual thread verification is ad-hoc, non-repeatable, and leaves no regression guard. |
| "The fix is obvious, just one line" | One-line fixes cause regressions. The regression test takes 2 minutes. |
After diagnosis is saved and regression test is written, implement fixes that are safe to apply autonomously.
Safe to fix autonomously (L0 code fixes):
Requires approval (write to APPROVAL_QUEUE.md instead):
After any TypeScript edit, run cd infra/scheduler && npx tsc --noEmit to verify the code compiles.
After implementing fixes:
cd infra/scheduler && npm test to confirm the regression test now passes.Follow docs/sops/commit-workflow.md. Commit message: slack-diagnosis: <brief summary of findings and fixes>