@chainpatrol/sdk 0.8.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1648 @@
1
+ // src/skill/content.ts
2
+ function buildSkillContent(version) {
3
+ return `---
4
+ name: chainpatrol
5
+ version: ${version}
6
+ description: |
7
+ ChainPatrol CLI assistant. Helps use the chainpatrol CLI tool: login via device
8
+ code flow, check auth status, list detection configs, list reports (including
9
+ customer-reported ones), run CLI commands, and run an organization
10
+ healthcheck across the detection / reviewing / blocklisting / takedown
11
+ pipeline.
12
+ Use when: "chainpatrol cli", "login to chainpatrol", "check detection configs",
13
+ "am I logged in", "list configs", "use the cli", "list reports",
14
+ "customer reports", "reports reported by customer", "find detection gaps",
15
+ "org healthcheck", "organization health check", "audit my org",
16
+ "what's wrong with org", "review org setup", "list orgs", "list organizations",
17
+ "get org", "get organization", "show org details", "org by slug",
18
+ "fetch org details", "org info",
19
+ "orgs with takedowns off", "automation off across orgs",
20
+ "which customers have X enabled", "service toggles by org",
21
+ "obligatory admin approval", "obligatory organization admin approval",
22
+ "obligatory approval", "admin approval enabled", "admin approval orgs",
23
+ "requires customer review", "requires admin approval",
24
+ "orgs that require admin approval", "orgs requiring approval",
25
+ "which orgs require approval for twitter", "approval scope",
26
+ "admin approval asset types", "approval per asset type",
27
+ "pending approval", "pending approvals", "pending service approval",
28
+ "orgs with pending approval", "pending wallet blocking approval",
29
+ "pending takedown approval", "awaiting approval", "waiting for approval",
30
+ "is protection active approval", "wallet blocking approval",
31
+ "who needs to approve wallet blocking", "service change request",
32
+ "track orgs with pending approval", "orgs awaiting sign-off",
33
+ "is this URL blocked", "is this domain blocked", "is this address blocked",
34
+ "check this asset", "asset check", "lookup asset status",
35
+ "what is ARCHIVE_ORG", "what does PAGE mean", "list asset types",
36
+ "supported asset types", "asset type mapping", "asset type enum",
37
+ "what asset types are there", "human readable asset type",
38
+ "how many takedowns", "takedowns in the last", "threats taken down",
39
+ "across all clients", "across all customers", "across all orgs",
40
+ "across all brands", "company-wide", "total takedowns", "total threats",
41
+ "total reports", "average takedowns", "average threats", "average per day",
42
+ "average per customer", "average per org", "rollup across customers",
43
+ "sum across orgs", "sum across customers",
44
+ "trends in org", "search for trends", "trend search", "look for trends",
45
+ "any trends", "trending threats", "spike in asset type",
46
+ "spike in threat volume", "coordinated attack", "spike check",
47
+ "anything unusual", "anything new for", "what's new for",
48
+ "employee being targeted", "spike on a sub-brand", "spike on a brand",
49
+ "sub-brand spike",
50
+ "list brands", "brands for org", "list sub-brands", "employee brands",
51
+ "individual brands", "brand list", "all brands in org".
52
+ allowed-tools:
53
+ - Bash
54
+ - Read
55
+ - Grep
56
+ - Glob
57
+ ---
58
+
59
+ # ChainPatrol CLI Skill
60
+
61
+ You are a ChainPatrol CLI assistant. Help the user interact with the ChainPatrol
62
+ platform using the CLI tool.
63
+
64
+ ## Running the CLI
65
+
66
+ IMPORTANT: Claude Code's sandbox shell often has a minimal PATH
67
+ (\`/usr/bin:/bin:/usr/sbin:/sbin\`) that may not include the directory where
68
+ \`chainpatrol\` is installed, so bare \`chainpatrol\` calls may fail with
69
+ "command not found". Always invoke the CLI by its full path.
70
+
71
+ The install location depends on the environment:
72
+
73
+ - **Local installs** typically land at \`/usr/local/bin/chainpatrol\` (when
74
+ installed globally via \`npm install -g @chainpatrol/cli\`).
75
+ - **Cloud / sandboxed environments** (e.g. Claude Code on the web, Cursor
76
+ Cloud) often install Node into \`/opt\` and the binary ends up under a
77
+ Node-version-specific path like \`/opt/node22/bin/chainpatrol\`. Variants
78
+ such as \`/opt/node20/bin/chainpatrol\` or \`/opt/node21/bin/chainpatrol\`
79
+ are also possible depending on which Node version is active.
80
+
81
+ To find the binary, try (in order):
82
+
83
+ \`\`\`bash
84
+ command -v chainpatrol \\
85
+ || ls /usr/local/bin/chainpatrol /opt/node*/bin/chainpatrol 2>/dev/null \\
86
+ | head -n 1
87
+ \`\`\`
88
+
89
+ Then use that full path for every subsequent command, e.g.:
90
+
91
+ \`\`\`bash
92
+ /opt/node22/bin/chainpatrol <command> [options]
93
+ # or
94
+ /usr/local/bin/chainpatrol <command> [options]
95
+ \`\`\`
96
+
97
+ All examples below use the short name \`chainpatrol\` for readability, but you
98
+ MUST substitute the full resolved path in your Bash commands.
99
+
100
+ ## Available Commands
101
+
102
+ ### \`login\` \u2014 Authenticate with ChainPatrol
103
+
104
+ Uses the OAuth Device Code flow (RFC 8628):
105
+ 1. CLI requests a device code from the server
106
+ 2. User is shown a code and a URL to visit
107
+ 3. User authorizes in the browser
108
+ 4. CLI polls for the token
109
+
110
+ \`\`\`bash
111
+ chainpatrol login
112
+ \`\`\`
113
+
114
+ JSON mode (for automation):
115
+ \`\`\`bash
116
+ chainpatrol --json login
117
+ \`\`\`
118
+
119
+ #### Running \`login\` from an agent (headless / non-TTY)
120
+
121
+ The login flow blocks for up to 30 minutes while polling for the user to
122
+ authorize in their browser. If you (the agent) run it as a foreground
123
+ command and wait for it to exit before reading output, you will appear
124
+ stuck \u2014 the verification URL will never be shown because the process is
125
+ still polling.
126
+
127
+ **Always run \`login\` in the background and stream its output**, then
128
+ surface the verification URL to the user as soon as it appears:
129
+
130
+ \`\`\`bash
131
+ # 1. Kick off login in the background (do NOT wait for it to exit)
132
+ chainpatrol --json login > /tmp/cp-login.out 2>&1 &
133
+
134
+ # 2. Wait briefly for the first line, which contains the URL
135
+ for _ in 1 2 3 4 5 6 7 8 9 10; do
136
+ test -s /tmp/cp-login.out && break
137
+ sleep 1
138
+ done
139
+ cat /tmp/cp-login.out
140
+ \`\`\`
141
+
142
+ The first line emitted is JSON describing the device code, e.g.:
143
+
144
+ \`\`\`json
145
+ {"action":"open_url","user_code":"ABCD-1234","verification_uri":"https://app.chainpatrol.io/auth/verify-device","verification_uri_complete":"https://app.chainpatrol.io/auth/verify-device?user_code=ABCD-1234","expires_in":1800,"headless":true}
146
+ \`\`\`
147
+
148
+ Show the user the \`verification_uri_complete\` link (or
149
+ \`verification_uri\` + \`user_code\` as a fallback) and explain that the
150
+ CLI will pick up the token automatically once they authorize. Then keep
151
+ the background process running and tail it for the final
152
+ \`{"status":"success",...}\` or \`{"error":...}\` line.
153
+
154
+ CLI v0.3.3+ also auto-detects non-TTY stdout and prints the URL as plain
155
+ text immediately when you run \`chainpatrol login\` without \`--json\`,
156
+ so the same background+tail pattern works without \`--json\`. Prefer
157
+ \`--json\` so the output is structured and machine-parseable.
158
+
159
+ ### \`logout\` \u2014 Clear stored credentials
160
+
161
+ \`\`\`bash
162
+ chainpatrol logout
163
+ \`\`\`
164
+
165
+ ### \`asset check\` \u2014 Check one or many assets against the blocklist
166
+
167
+ Look up a URL, domain, or crypto address and return its aggregated status
168
+ (\`BLOCKED\`, \`ALLOWED\`, or \`UNKNOWN\`) plus a per-source breakdown
169
+ (ChainPatrol + external feeds like eth-phishing-detect, phishfort, seal,
170
+ polkadot-phishing). Works whether you're authenticated via device-code
171
+ login or via a \`CHAINPATROL_API_KEY\` env var.
172
+
173
+ Single asset:
174
+
175
+ \`\`\`bash
176
+ chainpatrol asset check https://phish.example
177
+ chainpatrol asset check 0xabc123...
178
+ \`\`\`
179
+
180
+ #### Bulk checks (preferred for >1 asset)
181
+
182
+ Pass multiple assets in a single invocation \u2014 the CLI runs them in
183
+ parallel (concurrency 10) and returns one row per asset. **Do this
184
+ instead of looping the CLI in a shell \`for\` loop**: one process, one
185
+ auth handshake, parallel HTTP. Use either positional args or repeated
186
+ \`--asset\`:
187
+
188
+ \`\`\`bash
189
+ # positional form
190
+ chainpatrol asset check a.example b.example c.example
191
+
192
+ # repeated --asset (handy when content has spaces or special chars)
193
+ chainpatrol asset check --asset a.example --asset b.example
194
+
195
+ # from a file of one-asset-per-line (use xargs to splat into one call)
196
+ xargs -a domains.txt chainpatrol asset check
197
+ \`\`\`
198
+
199
+ JSON mode is the agent-friendly default \u2014 single-asset JSON keeps the
200
+ flat \`{ content, status, source, reason?, sources[], watchStatus? }\`
201
+ shape; multi-asset JSON returns \`{ results: [...], summary: { checked,
202
+ blocked, allowed, unknown, errored } }\`:
203
+
204
+ \`\`\`bash
205
+ chainpatrol --json asset check https://phish.example
206
+ chainpatrol --json asset check a.example b.example c.example
207
+ \`\`\`
208
+
209
+ Markdown / CSV are also available for sharing in docs / chat:
210
+
211
+ \`\`\`bash
212
+ chainpatrol asset check phish.example --output markdown
213
+ chainpatrol asset check a.example b.example --output csv
214
+ \`\`\`
215
+
216
+ If any individual lookup fails, the CLI still prints results for the
217
+ successful ones, then exits non-zero so failures aren't silently
218
+ swallowed.
219
+
220
+ ### \`asset types\` \u2014 List every supported asset type and what it means
221
+
222
+ When a user asks "what is \`ARCHIVE_ORG\`?", "what does \`PAGE\` mean?",
223
+ or "what asset types does ChainPatrol support?" \u2014 don't guess. Run:
224
+
225
+ \`\`\`bash
226
+ chainpatrol asset types
227
+ chainpatrol --json asset types
228
+ \`\`\`
229
+
230
+ The mapping is bundled with the CLI (no API or auth required), so this
231
+ is safe to run anywhere. Each row is \`{ type, label, description }\`:
232
+ \`type\` is the canonical enum value used by every \`--asset-type\` flag
233
+ (\`asset list\`, \`threats list\`, \`takedowns list\`, \`detections list\`,
234
+ \`reports list\`, \`orgs assets list\`); \`label\` is the human-friendly
235
+ display name (\`ARCHIVE_ORG\` \u2192 \`Archive.org\`, \`PAGE\` \u2192 \`Page\`,
236
+ \`FIVE_HUNDRED_PX\` \u2192 \`500px\`); \`description\` is a one-line note for
237
+ unobvious entries.
238
+
239
+ Use this whenever you need to translate between enum and display name,
240
+ validate that a type the user mentioned is real, or enumerate options
241
+ before constructing a filter.
242
+
243
+ ### \`configs list\` \u2014 List detection configurations
244
+
245
+ Requires authentication and an organization slug.
246
+
247
+ \`\`\`bash
248
+ chainpatrol configs list --org <slug>
249
+ \`\`\`
250
+
251
+ JSON mode:
252
+ \`\`\`bash
253
+ chainpatrol --json configs list --org <slug>
254
+ \`\`\`
255
+
256
+ The \`--org\` flag is saved for future commands. Once set, you can omit it:
257
+ \`\`\`bash
258
+ chainpatrol configs list
259
+ \`\`\`
260
+
261
+ ### \`reports list\` \u2014 List recent reports for an organization
262
+
263
+ Returns the most recent reports submitted for an organization. Each report
264
+ includes a \`reportedByCustomer\` boolean indicating whether the report was
265
+ submitted by a customer of ChainPatrol (e.g. via API key, Slack/Telegram bot,
266
+ or another external integration) rather than by ChainPatrol's automated
267
+ detections or staff reviewers.
268
+
269
+ \`\`\`bash
270
+ chainpatrol reports list --org <slug>
271
+ \`\`\`
272
+
273
+ Common flags:
274
+ - \`--limit <n>\` page size (1-20)
275
+ - \`--cursor <id>\` pagination cursor (use \`nextCursor\` from a previous response)
276
+ - \`--status <s>\` filter by report status (e.g. \`TODO\`, \`IN_PROGRESS\`, \`DONE\`)
277
+ - \`--search <q>\` search query across title/description/asset content
278
+ - \`--reported-by-customer\` only show reports submitted by a customer
279
+ - \`--no-reported-by-customer\` only show reports NOT submitted by a customer
280
+ (i.e. found by ChainPatrol's automation or staff)
281
+
282
+ JSON mode is recommended when you want to analyze the data programmatically:
283
+ \`\`\`bash
284
+ chainpatrol --json reports list --org <slug> --reported-by-customer
285
+ \`\`\`
286
+
287
+ The response includes \`totalCount\`: the number of reports matching the same
288
+ filters as the query, independent of \`--limit\`/\`--cursor\`. Use it to:
289
+ - Report a denominator when sampling (e.g. "sampled 200 of ~4,235").
290
+ - Decide up front whether to page through everything or narrow filters first \u2014
291
+ if \`totalCount\` is huge, add more filters instead of paginating blindly.
292
+ - Drive a progress indicator while paginating with \`nextCursor\`.
293
+
294
+ \`totalCount\` honors every list filter (\`--status\`, \`--reported-by-customer\` /
295
+ \`--no-reported-by-customer\`, \`--exclude-automation\`, \`--review-status\` /
296
+ \`--only-rejected\`, \`--asset-type\`, brand, \`--country-code\`, \`--from\`/\`--to\`,
297
+ \`--updated-from\`/\`--updated-to\`, \`--search\`, \`--reporter-query\`), so changing
298
+ filters changes the count. \`reports\` (the returned page) is capped by
299
+ \`--limit\` (max 20); \`totalCount\` is not.
300
+
301
+ #### Use case: finding gaps in ChainPatrol detection
302
+
303
+ Customer-reported reports (\`reportedByCustomer=true\`) are a valuable signal
304
+ for finding gaps in ChainPatrol's automated detections and staff triage: each
305
+ one is a threat the customer found before ChainPatrol's own systems did. When
306
+ the user asks something like:
307
+
308
+ - "show me the threats our customers are reporting"
309
+ - "what is X's customer reporting?"
310
+ - "where are we missing detections for org Y?"
311
+ - "summarize recent reports submitted by customers"
312
+
313
+ \u2026use \`chainpatrol --json reports list --org <slug> --reported-by-customer\`
314
+ to fetch them, then highlight patterns (asset types, domains, common
315
+ keywords, recurring brands) so the user can:
316
+ 1. Spot detection coverage gaps to fix in the org's detection configs.
317
+ 2. Improve staff triage runbooks for recurring scams.
318
+ 3. Work directly with the customer to close the loop and prevent future
319
+ misses.
320
+
321
+ You can also compare with the non-customer set using
322
+ \`--no-reported-by-customer\` to gauge detection coverage on the same time
323
+ window.
324
+
325
+ ### \`detections healthcheck\` \u2014 Validate enabled detection configs produce recent results
326
+
327
+ Server-side check. The CLI calls the ChainPatrol API; the server fetches each
328
+ enabled detection config for the org, counts results produced in the lookback
329
+ window, and FAILs configs that fall under \`--min-results\` (or whose run
330
+ errored when \`--run\` is set).
331
+
332
+ \`\`\`bash
333
+ chainpatrol --json detections healthcheck --org <slug>
334
+ \`\`\`
335
+
336
+ Flags:
337
+ - \`--source <key>\` only validate one source (e.g. \`twitter_search\`)
338
+ - \`--min-results <n>\` minimum results required in the window to pass
339
+ - \`--lookback-hours <n>\` size of the lookback window
340
+ - \`--run\` ask the server to run each config first, then validate the fresh output
341
+ - \`--include-disabled\` also validate disabled configs
342
+
343
+ What this command covers:
344
+ - Configs that have gone silent (recentResultCount below threshold)
345
+ - Configs that error when run (runOk=false) when \`--run\` is set
346
+
347
+ What it does NOT cover:
348
+ - Reviewing backlog / SLA breaches \u2192 use \`queues snapshot\`
349
+ - Takedown ToDo / In Progress / Cancelled volumes \u2192 use \`queues snapshot\`
350
+ - Spikes or drops in detection volume over time \u2192 use \`metrics breakdown\`
351
+ - Customer-reported gaps \u2192 use \`reports list --reported-by-customer\`
352
+ - Google Safe Browsing submission errors (not yet exposed in CLI)
353
+
354
+ Use it as the first signal in the Detection part of an org healthcheck, then
355
+ fall back to the manual checks in the HealthCheck Guide below for everything
356
+ else.
357
+
358
+ > Prefer the newer \`healthchecks\` namespace below. \`detections healthcheck\`
359
+ > is the original single-purpose command; the \`healthchecks\` namespace is
360
+ > the canonical place to discover and run every check we expose.
361
+
362
+ ### \`healthchecks list | run\` \u2014 Run uniform org healthchecks via the public API
363
+
364
+ The \`healthchecks\` namespace is the canonical way to run the named checks
365
+ from the Organization HealthCheck Guide below. Each implemented endpoint
366
+ returns the same uniform shape \u2014 \`{ id, ok, severity, observed, threshold,
367
+ findings, suggestedAction }\` \u2014 so the CLI / agent can render every check the
368
+ same way regardless of category.
369
+
370
+ \`\`\`bash
371
+ # Discover every check the platform exposes today, including planned checks
372
+ # that are not yet implemented on the backend.
373
+ chainpatrol --json healthchecks list
374
+
375
+ # Run a single named check.
376
+ chainpatrol --json healthchecks run reviewing.backlog --org <slug>
377
+
378
+ # Run every implemented check in parallel and aggregate the results.
379
+ chainpatrol --json healthchecks run --all --org <slug>
380
+ \`\`\`
381
+
382
+ Each implemented check has a stable id of the form \`category.name\`. Implemented
383
+ ids today: \`detections.silent-configs\`, \`reviewing.backlog\`,
384
+ \`reviewing.old-proposals\`, \`reviewing.watchlist-backlog\`,
385
+ \`reviewing.watchlist-old\`, \`takedowns.todo-volume\`,
386
+ \`takedowns.in-progress-volume\`, \`takedowns.stale-in-progress\`,
387
+ \`takedowns.cancelled-count\`, \`takedowns.automation-off\`,
388
+ \`assets.dead-asset-spike\`.
389
+
390
+ ### Pending proposals: "Needs Review" vs "Watchlisted"
391
+
392
+ PENDING proposals split into two operationally distinct buckets, and we
393
+ grade them with separate checks:
394
+
395
+ - **Needs Review** \u2014 pending proposals the reviewing UI shows by default
396
+ (\`excludeWatchlisted=true\`): assets that are NOT on a watchlist, OR
397
+ reports submitted by a customer (those stay visible even when the asset
398
+ is watchlisted). This is the actionable queue reviewers work from, so
399
+ pile-ups and old items here are high-priority signals (\`fail\` severity
400
+ is reachable).
401
+ - **Watchlisted** \u2014 pending proposals on watchlisted assets (excluding
402
+ customer-reported reports). The reviewing UI hides these by default
403
+ because watchlisting is the act of intentionally deferring an asset.
404
+ Pile-ups and aged items here are worth surfacing as cleanup work, but
405
+ severity is **capped at warn** so they never block on the same SLA as
406
+ Needs Review. When reporting findings, treat these as lower-priority.
407
+
408
+ Each healthcheck result includes an \`appUrl\` field (string or null) that
409
+ deep-links to the relevant filtered admin page in the web app \u2014 e.g. the
410
+ takedowns page filtered to IN_PROGRESS for \`takedowns.stale-in-progress\`,
411
+ or the review page filtered to oldest pending for \`reviewing.old-proposals\`.
412
+ **When reporting a non-OK healthcheck to the user, always surface the
413
+ \`appUrl\` so they can jump straight to the right view.** Some checks
414
+ (\`detections.silent-configs\`, \`assets.dead-asset-spike\`) emit \`null\`
415
+ because no filterable list page exists for that signal yet.
416
+
417
+ Implemented checks today:
418
+
419
+ - **detections.silent-configs** \u2014 equivalent to \`detections healthcheck\`,
420
+ exposed under the uniform shape.
421
+ - **reviewing.backlog** \u2014 counts Needs Review pending proposals and grades
422
+ severity against per-org thresholds (default warn=50, fail=100).
423
+ - **reviewing.old-proposals** \u2014 counts Needs Review proposals older than
424
+ the warn / fail age thresholds (default 7 / 14 days) and lists the
425
+ oldest offenders.
426
+ - **reviewing.watchlist-backlog** \u2014 counts watchlisted pending proposals
427
+ (default warn=200). Severity capped at warn.
428
+ - **reviewing.watchlist-old** \u2014 counts watchlisted pending proposals older
429
+ than the warn-age threshold (default 30 days) and lists the oldest.
430
+ Severity capped at warn.
431
+ - **takedowns.todo-volume** \u2014 counts takedowns in TODO (default warn=50,
432
+ fail=100). Pile-ups here usually mean an automation gap on a new threat
433
+ surface, or manual-filing capacity issues.
434
+ - **takedowns.in-progress-volume** \u2014 counts takedowns currently IN_PROGRESS
435
+ regardless of age (default warn=30, fail=75). Complements
436
+ \`stale-in-progress\` \u2014 a high count signals vendor-side or
437
+ submission-format problems even before items go stale.
438
+ - **takedowns.stale-in-progress** \u2014 counts takedowns sitting in IN_PROGRESS
439
+ past the staleness threshold (default 7 days) and lists the oldest.
440
+ - **takedowns.cancelled-count** \u2014 counts CANCELLED transitions from the
441
+ TakedownEvent log over a rolling window (default 7d, warn=3, fail=10).
442
+ Cancellations should be rare; a spike usually means a proposal-funnel
443
+ quality problem or misuse of the CANCELLED status.
444
+ - **takedowns.automation-off** \u2014 flags orgs with takedown service enabled
445
+ but \`isAutomatedTakedownsActive\` off for too long (default warn=30d,
446
+ fail=60d). Skipped for orgs with takedown service entirely disabled.
447
+ - **assets.dead-asset-spike** \u2014 compares DEAD-detection events in the
448
+ current window against the prior baseline rate; warns on a multiplier
449
+ exceeding the threshold (default 24h vs 7d, \xD72 warn / \xD74 fail) once the
450
+ current count clears the \`minSpikeCount\` floor. Catches liveness-checker
451
+ regressions after platform changes.
452
+
453
+ The following checks are listed by \`healthchecks list\` (\`implemented: false\`)
454
+ but **not yet implemented on the backend** \u2014 when the agent surfaces them in
455
+ a healthcheck report, mark them explicitly as "manual check, no API yet":
456
+
457
+ - **detections.coverage-gaps** \u2014 blocked assets vs. enabled-source correlation.
458
+ Still requires manual reasoning with \`configs list\` + \`reports list\`.
459
+ - **detections.spike** / **detections.drop** \u2014 require server-side baseline
460
+ modeling. Use \`metrics breakdown --by day\` as an interim signal.
461
+ - **reviewing.auto-approval-spike** \u2014 needs distinguishing automation vs.
462
+ human approvers in the review history. Use \`metrics breakdown\` as a proxy.
463
+ - **blocklisting.gsb-cancelled-rate** \u2014 Google Safe Browsing submission state
464
+ is not yet exposed in the public API.
465
+ - **assets.dead-but-alive** / **assets.alive-but-marked-dead** \u2014 require live
466
+ HTTP probes against asset URLs, which is not a synchronous-healthcheck
467
+ shape. Until a dedicated probe command exists, sample a handful manually
468
+ from \`assets list --status DEAD\` (or ALIVE) and verify in a browser. Notify
469
+ ChainPatrol engineering if the liveness checker looks miscalibrated.
470
+
471
+ When the user asks to "run a healthcheck on org X", the canonical command is:
472
+
473
+ \`\`\`bash
474
+ chainpatrol --json healthchecks run --all --org X
475
+ \`\`\`
476
+
477
+ This iterates the implemented entries in \`healthchecks list\`, runs them in
478
+ parallel, and aggregates the uniform results. Combine with the manual checks
479
+ in the HealthCheck Guide below for everything still marked
480
+ \`implemented: false\`.
481
+
482
+ ### \`queues snapshot\` \u2014 Operations review/takedown queue snapshot
483
+
484
+ Server-side aggregation of the operations review queue (pending proposals,
485
+ SLA breaches, age buckets) and the takedown queue (open, in-progress, stale).
486
+
487
+ \`\`\`bash
488
+ chainpatrol --json queues snapshot --org <slug>
489
+ \`\`\`
490
+
491
+ Useful for the **Reviewing** and **Takedowns** sections of the HealthCheck
492
+ Guide. Key signals in the response:
493
+ - \`reviewQueue.totalPendingProposals\` and \`reviewQueue.distinctReports\` \u2014
494
+ backlog size
495
+ - \`reviewQueue.slaBuckets.breached\` \u2014 SLA breaches (treat any breach as a
496
+ finding)
497
+ - \`reviewQueue.ageBuckets.gte168h\` \u2014 proposals older than 7 days (anything
498
+ >14 days from the manual guide should always be in here)
499
+ - \`takedownQueue.totalOpen\` and \`takedownQueue.staleInProgress\` \u2014 open
500
+ and stuck takedowns
501
+
502
+ Use \`--all\` to snapshot every org you have access to instead of a single slug.
503
+
504
+ ### \`orgs list\` \u2014 List organizations with subscription status, service toggles, and admin-approval scope
505
+
506
+ Returns every organization the caller can see, with each org's
507
+ subscription status (\`PROSPECT\`, \`TRIAL\`, \`ACTIVE\`, \`INTEGRATION\`),
508
+ which services are active, and the per-org "Obligatory Organization
509
+ Admin Approval" toggle (with its asset-type scope). Use it to answer
510
+ questions like "which customers have takedowns enabled but automation
511
+ off?", "which prospects don't have detection turned on yet?", or "which
512
+ orgs require admin approval before adding Twitter assets to the
513
+ blocklist?" \u2014 filters compose with AND and are applied server-side, so
514
+ one call returns the final list.
515
+
516
+ \`\`\`bash
517
+ chainpatrol --json orgs list \\
518
+ --subscription-status ACTIVE \\
519
+ --service-active takedowns \\
520
+ --service-manual takedowns
521
+ \`\`\`
522
+
523
+ #### Per-service response shape \u2014 \`automated\` is takedowns-only
524
+
525
+ Every service exposes an \`active\` boolean. **Only \`takedowns\`
526
+ additionally exposes \`automated\`** \u2014 that is the one service where the
527
+ manual-vs-automated distinction changes real platform behavior (whether
528
+ ChainPatrol files the takedown on its own, or queues it for a human to
529
+ file). \`reporting\`, \`reviewing\`, and \`protection\` have backing
530
+ \`isAutomated*Active\` columns in the database, but those flags have no
531
+ operational effect today, so the API deliberately omits them from both
532
+ the response and the \`services\` filter \u2014 surfacing them would invite
533
+ misleading filters like "reporting.automated=true" that don't mean
534
+ anything. \`detection\` and \`darkWebMonitoring\` have always been
535
+ single-flag services.
536
+
537
+ #### Obligatory Organization Admin Approval
538
+
539
+ Each org also has a separate "Obligatory Organization Admin Approval"
540
+ toggle (\`Organization.requiresCustomerReview\` in the schema, surfaced
541
+ on the Services settings page in the app) that gates customer-side
542
+ review of proposals ChainPatrol staff have already approved before
543
+ they're added to the blocklist. It is NOT one of the operational
544
+ services above \u2014 it is an org-policy toggle with its own per-asset-type
545
+ scope.
546
+
547
+ Each org's response includes:
548
+
549
+ \`\`\`json
550
+ {
551
+ "obligatoryAdminApproval": {
552
+ "active": true,
553
+ "assetTypes": ["TWITTER", "URL"]
554
+ }
555
+ }
556
+ \`\`\`
557
+
558
+ - \`active=true\` + empty \`assetTypes\` means approval applies to
559
+ **all** asset types \u2014 the org has not narrowed the scope.
560
+ - \`active=true\` + a non-empty \`assetTypes\` list means approval is
561
+ required only for those asset types.
562
+ - \`active=false\` means no approval is required; \`assetTypes\` is
563
+ always empty in that case.
564
+
565
+ So per-org JSON looks like:
566
+
567
+ \`\`\`json
568
+ {
569
+ "services": {
570
+ "reporting": { "active": true },
571
+ "reviewing": { "active": true },
572
+ "protection": { "active": false },
573
+ "takedowns": { "active": true, "automated": false },
574
+ "detection": { "active": true },
575
+ "darkWebMonitoring": { "active": false }
576
+ },
577
+ "obligatoryAdminApproval": { "active": true, "assetTypes": ["TWITTER"] },
578
+ "pendingServiceApprovals": [
579
+ {
580
+ "service": "protection",
581
+ "automated": false,
582
+ "serviceType": "isProtectionActive",
583
+ "serviceName": "Wallet Blocking",
584
+ "requestedAt": "2026-05-30T18:04:11.000Z"
585
+ }
586
+ ]
587
+ }
588
+ \`\`\`
589
+
590
+ #### Pending service approvals (Wallet Blocking / Takedowns)
591
+
592
+ Turning on **Wallet Blocking** (\`protection\`, the "is protection active"
593
+ toggle) or **Takedowns** is approval-gated: when a lower-level org member
594
+ tries to enable one, ChainPatrol records a pending request that a higher-up
595
+ at the org \u2014 an org OWNER, or ChainPatrol staff acting as owner \u2014 must
596
+ approve before the service actually turns on. \`pendingServiceApprovals\`
597
+ lists those open, awaiting-sign-off requests per org.
598
+
599
+ This is the answer to "which organizations have a pending approval for
600
+ Wallet blocking or Takedown services?" \u2014 it is NOT the same as "which orgs
601
+ have Wallet Blocking turned off". An org can have \`protection.active=false\`
602
+ with **no** pending approval (nobody has asked) OR **with** a pending
603
+ approval (someone asked and it's waiting on an owner). Only
604
+ \`pendingServiceApprovals\` distinguishes the two.
605
+
606
+ Each entry:
607
+
608
+ - \`service\` \u2014 \`protection\` (Wallet Blocking) or \`takedowns\`, matching the
609
+ \`services\` keys.
610
+ - \`automated\` \u2014 \`true\` when the request is for the automated variant
611
+ (e.g. "Automated Wallet Blocking").
612
+ - \`serviceType\` \u2014 raw enum, e.g. \`isProtectionActive\`.
613
+ - \`serviceName\` \u2014 human label, e.g. \`Wallet Blocking\`.
614
+ - \`requestedAt\` \u2014 when the enable request was submitted (ISO 8601, UTC).
615
+
616
+ An **empty array means nothing is awaiting approval** \u2014 read \`services\` for
617
+ the current on/off state, never infer it from this field.
618
+
619
+ When a user asks about "automated reporting / reviewing / protection",
620
+ explain that the flag exists in the DB but has no operational effect and
621
+ isn't exposed by the public API \u2014 only \`takedowns.automated\` carries a
622
+ real meaning.
623
+
624
+ Filter flags (all optional, all comma-separated lists where noted):
625
+
626
+ - \`--query <text>\` partial name match (substring, case-insensitive)
627
+ - \`--subscription-status <list>\` one or more of \`PROSPECT\`, \`TRIAL\`,
628
+ \`ACTIVE\`, \`INTEGRATION\`. \`INACTIVE\` is intentionally not reachable
629
+ through this filter \u2014 \`orgs list\` only ever returns live customers.
630
+ - \`--service-active <list>\` services that must be active
631
+ - \`--service-inactive <list>\` services that must be inactive
632
+ - \`--service-automated <list>\` services whose automation must be ON.
633
+ **Only \`takedowns\` is accepted** \u2014 the other services don't have a
634
+ meaningful automation toggle. Passing any other service name errors out.
635
+ - \`--service-manual <list>\` services whose automation must be OFF.
636
+ Same restriction \u2014 only \`takedowns\`.
637
+ - \`--obligatory-approval-active\` \u2014 only orgs with admin approval on
638
+ - \`--obligatory-approval-inactive\` \u2014 only orgs with admin approval off
639
+ - \`--obligatory-approval-asset-type <list>\` \u2014 only orgs whose admin
640
+ approval scope covers EVERY listed asset type. The match treats an
641
+ org's empty per-asset-type list as "applies to all asset types", so a
642
+ fully-broad org matches every value passed here. Passing this flag
643
+ implies the feature is on, so it can't be combined with
644
+ \`--obligatory-approval-inactive\`. Use the canonical asset-type enum
645
+ names (\`TWITTER\`, \`URL\`, \`PAGE\`, \u2026); run \`chainpatrol asset types\`
646
+ to see them all.
647
+ - \`--pending-approval-active\` \u2014 only orgs with at least one open
648
+ service-enable approval awaiting a higher-up's sign-off.
649
+ - \`--pending-approval-inactive\` \u2014 only orgs with no pending approvals.
650
+ - \`--pending-approval-service <list>\` \u2014 only orgs with a pending approval
651
+ for one of the listed services. Accepts \`protection\` (Wallet Blocking)
652
+ and/or \`takedowns\` \u2014 those are the only approval-gated services.
653
+ Matches both the manual and automated variant. Passing this flag implies
654
+ a pending approval exists, so it can't be combined with
655
+ \`--pending-approval-inactive\`.
656
+
657
+ Service names: \`reporting\`, \`reviewing\`, \`protection\`, \`takedowns\`,
658
+ \`detection\`, \`darkWebMonitoring\`.
659
+
660
+ Customers see only orgs they're a member of. Staff/superuser sessions see
661
+ every matching org. The response is the same in both cases; visibility is
662
+ enforced server-side.
663
+
664
+ #### Use case: finding which orgs require admin approval for an asset type
665
+
666
+ When a user asks "which orgs require admin approval before blocking
667
+ Twitter assets?", reach straight for the filter \u2014 no client-side
668
+ post-processing needed:
669
+
670
+ \`\`\`bash
671
+ chainpatrol --json orgs list --obligatory-approval-asset-type TWITTER
672
+ \`\`\`
673
+
674
+ To audit just the broad opt-ins ("which orgs require approval for
675
+ everything?"), filter on the toggle and inspect \`assetTypes\` in the
676
+ output \u2014 an empty array means "all":
677
+
678
+ \`\`\`bash
679
+ chainpatrol --json orgs list --obligatory-approval-active \\
680
+ | jq '.organizations[] | select(.obligatoryAdminApproval.assetTypes | length == 0) | .slug'
681
+ \`\`\`
682
+
683
+ #### Use case: tracking orgs with a pending Wallet Blocking / Takedown approval
684
+
685
+ When a user asks "which organizations have a pending approval for Wallet
686
+ blocking or Takedown services?", do NOT reach for \`--service-inactive
687
+ protection\` \u2014 that lists orgs with the service turned OFF, which is a
688
+ different question. Use the pending-approval filter, which surfaces
689
+ staff-initiated enable requests still waiting on a higher-up:
690
+
691
+ \`\`\`bash
692
+ # Every org with a pending Wallet Blocking OR Takedown approval:
693
+ chainpatrol --json orgs list --pending-approval-service protection,takedowns
694
+
695
+ # Just Wallet Blocking:
696
+ chainpatrol --json orgs list --pending-approval-service protection
697
+
698
+ # Any pending approval at all, then read each org's pendingServiceApprovals:
699
+ chainpatrol --json orgs list --pending-approval-active \\
700
+ | jq '.organizations[] | {slug, pending: [.pendingServiceApprovals[].serviceName]}'
701
+ \`\`\`
702
+
703
+ ### \`orgs get\` \u2014 Get a single organization by slug
704
+
705
+ Look up one organization the caller has access to. Returns the same per-org
706
+ shape as a single row from \`orgs list\` \u2014 \`active\` for every service,
707
+ plus \`automated\` on \`takedowns\` only (see the note above on why other
708
+ services don't expose an automation flag), plus \`obligatoryAdminApproval\`
709
+ (\`active\` + \`assetTypes\`) and \`pendingServiceApprovals\` (open Wallet
710
+ Blocking / Takedown enable requests awaiting a higher-up's sign-off).
711
+ Anything you could read from \`orgs list\` you can also read here without
712
+ paging or filtering. Use it when the user names a specific customer ("show
713
+ me acme's setup", "is takedowns automation on for morpho?", "does this org
714
+ require admin approval for Twitter?", "is morpho waiting on a Wallet
715
+ Blocking approval?") and you don't need the rest of the catalogue.
716
+
717
+ \`\`\`bash
718
+ chainpatrol orgs get <slug>
719
+ chainpatrol --json orgs get <slug>
720
+ \`\`\`
721
+
722
+ Permission rules match \`orgs list\`:
723
+
724
+ - Org-scoped API keys: must match the slug \u2014 querying another org returns
725
+ 403.
726
+ - User sessions / user-scoped API keys: need an active OrganizationMembership
727
+ on the slug. Staff/superusers can read any org.
728
+ - Soft-deleted orgs are not returned (404). A 404 also fires for orgs the
729
+ caller would not be authorized to see \u2014 the endpoint deliberately does
730
+ not distinguish "doesn't exist" from "you can't see this" beyond the
731
+ generic 403/404 envelope.
732
+
733
+ Prefer \`orgs get\` over \`orgs list\` + client-side filter whenever the
734
+ caller already knows the slug; it's one round-trip and side-steps the
735
+ list filters entirely.
736
+
737
+ #### Use case: finding service configuration gaps across the customer base
738
+
739
+ When the user asks something like "which customers are paying us but don't
740
+ have takedowns automated yet?" or "any orgs running detection without
741
+ takedowns?", reach for \`orgs list\` \u2014 it's the only command that exposes
742
+ service flags across multiple orgs in one call. Run it in \`--json\` mode
743
+ and summarize patterns by service or by subscription tier.
744
+
745
+ ### \`brands list\` \u2014 List the brands (sub-brands) belonging to an org
746
+
747
+ Returns every brand for the org the caller is authenticated as, both
748
+ parent / product brands (\`type: "ORGANIZATION"\`) and individual /
749
+ employee brands (\`type: "INDIVIDUAL"\`). Soft-deleted brands are excluded.
750
+ The endpoint is org-scoped and inferred from auth \u2014 there's no \`--org\`
751
+ flag \u2014 so org-scoped API keys, user API keys, and user sessions all work
752
+ without extra arguments.
753
+
754
+ \`\`\`bash
755
+ chainpatrol brands list # all brands
756
+ chainpatrol brands list --type INDIVIDUAL # employee / person brands only
757
+ chainpatrol brands list --type ORGANIZATION # product / parent brands only
758
+ chainpatrol --json brands list # machine-readable
759
+ \`\`\`
760
+
761
+ Each entry has \`{ id, slug, name, type, description, brandGroupId, createdAt }\`.
762
+ Use this when you need to:
763
+
764
+ - Distinguish employee vs. product brands ahead of time \u2014 e.g. while
765
+ running a trend search and you want to highlight which spiking
766
+ sub-brands are employees so the user gets a direct heads-up to the
767
+ person involved.
768
+ - Resolve a brand name the user mentions to its \`slug\` for use with
769
+ \`metrics organization --brand-slug <slug>\` or as a \`brandId\` for
770
+ \`takedowns list --brand <id>\`.
771
+ - Audit a customer's setup \u2014 "how many employee brands does this org
772
+ protect?" or "are there brands the org set up but never wired into a
773
+ detection config?"
774
+
775
+ ### \`metrics summary | found | breakdown | organization\` \u2014 Org metrics for spike/drop analysis
776
+
777
+ #### Decision rule \u2014 read this before picking a metrics subcommand
778
+
779
+ When the user asks for a number that **spans more than one customer/org/brand**
780
+ \u2014 phrases like "across all clients", "across all customers", "across all orgs",
781
+ "across all brands", "company-wide", "total takedowns", "total threats",
782
+ "average takedowns per day across customers", "rollup across customers",
783
+ "how many takedowns in the last 7 days?" (no org named) \u2014 the answer is
784
+ **\`chainpatrol metrics organization --all-my-orgs\`** (or \`--slugs\`
785
+ if you want a specific subset). \`summary\`, \`found\`, and \`breakdown\`
786
+ are single-org commands and have **no** \`--slugs\`/\`--all-my-orgs\`
787
+ form; only \`organization\` does. The multi-org form rolls totals +
788
+ per-day / per-org-per-day averages + a per-org breakdown server-side
789
+ in **one** HTTP call.
790
+
791
+ **Anti-patterns to avoid:**
792
+
793
+ - \u274C "There's no cross-org aggregation in the CLI." There is \u2014
794
+ \`metrics organization --all-my-orgs\` (or \`--slugs\`). Don't bail
795
+ out citing the docs without trying these flags.
796
+ - \u274C Looping \`metrics summary --org X\` once per customer to sum
797
+ client-side. The multi-org form is one round-trip; the loop is what
798
+ made the endpoint 503-prone in the first place.
799
+ - \u274C Calling \`orgs list\` to build a slug list when you just want
800
+ "everything." Use \`--all-my-orgs\` and skip the enumeration entirely \u2014
801
+ the server resolves the same set via shared logic. Save \`orgs list\`
802
+ + \`--slugs\` for cases where the user asked for a specific subset.
803
+ - \u274C Routing the user to Metabase / the data warehouse for a question
804
+ the CLI can answer. Reach for Metabase only when the metric isn't
805
+ in the \`--include\` list (\`reports\`, \`newThreats\`,
806
+ \`threatsWatchlisted\`, \`takedownsFiled\`, \`takedownsCompleted\`,
807
+ \`domainThreats\`, \`twitterThreats\`, \`telegramThreats\`,
808
+ \`otherThreats\`, \`blockedByType\`, \`blockedByDay\`).
809
+ - \u274C "Iterating 100+ orgs one-by-one isn't practical here." Right \u2014
810
+ that's why you don't iterate. \`--all-my-orgs\` covers up to 500
811
+ orgs in a single call; for larger fleets, narrow with
812
+ \`--subscription-status\` / \`--service-active\`, or split an
813
+ explicit \`--slugs\` list into batches and sum.
814
+
815
+ #### Common cross-org recipe (copy and run)
816
+
817
+ The shortest answer to "how many takedowns across all customers in the
818
+ last 7 days?" is a single call \u2014 no \`orgs list\` step needed:
819
+
820
+ \`\`\`bash
821
+ chainpatrol --json metrics organization \\
822
+ --all-my-orgs \\
823
+ --subscription-status ACTIVE \\
824
+ --service-active takedowns \\
825
+ --include takedownsCompleted \\
826
+ --from <YYYY-MM-DD 7 days ago> --to <YYYY-MM-DD today>
827
+
828
+ # Read these fields from the JSON:
829
+ # .scope.orgs \u2190 which orgs the server resolved
830
+ # .metrics.takedownsCompleted \u2190 grand total across all orgs
831
+ # .averages.perDay.takedownsCompleted \u2190 total / windowDays
832
+ # .averages.perOrgPerDay.takedownsCompleted \u2190 total / numOrgs / windowDays
833
+ # .perOrg[slug].metrics.takedownsCompleted \u2190 per-customer breakdown
834
+ \`\`\`
835
+
836
+ Replace \`takedownsCompleted\` with whatever metric the user asked about.
837
+ Replace the date range with whatever window they asked about (default
838
+ 3 months if they didn't say).
839
+
840
+ If the user *asked* for a specific subset of customers ("how many for
841
+ acme, beta, gamma combined?"), use \`--slugs acme,beta,gamma\` instead
842
+ of \`--all-my-orgs\`. \`--slugs\` accepts up to 500 entries.
843
+
844
+ **Auth note for \`--all-my-orgs\`:** requires a user session or a
845
+ user-scoped API key (it inherits your memberships). Org-scoped API
846
+ keys are rejected \u2014 they're pinned to a single org by design. If
847
+ \`whoami\` shows an org-scoped key, use a Bearer session instead or
848
+ ask the user to provision a user API key.
849
+
850
+ #### Single-org examples
851
+
852
+ \`\`\`bash
853
+ chainpatrol --json metrics summary --org <slug> # defaults to last 3 months
854
+ chainpatrol --json metrics summary --org <slug> --this-week
855
+ chainpatrol --json metrics breakdown --org <slug> --by day --this-week
856
+ chainpatrol --json metrics found --org <slug> --from <YYYY-MM-DD> --to <YYYY-MM-DD>
857
+ chainpatrol --json metrics organization --org <slug> # defaults to last 3 months
858
+ \`\`\`
859
+
860
+ **Always operate on a bounded window.** When no \`--from\`/\`--to\`/\`--this-week\`
861
+ is passed, every metrics subcommand defaults to the trailing **last 3 months**
862
+ ending now. The default exists because unbounded org-wide aggregates over
863
+ multi-year history routinely time out at the platform layer (Vercel's
864
+ 30s function cap), which surfaces to clients as a 503. Stick to the default,
865
+ or pass an explicit narrower window \u2014 don't try to bypass the default by
866
+ guessing wide \`--from\` values.
867
+
868
+ The resolved range is echoed back in every output format so the user can
869
+ see exactly what they got:
870
+
871
+ - JSON: \`{ "range": { "startDate": "...", "endDate": "...", "label": "last 3 months" } }\`
872
+ - Markdown / human: the header line includes the label, e.g.
873
+ \`Organization metrics for acme \u2014 last 3 months\`, followed by
874
+ \`Range: <startDate> \u2192 <endDate>\`.
875
+
876
+ When reporting numbers to the user (especially averages and rates),
877
+ **state the window explicitly** \u2014 say "averaged over the last 3 months"
878
+ rather than just quoting a number, since the same prompt phrased
879
+ differently can pick a different window.
880
+
881
+ \`breakdown\` is the one you usually want for healthchecks: it returns a
882
+ time series (by day or week) of reports, new threats, watchlisted threats,
883
+ and takedowns filed/completed. Compare the latest period against a prior
884
+ window to spot the **spike** or **drop** signals described in the manual
885
+ HealthCheck Guide. \`summary\` returns a single window total; \`found\` is
886
+ oriented around when threats were first discovered; \`organization\` is
887
+ the full customer-facing dashboard slice (reports, new threats,
888
+ watchlisted, takedowns filed/completed, plus per-type and per-day
889
+ breakdowns).
890
+
891
+ #### \`--include\` \u2014 only compute the metrics you actually need
892
+
893
+ \`metrics organization\` runs one Prisma aggregate per requested field.
894
+ By default all 11 are computed in parallel. Pass \`--include\` (or
895
+ \`include: [\u2026]\` in the JSON body) with the comma-separated subset you
896
+ care about to skip the rest \u2014 the unrequested fields come back as
897
+ \`null\` instead of a number, and the server never runs those queries:
898
+
899
+ \`\`\`bash
900
+ # Only takedowns \u2014 one of the cheap shapes
901
+ chainpatrol --json metrics organization --org <slug> \\
902
+ --include takedownsFiled,takedownsCompleted
903
+
904
+ # Time series only, no scalar counts
905
+ chainpatrol --json metrics organization --org <slug> --include blockedByDay
906
+ \`\`\`
907
+
908
+ Allowed values: \`reports\`, \`newThreats\`, \`threatsWatchlisted\`,
909
+ \`takedownsFiled\`, \`takedownsCompleted\`, \`domainThreats\`,
910
+ \`twitterThreats\`, \`telegramThreats\`, \`otherThreats\`,
911
+ \`blockedByType\`, \`blockedByDay\`.
912
+
913
+ Use this whenever the user's question is specific ("how many takedowns
914
+ did we file last month?"). It is the lowest-effort way to make a
915
+ metrics call cheap enough to run repeatedly. Pair it with an explicit
916
+ date window for the best behavior.
917
+
918
+ #### \`--slugs\` \u2014 multi-org rollups in one call (use this for "across all customers/clients")
919
+
920
+ When the user asks for a total or an average **across more than one
921
+ org** \u2014 e.g. "how many takedowns did we complete across all clients
922
+ in the last 7 days?", "average reports per org per day this month",
923
+ "top 5 customers by new threats" \u2014 reach for \`--slugs\` instead of
924
+ looping. The server fans out the per-org aggregates internally,
925
+ sums into totals, computes per-day and per-org-per-day averages,
926
+ and returns a per-org breakdown in a **single HTTP round trip**:
927
+
928
+ \`\`\`bash
929
+ # Total takedowns completed across three customers, last 7 days
930
+ chainpatrol --json metrics organization \\
931
+ --slugs acme,beta,gamma \\
932
+ --include takedownsCompleted \\
933
+ --from 2026-05-12 --to 2026-05-19
934
+ \`\`\`
935
+
936
+ The response shape switches to multi-org:
937
+
938
+ \`\`\`json
939
+ {
940
+ "scope": { "mode": "multi", "orgs": ["acme", "beta", "gamma"] },
941
+ "metrics": { "takedownsCompleted": 117, ... }, // sum across orgs
942
+ "averages": {
943
+ "perDay": { "takedownsCompleted": 16.71, ... }, // total / windowDays
944
+ "perOrgPerDay": { "takedownsCompleted": 5.57, ... }, // total / numOrgs / windowDays
945
+ "windowDays": 7
946
+ },
947
+ "perOrg": { "acme": { "metrics": { ... } }, "beta": { ... }, "gamma": { ... } }
948
+ }
949
+ \`\`\`
950
+
951
+ To answer **"across all of our customers"**, prefer \`--all-my-orgs\` \u2014
952
+ it lets the server resolve the org set in one round-trip, no \`orgs
953
+ list\` step needed:
954
+
955
+ \`\`\`bash
956
+ chainpatrol --json metrics organization \\
957
+ --all-my-orgs \\
958
+ --subscription-status ACTIVE \\
959
+ --service-active takedowns \\
960
+ --include takedownsCompleted \\
961
+ --from 2026-05-12 --to 2026-05-19
962
+ \`\`\`
963
+
964
+ Use \`--slugs <comma-list>\` only when the user asked for a *specific*
965
+ subset of customers ("how many for acme, beta, gamma combined?"); the
966
+ two flags are mutually exclusive. Both forms cap at 500 orgs per call;
967
+ if a real fleet exceeds that, narrow with
968
+ \`--subscription-status\`/\`--service-active\` filters or split an
969
+ explicit \`--slugs\` list into batches and sum. **Do not loop
970
+ \`metrics organization\` once per org** \u2014 N HTTP round-trips is what
971
+ made the old code 503.
972
+
973
+ Always pair the multi-org form with \`--include\` to narrow the metric
974
+ set to what the user actually asked about. "How many takedowns did
975
+ we complete?" \u2192 \`--include takedownsCompleted\`; "average reports
976
+ per day per customer?" \u2192 \`--include reports\`. Skipping \`--include\`
977
+ runs ~11 aggregates per org which is rarely necessary.
978
+
979
+ #### Auth: which credential can use \`--slugs\` / \`--all-my-orgs\`
980
+
981
+ - **Org-scoped API key** (the most common production key): can only
982
+ query its own org. If \`--slugs\` contains foreign orgs the server
983
+ returns 403; \`--all-my-orgs\` is also rejected. Use the \`--org\`
984
+ form (or omit both) instead.
985
+ - **User API key**: inherits the user's org memberships, so it can
986
+ query any org the user is a member of (or any org for staff
987
+ users) via \`--slugs\` or \`--all-my-orgs\`. This is the credential
988
+ you want for cross-org rollups from automated agents.
989
+ - **Session auth** (Bearer token, e.g. \`chainpatrol login\`): same
990
+ membership rules as the user. Staff users can query any org.
991
+
992
+ #### Reporting numbers to the user
993
+
994
+ Whatever window and scope you choose, **make both explicit in your
995
+ reply** \u2014 say "averaged across 12 customers over the last 3 months"
996
+ or "summed across all paying orgs for the last 7 days." The same
997
+ prompt phrased slightly differently can pick a different window or
998
+ org set, and the response already echoes
999
+ \`scope.mode\` / \`scope.orgs\` / \`averages.windowDays\` /
1000
+ \`range.label\` so you don't have to guess.
1001
+
1002
+ ### \`presets list | run\` \u2014 Packaged workflows for common jobs
1003
+
1004
+ \`\`\`bash
1005
+ chainpatrol presets list
1006
+ chainpatrol presets run cs-weekly-health --org <slug>
1007
+ \`\`\`
1008
+
1009
+ Use \`presets list\` to discover packaged multi-step workflows. The bundled
1010
+ \`cs-weekly-health\` preset runs the standard customer-success weekly health
1011
+ sweep; prefer it over hand-rolling the same sequence of commands.
1012
+
1013
+ ## Headless / agent-mode tips
1014
+
1015
+ When running these commands from an agent or CI:
1016
+
1017
+ - Prefer \`--json\` (or \`--output json\`) so output is structured and the
1018
+ update-check stderr nudge is suppressed automatically.
1019
+ - Pass \`--no-input\` to forbid any interactive prompt (the CLI will error
1020
+ out instead of waiting on a TTY).
1021
+ - Pass \`--no-color\` or set \`NO_COLOR=1\` if your sink can't render ANSI.
1022
+ - Set \`CHAINPATROL_NO_UPDATE_CHECK=1\` to silence the skill/npm freshness
1023
+ nudge entirely.
1024
+ - For \`login\` specifically, see the headless runbook in the login section
1025
+ above \u2014 login is the one command that needs background + tail handling.
1026
+
1027
+ ## Checking Auth Status
1028
+
1029
+ To check if the user is logged in, read the credentials file:
1030
+
1031
+ \`\`\`bash
1032
+ cat ~/.chainpatrol/credentials.json 2>/dev/null && echo "Logged in" || echo "Not logged in"
1033
+ \`\`\`
1034
+
1035
+ Or start the login flow which will detect existing sessions:
1036
+ \`\`\`bash
1037
+ chainpatrol --json login
1038
+ \`\`\`
1039
+
1040
+ ## Configuration
1041
+
1042
+ Config is stored at \`~/.chainpatrol/config.json\`:
1043
+ - \`apiUrl\` \u2014 API base URL (default: \`https://app.chainpatrol.io\`)
1044
+ - \`defaultOrg\` \u2014 Saved organization slug
1045
+
1046
+ Override config dir with \`CHAINPATROL_CONFIG_DIR\` env var.
1047
+
1048
+ ## Version Checks
1049
+
1050
+ The CLI runs two lightweight version checks alongside each command and prints
1051
+ a nudge to stderr if anything is out of date:
1052
+
1053
+ - **Skill freshness**: compares the installed skill (\`~/.claude/skills/chainpatrol/SKILL.md\`)
1054
+ to the version bundled with the CLI. If it's missing or older, the user is
1055
+ asked to run \`chainpatrol setup\`.
1056
+ - **NPM freshness**: compares the running CLI version to the latest published
1057
+ on the npm registry. The check is throttled to once per 24 hours and capped
1058
+ at a 1.5s timeout, with the result cached at \`<configDir>/version-check.json\`.
1059
+
1060
+ Set \`CHAINPATROL_NO_UPDATE_CHECK=1\` to silence both checks. JSON mode
1061
+ (\`--json\`) and quiet mode (\`-q\` / \`--quiet\`) also suppress the nudges so
1062
+ machine-readable output is never polluted.
1063
+
1064
+ ## Global Flags
1065
+
1066
+ | Flag | Description |
1067
+ |------------------|--------------------------------------------------------|
1068
+ | \`--json\` | Machine-readable JSON output (shortcut for \`--output json\`) |
1069
+ | \`--output <fmt>\` | Output format: \`human\` (default), \`json\`, \`markdown\`, \`csv\` |
1070
+ | \`--quiet\`, \`-q\` | Suppress non-essential output and the update-check nudge |
1071
+ | \`--no-color\` | Disable ANSI colors (also respects the \`NO_COLOR\` env var) |
1072
+ | \`--no-input\` | Disable interactive prompts (use in scripts and agents) |
1073
+ | \`--org <slug>\` | Organization slug (saved as the default for later commands) |
1074
+ | \`--help\`, \`-h\` | Show help |
1075
+ | \`--version\` | Show version |
1076
+
1077
+ ## Workflow
1078
+
1079
+ When the user asks to use the CLI, follow this order:
1080
+
1081
+ 1. **Check login status** \u2014 Read \`~/.chainpatrol/credentials.json\` to see if they're logged in
1082
+ 2. **Login if needed** \u2014 Run the login command and guide them through the device code flow
1083
+ 3. **Set org if needed** \u2014 Ensure \`--org\` is provided or already saved in config
1084
+ 4. **Run the requested command** \u2014 Execute the CLI command and show results
1085
+
1086
+ ## Detection Config Output
1087
+
1088
+ The \`configs list\` command shows detection sources grouped by:
1089
+ - **Configured** \u2014 Sources with org-level configs (enabled/disabled with details)
1090
+ - **Global** \u2014 Sources that run globally for all orgs (CERTSTREAM, ASSET_CHECK, BLOCKLIST, etc.)
1091
+ - **Not Configured** \u2014 Sources available but not yet set up for the org
1092
+
1093
+ Each config entry includes: title, status, cron schedule, and configuration parameters.
1094
+
1095
+ ## Organization HealthCheck Guide
1096
+
1097
+ This guide explains how to look for things that may be wrong for a given org
1098
+ across the full pipeline: **detection \u2192 reviewing \u2192 blocklisting \u2192 takedowns**.
1099
+ When the user asks for a "health check", "audit", "what's wrong with org X",
1100
+ "review org X's setup", or similar, walk through each section below and surface
1101
+ findings.
1102
+
1103
+ In each section there are things you can look for that may be wrong. Some
1104
+ checks have a dedicated CLI command that does most of the work server-side;
1105
+ others are soft / qualitative signals that still need you to fetch data with
1106
+ \`configs list\` or \`reports list\` and reason about it manually.
1107
+
1108
+ ### Quick Path: CLI commands that automate parts of this guide
1109
+
1110
+ The canonical first step is now the \`healthchecks\` namespace, which runs
1111
+ every implemented check via the public API and returns a uniform shape per
1112
+ check (\`id\`, \`severity\`, \`observed\`, \`threshold\`, \`findings\`,
1113
+ \`suggestedAction\`):
1114
+
1115
+ \`\`\`bash
1116
+ # Discover every check the platform exposes, implemented or planned.
1117
+ chainpatrol --json healthchecks list
1118
+
1119
+ # Run every implemented healthcheck in parallel and aggregate the results.
1120
+ chainpatrol --json healthchecks run --all --org <slug>
1121
+
1122
+ # Run a single named check.
1123
+ chainpatrol --json healthchecks run reviewing.backlog --org <slug>
1124
+ \`\`\`
1125
+
1126
+ After \`healthchecks run --all\`, use these complementary commands to cover
1127
+ the signals that are not yet exposed as a uniform healthcheck endpoint:
1128
+
1129
+ \`\`\`bash
1130
+ # Spikes / drops in detection volume over time (compare windows)
1131
+ chainpatrol --json metrics breakdown --org <slug> --by day --this-week
1132
+
1133
+ # Customer-reported threats \u2014 gaps in our own detection
1134
+ chainpatrol --json reports list --org <slug> --reported-by-customer
1135
+
1136
+ # What's enabled vs disabled vs not configured for the org
1137
+ chainpatrol --json configs list --org <slug>
1138
+
1139
+ # Snapshot of review/takedown queues \u2014 raw counts behind several healthchecks
1140
+ chainpatrol --json queues snapshot --org <slug>
1141
+
1142
+ # Packaged weekly customer-success sweep (preferred when it covers the ask)
1143
+ chainpatrol presets run cs-weekly-health --org <slug>
1144
+ \`\`\`
1145
+
1146
+ Treat each command's output as one input to the healthcheck. The manual
1147
+ checks below still apply \u2014 especially for signals the CLI cannot infer on
1148
+ its own (e.g. "lots of Twitter assets are blocked but Twitter Post Search
1149
+ is disabled", or "this drop is fine because the config isn't relevant
1150
+ to this org"). Each subsection of the guide notes whether a healthcheck
1151
+ endpoint exists today and what to fall back on when it doesn't.
1152
+
1153
+ ### Reporting progress while running a healthcheck
1154
+
1155
+ When the user asks for a healthcheck, narrate each step in real time so they
1156
+ can watch the run unfold. Do NOT batch results and dump everything at the
1157
+ end. For every check you run (Quick Path CLI command, or a manual signal
1158
+ where you're fetching data with \`configs list\` / \`reports list\` to
1159
+ reason about):
1160
+
1161
+ 1. **Before** you call the command, emit ONE short sentence stating what
1162
+ you're about to check, including the org slug. Examples:
1163
+ - "Running detection config healthcheck for morpho\u2026"
1164
+ - "Snapshotting review and takedown queues for morpho\u2026"
1165
+ - "Fetching customer-reported reports for morpho to look for detection gaps\u2026"
1166
+
1167
+ 2. **As soon as** the command returns, emit ONE short result line that
1168
+ starts with a status word and ends with a key number or finding:
1169
+ - \`DONE\` \u2014 ran cleanly, nothing to flag
1170
+ - \`WARN\` \u2014 soft signal worth surfacing (e.g. a borderline backlog,
1171
+ mild spike or drop, a config you'd want a human to confirm)
1172
+ - \`FAIL\` \u2014 concrete failure that the user should act on
1173
+ - Examples:
1174
+ - "DONE \u2014 14/14 detection configs passing."
1175
+ - "WARN \u2014 23 proposals in the review queue; 4 are older than 7 days."
1176
+ - "FAIL \u2014 twitter_post_search returned 0 results in the last 24h with --run."
1177
+
1178
+ 3. Run **independent** checks in **parallel** (single message, multiple
1179
+ Bash tool calls) so progress lines arrive quickly. \`detections
1180
+ healthcheck\`, \`queues snapshot\`, \`metrics breakdown\`,
1181
+ \`reports list --reported-by-customer\`, and \`configs list\` are all
1182
+ independent of each other and safe to fire concurrently. Dependent
1183
+ follow-ups (e.g. paginating \`reports list\` with a returned cursor,
1184
+ or fetching extra detail on a single failing config) run after the
1185
+ first round.
1186
+
1187
+ 4. After every check is reported, emit a short final **Summary** section:
1188
+ - A one-line status per check (\u2713 / \u26A0 / \u2717 + name + key number).
1189
+ - A short "Top issues" list of the highest-priority FAIL / WARN
1190
+ findings, in priority order, with the concrete next action for each.
1191
+
1192
+ Keep each progress line to one sentence. The goal is for the user to see
1193
+ the healthcheck happening, not to read a wall of text mid-run \u2014 full
1194
+ detail belongs in the final Summary or in a follow-up when the user asks
1195
+ about a specific finding.
1196
+
1197
+ ### Detection
1198
+
1199
+ #### Enable Config That May Be Turned Off for Current Threats
1200
+
1201
+ Blocked threats exist in an asset type but the matching detection source is
1202
+ turned off. For example: lots of Twitter assets are on the blocklist, but
1203
+ detection sources like "Twitter / X User Search" or "Twitter Post Search" are
1204
+ disabled. Those should be turned on.
1205
+
1206
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed in
1207
+ \`healthchecks list\` as \`detections.coverage-gaps\` with
1208
+ \`implemented: false\` \u2014 when reporting this signal in a healthcheck, note
1209
+ "manual check, no API yet". Until the endpoint lands, do the correlation
1210
+ manually: \`chainpatrol --json configs list --org <slug>\` for enabled vs
1211
+ disabled configs, then \`chainpatrol --json reports list --org <slug>\` for
1212
+ recent blocked-item asset types. Flag any asset type where blocked items
1213
+ exist but the matching detection source has \`status: "disabled"\` (or
1214
+ appears in the "Not configured" group).
1215
+
1216
+ #### Spike in Detections
1217
+
1218
+ A spike in recent detections is worth investigating. It could be a bad config
1219
+ change, or it could be a legitimate new attack push in this area \u2014 useful
1220
+ intel to surface to the security team as a targeted spike.
1221
+
1222
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1223
+ in \`healthchecks list\` as \`detections.spike\` with \`implemented: false\`.
1224
+ Until the endpoint lands, use \`chainpatrol --json metrics breakdown --org <slug> --by day --this-week\`
1225
+ (and a comparison window via \`--from\`/\`--to\`) to see daily detection
1226
+ volume. Anything notably above the recent baseline is a spike \u2014 cross-reference
1227
+ against recent config changes for that source.
1228
+
1229
+ #### Drop in Detections
1230
+
1231
+ A drop is also worth looking into. It may be a bad config change, or it may
1232
+ mean the config is not really relevant and can be safely turned off (not all
1233
+ default-on configs are relevant to every org).
1234
+
1235
+ **Run via CLI:** the extreme case ("this source went silent") is covered
1236
+ today by \`chainpatrol --json healthchecks run detections.silent-configs --org <slug>\`,
1237
+ which is the canonical replacement for the older \`detections healthcheck\`.
1238
+ It fails any config whose \`recentResultCount\` is below \`--min-results\`
1239
+ in the \`--lookback-hours\` window; pass \`--run\` (via the lower-level
1240
+ \`detections healthcheck --run\`) to also catch configs that error when
1241
+ executed. For soft drops (still producing results but below baseline),
1242
+ \`detections.drop\` is marked \`implemented: false\` in \`healthchecks list\`
1243
+ \u2014 use \`metrics breakdown --by day\` and compare windows manually.
1244
+
1245
+ ### Reviewing
1246
+
1247
+ PENDING proposals split into two operationally distinct buckets:
1248
+
1249
+ - **Needs Review** \u2014 assets not on a watchlist, or reports submitted by a
1250
+ customer. This is the reviewing UI's default view (\`excludeWatchlisted=true\`)
1251
+ and the actionable queue reviewers work from. Pile-ups and aged items
1252
+ here are high priority \u2014 \`fail\` severity is reachable.
1253
+ - **Watchlisted** \u2014 pending proposals on watchlisted assets (excluding
1254
+ customer-reported reports). The UI hides these by default because
1255
+ watchlisting is the act of intentionally deferring the asset. Pile-ups
1256
+ and aged items here are worth surfacing as cleanup work but **severity
1257
+ is capped at warn** \u2014 they should never block on the same SLA as Needs
1258
+ Review.
1259
+
1260
+ Each bucket has its own pile-up and age check, so you can grade them
1261
+ independently and tune thresholds without one drowning the other.
1262
+
1263
+ #### Pile Up / Backlog of Needs-Review Proposals
1264
+
1265
+ Too many proposals waiting in review. For most organizations this is over 100
1266
+ reports, but really the threshold is relative to the average number of
1267
+ confirmed threats per week. Example: if an org only adds 5 blocked threats per
1268
+ week, then a 7-day backlog of even 10 proposals is a really big deal.
1269
+
1270
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.backlog\`.**
1271
+ The endpoint counts the **Needs Review** subset only (assets not
1272
+ watchlisted, or reports marked \`reportedByCustomer\`) and grades severity
1273
+ against per-org thresholds (default warn=50, fail=100; override with
1274
+ \`--warn-threshold\` / \`--fail-threshold\` via the run payload). This is
1275
+ the number the reviewing page in the app shows by default, so the
1276
+ healthcheck output matches what reviewers see.
1277
+
1278
+ For raw counts plus SLA / age breakdowns,
1279
+ \`chainpatrol --json queues snapshot --org <slug>\` remains useful and
1280
+ exposes \`reviewQueue.totalPendingProposals\` and
1281
+ \`reviewQueue.distinctReports\` (note: \`queues snapshot\` does NOT apply
1282
+ the watchlist filter, so its number is the sum of Needs Review +
1283
+ Watchlisted). Compare against the org's typical weekly throughput
1284
+ (use \`metrics summary --this-week\` for that baseline) \u2014 a backlog that
1285
+ exceeds a week of typical confirmed-threat volume is a finding regardless
1286
+ of the absolute number.
1287
+
1288
+ #### Really Old Needs-Review Proposals
1289
+
1290
+ Any Needs-Review proposal waiting longer than 14 days is a sign something
1291
+ has gone wrong. Even complex investigations rarely take longer than this.
1292
+ Except for rare cases, these should be rejected or approved to prevent a
1293
+ backlog from building.
1294
+
1295
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.old-proposals\`.**
1296
+ The endpoint counts Needs-Review proposals older than the warn / fail age
1297
+ thresholds (default 7 / 14 days) and lists the oldest offenders in
1298
+ \`findings\`. \`queues snapshot\` (\`reviewQueue.ageBuckets.gte168h\`) still
1299
+ works as a raw view, and \`reviewQueue.slaBuckets.breached\` captures the
1300
+ strictest SLA breaches separately \u2014 any non-zero value is worth raising.
1301
+
1302
+ #### Watchlist Pile-Up / Old Watchlisted Proposals
1303
+
1304
+ Watchlisted-pending proposals are deferred on purpose, but they shouldn't
1305
+ grow unbounded \u2014 a huge pile or very-old items signal that the watchlist
1306
+ needs a cleanup pass. These don't block on the same SLA as Needs Review.
1307
+
1308
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.watchlist-backlog\`**
1309
+ (pile-up count, default warn=200) and
1310
+ **\`healthchecks run reviewing.watchlist-old\`** (default warn-age 30
1311
+ days). Both cap severity at warn. When reporting findings during an org
1312
+ healthcheck, group them under "watchlist cleanup" rather than mixing with
1313
+ Needs-Review findings \u2014 they're operationally different concerns.
1314
+
1315
+ #### Spike in Auto Approved Reports
1316
+
1317
+ If suddenly a lot of proposals in an org are being approved by automation,
1318
+ that can be a sign of a bad rule approving too much, or a break in auto
1319
+ confidences. Sometimes detection is spamming things that uniquely combine
1320
+ with a weakness of a rule \u2014 which is effectively a bad rule. In all these
1321
+ cases, notify an engineer at ChainPatrol and check any detection configs you
1322
+ adjusted recently, since those may be the cause of spam combined with a weak
1323
+ rule.
1324
+
1325
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1326
+ in \`healthchecks list\` as \`reviewing.auto-approval-spike\` with
1327
+ \`implemented: false\`. As a proxy until the endpoint lands, use
1328
+ \`chainpatrol --json metrics breakdown --org <slug> --by day --this-week\`
1329
+ and look for a sudden surge in \`newThreats\` / \`threatsWatchlisted\` that
1330
+ isn't matched by a parallel rise in reviewer activity \u2014 that gap usually
1331
+ points at automation doing the approving.
1332
+
1333
+ ### Blocklisting
1334
+
1335
+ #### Google Safe Browsing (Coming Soon)
1336
+
1337
+ (Needs new public API added before this works.)
1338
+
1339
+ High error rate in Google Safe Browsing submission tracker. Each submission
1340
+ has a status. If too many are in \`CANCELLED\`, that means Google's engine
1341
+ denied our submission. Contact ChainPatrol's eng team to investigate why, and
1342
+ also take a look at the org's custom detection sources \u2014 it's possible there
1343
+ are too many false positives landing on the blocklist, indicating issues with
1344
+ detection and reviewing rules.
1345
+
1346
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1347
+ in \`healthchecks list\` as \`blocklisting.gsb-cancelled-rate\` with
1348
+ \`implemented: false\`. Until Google Safe Browsing submission state is
1349
+ exposed in the public API, this remains a manual / engineering-team check.
1350
+
1351
+ ### Takedowns
1352
+
1353
+ The takedown pipeline has three stages \u2014 TODO (queued, not yet filed),
1354
+ IN_PROGRESS (filed, waiting on vendor / customer / refile), and a terminal
1355
+ state (COMPLETED or CANCELLED). Healthchecks cover pile-ups at each stage,
1356
+ plus quality/configuration issues.
1357
+
1358
+ #### Too Many Takedowns in ToDo
1359
+
1360
+ Can mean a gap in automated takedowns not being implemented for some new area
1361
+ of threats. It can also mean the areas that require manual takedowns are
1362
+ being missed by the takedown team.
1363
+
1364
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.todo-volume\`.**
1365
+ Counts takedowns sitting in TODO (default warn=50, fail=100). For raw
1366
+ breakdowns by type, cross-reference with
1367
+ \`chainpatrol --json metrics breakdown --org <slug> --by assetType\` \u2014
1368
+ items piled up on a specific platform usually point at an automation
1369
+ gap there.
1370
+
1371
+ #### Too Many Takedowns In Progress
1372
+
1373
+ Typically means something is wrong with the submission itself. The takedown
1374
+ may need to be resubmitted, the vendor asked for more evidence, or we may
1375
+ have submitted it in the wrong place.
1376
+
1377
+ **Run via CLI:** Two checks, complementary:
1378
+
1379
+ - **\`healthchecks run takedowns.in-progress-volume\`** \u2014 counts all
1380
+ IN_PROGRESS takedowns regardless of age (default warn=30, fail=75).
1381
+ Catches a vendor-side or submission-format problem before items go
1382
+ stale.
1383
+ - **\`healthchecks run takedowns.stale-in-progress\`** \u2014 counts IN_PROGRESS
1384
+ takedowns past a staleness threshold (default 7 days), lists the oldest
1385
+ offenders. Any non-zero value is worth investigating; a growing count
1386
+ across snapshots strongly suggests vendor-side or format issues.
1387
+
1388
+ #### Too Many Cancelled Takedowns
1389
+
1390
+ Takedowns should rarely be cancelled. A cancelled takedown means "we will not
1391
+ do this takedown" for some reason. Cases like adding an item to the blocklist
1392
+ when it's already taken down are treated as completed, not cancelled. So even
1393
+ 3 cancelled takedowns in a 7-day period is too many.
1394
+
1395
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.cancelled-count\`.**
1396
+ Counts transitions into the CANCELLED status from the TakedownEvent log
1397
+ within the lookback window (default 7 days, warn=3, fail=10). The check
1398
+ uses the event log rather than \`Takedown.updatedAt\` so it correctly
1399
+ attributes the cancellation date even if the takedown has since been
1400
+ edited. A spike usually means a quality problem in the proposal funnel
1401
+ or the CANCELLED status being used as a catch-all.
1402
+
1403
+ #### Automated Takedowns Turned Off for Over 30 Days
1404
+
1405
+ Automated takedowns should be on by default for nearly every organization.
1406
+ Any issue that would make you want to turn off automated takedowns should be
1407
+ resolved within 30 days.
1408
+
1409
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.automation-off\`.**
1410
+ Checks \`Organization.isAutomatedTakedownsActive\` and derives the
1411
+ off-duration from the most recent \`SERVICES_AUTOMATED_TAKEDOWNS_UPDATED\`
1412
+ entry in \`OrganizationEvent\` (default warn 30 days, fail 60 days). Orgs
1413
+ with takedown service entirely disabled (\`isTakedownsActive=0\`) are
1414
+ skipped \u2014 automation being off is implied in that case.
1415
+
1416
+ ### Assets
1417
+
1418
+ Healthchecks on the asset model \u2014 specifically asset liveness state, which
1419
+ the takedown team depends on for follow-up.
1420
+
1421
+ #### Spike in Recently Dead Assets
1422
+
1423
+ A sudden spike in DEAD detections can be a good signal (takedowns or platform
1424
+ moderation working) but it can also mean the liveness checker is
1425
+ misclassifying assets after a platform change, captcha rollout, or anti-bot
1426
+ update. If many assets become dead at once, sample a few manually.
1427
+
1428
+ **Run via CLI:** **Implemented as \`healthchecks run assets.dead-asset-spike\`.**
1429
+ Compares \`DETECTED_AS_DEAD\` events in the current window (default 24h)
1430
+ against the baseline rate from the prior \`baselineDays\` (default 7d).
1431
+ Severity fires only when the current count clears \`minSpikeCount\` (default
1432
+ 10) AND exceeds the multiplier (default warn \xD72, fail \xD74). The
1433
+ \`minSpikeCount\` floor suppresses noise on orgs with near-zero baseline
1434
+ activity. When this fires, pull a sample of recent DEAD assets, verify a
1435
+ few in a browser, and notify ChainPatrol engineering if the sample is
1436
+ clearly still live.
1437
+
1438
+ #### Assets Marked Dead but Still Online / Assets Not Marked Dead Even Though They Are Down
1439
+
1440
+ These two opposite failure modes are **not implemented as healthchecks**
1441
+ (listed as \`assets.dead-but-alive\` and \`assets.alive-but-marked-dead\` with
1442
+ \`implemented: false\`). Both require live HTTP probes against asset URLs,
1443
+ which is not a synchronous-healthcheck shape.
1444
+
1445
+ Until a dedicated probe command exists:
1446
+
1447
+ - For "marked dead but still alive": sample a handful of recently-DEAD
1448
+ assets, open them in a browser, and watch for any that load. Common
1449
+ causes: bot protection, geo-blocking, rate limits, or liveness logic
1450
+ that does not handle the asset type correctly.
1451
+ - For "alive but marked dead": after a known takedown event, sample
1452
+ assets that *should* be dead but are still marked alive. Common causes:
1453
+ cached responses, soft-404 pages, parked-domain redirects, platform
1454
+ suspension pages still returning 200.
1455
+
1456
+ In both cases, if liveness looks miscalibrated for a class of assets,
1457
+ notify ChainPatrol engineering \u2014 the checker likely needs a tuning pass for
1458
+ that platform.
1459
+
1460
+ ## Organization Trend Search Guide
1461
+
1462
+ Trend search asks "what's changed recently for this org?" \u2014 the answer can
1463
+ surface coordinated attacks, new attack channels, or campaigns targeting
1464
+ specific people, **before** they show up as a healthcheck failure. Unlike
1465
+ the HealthCheck Guide above (which grades single signals against
1466
+ thresholds), trend search compares a recent window to a baseline window
1467
+ and flags ratios, not absolute counts. A trend is interesting even when
1468
+ the pipeline is keeping up with it \u2014 the user usually wants to know.
1469
+
1470
+ When the user asks something like:
1471
+
1472
+ - "are there any trends in org X?"
1473
+ - "search for trends in <org>"
1474
+ - "anything unusual happening with <org> lately?"
1475
+ - "any spikes for <org>?"
1476
+ - "what's new for <org> this week?"
1477
+ - "is anyone targeting <org>'s employees more than usual?"
1478
+ - "are we seeing more YouTube/Telegram/etc. threats for <org>?"
1479
+
1480
+ \u2026run the three trend checks below in parallel (single message, multiple
1481
+ Bash calls) and surface anything where the current rate is \u2265 2\xD7 the
1482
+ baseline AND clears a small absolute floor.
1483
+
1484
+ ### How to compute "current vs. baseline" rates
1485
+
1486
+ Pick two non-overlapping windows: a **current** window the user cares about
1487
+ (default last 7 days) and a **baseline** window ending where the current
1488
+ one starts (default the prior ~90 days, i.e. \`current_start - 90d\` \u2192
1489
+ \`current_start - 1d\`). For any breakdown bucket, compute:
1490
+
1491
+ \`\`\`
1492
+ current_per_day = current_count / current_window_days
1493
+ baseline_per_day = baseline_count / baseline_window_days
1494
+ ratio = current_per_day / max(baseline_per_day, epsilon)
1495
+ \`\`\`
1496
+
1497
+ Flag a bucket if \`ratio >= 2\` AND \`current_count >= 5\`. The floor
1498
+ suppresses noise on orgs with near-zero baseline activity (a single new
1499
+ YouTube report jumping the rate from 0 to 1/day shouldn't trigger). If
1500
+ the user gives a different window ("last 3 days", "this month"), adjust
1501
+ both windows proportionally and keep the same ratio threshold.
1502
+
1503
+ ### Trend 1 \u2014 Spike in a specific asset type
1504
+
1505
+ A sudden jump in threats on a platform the org doesn't usually see
1506
+ traffic on ("normally you don't get targeted on YouTube much, but now
1507
+ there's a spike there") is worth flagging \u2014 it usually means an attacker
1508
+ has discovered a new channel that works for them. Even when the absolute
1509
+ number is small, the *ratio* against the org's normal mix is what
1510
+ matters.
1511
+
1512
+ Use \`metrics breakdown --by type\` over both windows:
1513
+
1514
+ \`\`\`bash
1515
+ # Current window \u2014 last 7 days, broken out by asset type
1516
+ chainpatrol --json metrics breakdown --org <slug> --by type \\
1517
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1518
+
1519
+ # Baseline window \u2014 prior ~90 days ending where the current window starts
1520
+ chainpatrol --json metrics breakdown --org <slug> --by type \\
1521
+ --from <YYYY-MM-DD 97d ago> --to <YYYY-MM-DD 8d ago>
1522
+ \`\`\`
1523
+
1524
+ Each entry in \`.points\` has \`{ type, count }\`. Join the two windows on
1525
+ \`type\`, apply the ratio rule above, and report each flagged type.
1526
+
1527
+ Cross-reference any flagged type with \`configs list --org <slug>\` \u2014 if
1528
+ the spike is on Twitter / X but \`twitter_post_search\` is disabled, the
1529
+ detection source for that channel isn't even running for this org and
1530
+ the spike is being caught by something else (likely customer reports);
1531
+ suggest turning it on.
1532
+
1533
+ ### Trend 2 \u2014 Spike in overall threat volume
1534
+
1535
+ A sharp rise in total threats across the org \u2014 regardless of type or
1536
+ brand \u2014 usually means a coordinated attack or campaign is underway. This
1537
+ isn't a healthcheck (reviewing and takedowns may be keeping up just
1538
+ fine), but the security team still wants to know so they can warn
1539
+ customers / employees / partners.
1540
+
1541
+ \`\`\`bash
1542
+ # Daily volume for the last ~6 weeks \u2014 enough to eyeball a baseline AND
1543
+ # see the spike on the right edge of the series.
1544
+ chainpatrol --json metrics breakdown --org <slug> --by day \\
1545
+ --from <YYYY-MM-DD 42d ago> --to <YYYY-MM-DD today>
1546
+ \`\`\`
1547
+
1548
+ Read \`.points\` (one entry per day). Take the trailing 7-day average and
1549
+ compare against the prior ~5 weeks (the same 2\xD7 / floor rule). For round
1550
+ totals to quote to the user, also pull:
1551
+
1552
+ \`\`\`bash
1553
+ # Two calls \u2014 current and baseline windows \u2014 using --include to skip
1554
+ # the per-type / per-day series and keep the call cheap.
1555
+ chainpatrol --json metrics organization --org <slug> \\
1556
+ --include reports,newThreats,threatsWatchlisted \\
1557
+ --from <current_from> --to <current_to>
1558
+
1559
+ chainpatrol --json metrics organization --org <slug> \\
1560
+ --include reports,newThreats,threatsWatchlisted \\
1561
+ --from <baseline_from> --to <baseline_to>
1562
+ \`\`\`
1563
+
1564
+ When volume spikes broadly, also skim \`reports list --reported-by-customer\`
1565
+ for the same window \u2014 a wave of customer reports often arrives a few hours
1566
+ ahead of automated detection on a real coordinated push.
1567
+
1568
+ ### Trend 3 \u2014 Spike on a specific sub-brand (especially employee brands)
1569
+
1570
+ Sub-brands the org has set up for individual people \u2014 employees,
1571
+ executives, public figures \u2014 are high-signal targets. A sudden spike on
1572
+ one usually means an attacker is impersonating that person specifically,
1573
+ which is materially different from a generic phishing wave and usually
1574
+ warrants a direct heads-up to the person involved. In the database these
1575
+ are \`Brand\` rows with \`type: INDIVIDUAL\` (vs. \`ORGANIZATION\` for
1576
+ product / parent brands).
1577
+
1578
+ **Step 1: Pull the brand roster** so you can label each spike as
1579
+ "employee" or "product" without asking the user.
1580
+
1581
+ \`\`\`bash
1582
+ chainpatrol --json brands list
1583
+ \`\`\`
1584
+
1585
+ Build a map of \`slug \u2192 type\` from the response so the next step's
1586
+ findings can be tagged \`(employee)\` or \`(product)\` automatically.
1587
+
1588
+ **Step 2: Run the breakdown over both windows.**
1589
+
1590
+ \`\`\`bash
1591
+ # Current window \u2014 last 7 days, broken out by sub-brand
1592
+ chainpatrol --json metrics breakdown --org <slug> --by brand \\
1593
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1594
+
1595
+ # Baseline window \u2014 prior ~90 days
1596
+ chainpatrol --json metrics breakdown --org <slug> --by brand \\
1597
+ --from <YYYY-MM-DD 97d ago> --to <YYYY-MM-DD 8d ago>
1598
+ \`\`\`
1599
+
1600
+ Each entry in \`.points\` has \`{ brandId, brandSlug, brandName, count }\`.
1601
+ Apply the ratio rule, join against the \`slug \u2192 type\` map from Step 1,
1602
+ and report each spiking sub-brand by name plus its type.
1603
+
1604
+ **Step 3: Drill into the flagged brand** with \`metrics organization
1605
+ --brand-slug <slug>\` for a per-day / per-type breakdown scoped to that
1606
+ brand only. The server applies the brand filter to the scalar metrics
1607
+ (\`newThreats\`, \`takedownsFiled\`, etc.) AND to \`blockedByType\` /
1608
+ \`blockedByDay\`, so the time series and per-asset-type counts are real
1609
+ brand-only data:
1610
+
1611
+ \`\`\`bash
1612
+ chainpatrol --json metrics organization --org <slug> \\
1613
+ --brand-slug <brand-slug> \\
1614
+ --include newThreats,blockedByType,blockedByDay \\
1615
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1616
+ \`\`\`
1617
+
1618
+ If multiple \`INDIVIDUAL\` brands are spiking at the same time, treat that
1619
+ as a stronger signal than a single one \u2014 likely a campaign targeting the
1620
+ company's people rather than a single impersonation. Prioritize those
1621
+ findings over single-brand spikes when summarizing.
1622
+
1623
+ ### Reporting trend findings
1624
+
1625
+ Report each spiking bucket as its own finding with: the trend it falls
1626
+ under (asset type / overall volume / sub-brand), the current vs. baseline
1627
+ rate (e.g. "youtube: 12/day last 7d vs. 1.2/day prior 90d, \xD710
1628
+ baseline"), and a one-line follow-up:
1629
+
1630
+ - Asset-type spike \u2192 check \`configs list\` for the matching detection
1631
+ source and turn it on if it's off.
1632
+ - Overall-volume spike \u2192 flag a possible coordinated campaign; suggest
1633
+ the security team look at the recent \`reports list\` for shared
1634
+ infrastructure (sender, registrar, hosting).
1635
+ - Sub-brand spike \u2192 look up \`type\` via \`brands list\`; if
1636
+ \`INDIVIDUAL\`, suggest a direct heads-up to that person; if
1637
+ \`ORGANIZATION\`, suggest a product-team alert.
1638
+
1639
+ If none of the three trends fire above the 2\xD7 / floor thresholds, say so
1640
+ explicitly ("no significant trends in the last 7 days vs. the prior 90")
1641
+ rather than dumping every breakdown number \u2014 the absence is the
1642
+ finding.
1643
+ `;
1644
+ }
1645
+
1646
+ export { buildSkillContent };
1647
+ //# sourceMappingURL=chunk-UTEZF4EZ.mjs.map
1648
+ //# sourceMappingURL=chunk-UTEZF4EZ.mjs.map