---
description: "Customer-complaint triage. Ingests complaints (paste, csv/xlsx/txt/json file, Jira issue, Confluence URL), fetches Graylog evidence per trx/conversation id, correlates read-only against the selected client + BFF repos; per complaint: client/bff root cause + fix plan + dev prompt, or core routing recommendation, or insufficient-evidence. Report only, no dev chaining. Use when customer-reported errors need layer triage."
description-tr: "Müşteri şikayeti / müşteri kaynaklı hata triyajı. Şikayetleri alır (serbest metin, csv/xlsx/txt/json dosya, Jira issue, Confluence URL), trxId/conversationId ile Graylog kanıtı çeker, seçilen client + BFF repolarıyla salt-okunur eşleştirir ve her şikayeti sınıflandırır: client / bff (bizim sorumluluğumuz, kök neden analizi) veya core (core ekibine yönlendirme önerisi) veya insufficient-evidence. Rapor üretip durur - branch, worktree, commit, PR veya dev zinciri yok."
argument-hint: "[\"<run-name>\"] [--file <path>] [<jira-id | jira-url | confluence-url> ...]"
parameters: [{"name":"name","kind":"text"},{"name":"--file","kind":"path"},{"name":"sources","kind":"text","repeat":true}]
gui: form
destructive: false
confirm: none
---

# multi-agent complaint-analysis - Customer Complaint Triage

**Access check, before anything else.** This command can write outside this machine, so a login the site closed is stopped here, before any question or write.

```bash
ACCESS_LINE=$(node "$HOME/.claude/scripts/usage-access.mjs"); ACCESS_RC=$?
```

`ACCESS_RC` 3: print `$ACCESS_LINE` as written and stop: no question, no write, attended or unattended. Any other exit continues (the check fails open). Contract: `$HOME/.claude/multi-agent-refs/features/usage-reporting.md` "The access check".

**Input**: $ARGUMENTS (optional run name, optional `--file <path>`, optional Jira ids / Jira URLs / Confluence URLs; remaining free text is treated as pasted complaints)

Triage of customer-reported errors across the layers the team owns (client apps + BFFs): Graylog evidence by trx/conversation id, read-only repo correlation, a verdict per complaint. **Core failures get a routing recommendation, never a fix analysis.**

**Side-effect contract**: may write a local markdown report, post a Confluence page, or add a Jira comment - but **never** creates branches, worktrees, commits, or PRs. Stops at the report.

> **Language**: instruction prose stays English (`$HOME/.claude/multi-agent-refs/rules.md` Language Application). `AskUserQuestion` `question` / `label` / `description` and the report body follow `outputLanguage`; `header` (<=12 chars), verdict tokens, Graylog excerpts and payload metadata stay English.

Procedures, tables, the full locked decisions and the reusable refs: `$HOME/.claude/multi-agent-refs/complaint-analysis/phases.md`. Read the section each phase names before running it.

## Locked decisions (do not re-ask)

1. **Graylog is primary evidence.** A fetch failure never halts the run; it caps that complaint at `insufficient-evidence`.
2. **Ids are never guessed.** No trxId and no convId: the user supplies one or marks `skip-graylog`. Empty submit is not consent; re-ask.
3. **Read-only ops command.** No worktree, branch, commit, PR, or dev chaining.
4. **Redaction before any output** (`parse-complaints.sh`, Jira / Confluence text via `--stdin`). Raw PII never enters state, drafts or any target.
5. **Core is a residual classification, not a repo**: routing only, no fix analysis, no core-repo grepping.
6. **Layer mapping is user-confirmed** before Phase 1.
7. **Output default = Local file**; Confluence and Jira are never default-selected.
8. **Humanizer punctuation policy is non-negotiable**: no em-dash, en-dash, ellipsis, curly quotes or section sign; Turkish diacritics preserved, never ASCII-folded.
9. **Language split** as above.
10. **Citations.** `client`/`bff` cites a Graylog message (timestamp + source) AND a `file:line`, else `insufficient-evidence`; `core` cites the message naming the upstream service.
11. **One batch per run**; unrelated products: ask to split.
12. **No auto-commit.**
13. **Client/bff verdicts carry a dev handoff** (fix plan + dev prompt), never run here; other verdicts get none.

## Steps

### Phase 0 - Intake

`AskUserQuestion` chain into `state.complaintSpec.*`, breadcrumbs per `$HOME/.claude/multi-agent-refs/picker-contract.md`. Read `phases.md` "Phase 0" first.

0. **Language (BLOCKING)**: read `prefs.global.outputLanguage` (default `tr`) before the first picker; every `<localized: "...">` marker renders in it, never literally.
1. **Run name**: quoted argument, else `complaints-<YYYYMMDD>` (announce, do not ask).
2. **Account**: `$HOME/.claude/multi-agent-refs/_account-picker.md`; `null` only for a fully local run.
3. **Repos**: `$HOME/.claude/multi-agent-refs/_repo-picker.md`, owned client + BFF repos only.
3b. **Layer tagging**: infer a layer per repo, ONE confirmation question with the whole table (`Approve mapping` / `Override rows`) (Locked 6).
4. **Complaint input**: every source through `parse-complaints.sh` (Locked 4), merged as `C-01..C-NN`. Store reviews: optional, `phases.md` Step 4.
5. **Id confirmation loop** for every complaint missing both ids (Locked 2). Then `phase: "fetching_graylog"`.

### Phase 1 - Graylog evidence fan-out

`~/.claude/lib/fetch-graylog.sh --trx <trxId> --conv <convId>` per complaint with an id and no `skipGraylog`; environment `auto` unless the intake pins it (`--env prod|test`). Exit 2 / 3 / 6: warn ONCE per `$HOME/.claude/multi-agent-refs/keychain.md`, mark the rest `degraded`, continue; never halt (Locked 1). **Always name the environment when citing log evidence**; test-only evidence is `insufficient-evidence` for a production claim. Statuses and recorded fields: `phases.md` "Phase 1". Then `phase: "correlating_repos"`.

### Phase 2 - Repo evidence correlation (read-only)

Grep the selected repos for Graylog-derived signals only; degraded or skipped complaints get a `partial` text-similarity pass. Details: `phases.md` "Phase 2". Then `phase: "triaging"`.

### Phase 3 - Triage classification

Owned-layer origin -> `client:<ios|android|web>` / `bff:<mobile-bff|web-bff>`; downstream unowned failure -> `core` + routing recommendation; no evidence -> `insufficient-evidence`. Ambiguity lowers `confidence`, never invents evidence. Condition table, routing shape and the client/bff fix plan + dev prompt (Locked 13): `phases.md` "Phase 3". Then `phase: "drafting"`.

### Phase 4 - Draft, humanize, buffer

1. Render per `$HOME/.claude/multi-agent-refs/complaint-analysis-template.md` to `/tmp/complaint-analysis-<run-slug>-<UTC-iso8601>/report.md` (`outputs.draftDir`).
2. **Humanizer pass (required: actually invoke the `ai-common-toolkit:humanizer` skill; the punctuation grep alone does NOT satisfy this)**: `language: <tr|en>`, `tone: technical-explanatory`, `stripFancyPunctuation: true` (Locked 8).
3. `node $HOME/.claude/scripts/validate-complaint-doc.mjs <draft>` reports no banned punctuation (never `grep -P`).
4. Show path + size; `phase: "awaiting_output_decision"`.

### Phase 4.5 - Output destination picker

`AskUserQuestion` multiSelect, `header` `Output`, options `Local file` (pre-selected, Locked 7) / `Confluence page` / `Jira`; follow-ups in `phases.md` "Phase 4.5". Then `phase: "dispatching"`.

### Phase 5 - Validate, dispatch, report. Stop.

**Pre-dispatch gate (BLOCKING)**: `validate-complaint-doc.mjs <draft>`; any ERROR blocks dispatch until fixed and re-validated. Local copies to `complaints/<run-name>.md` with **no commit** (Locked 12); Confluence and Jira re-humanize and post per `phases.md` "Phase 5" (a Jira issue gets a comment, never a close or transition). 401 / 403: surface it and offer Local. Print the `outputLanguage` summary (`phases.md` "Phase 5").

**Stop. Do not chain into a dev run. Do not open a worktree. Do not create a branch.** Set `phase: "done"`.

### Resume contract

`state.complaintSpec.phase`: `intake | fetching_graylog | correlating_repos | triaging | drafting | awaiting_output_decision | dispatching | reporting | done`. At `awaiting_output_decision`, jump to Phase 4.5 when `report.md` is still in `outputs.draftDir`, else re-render Phase 4 from state. Earlier phases resume at their own boundary. Graylog results in state are never re-fetched.

## Notes

- Fully generic: hosts from `prefs.global.hosts.*`, tokens from `prefs.global.keychainMapping.*`; no company name, host, or real repo name in this file.
